Unrar split RARs on Windows using Cygwin

Sometimes out of dire circumstances one may download a huge set of rars. Unraring all the scene release files in split rar format in each separate directory with their separate subtitles (idx/sub files) is a cumbersome task.

  1. Install unrar from http://gnuwin32.sourceforge.net/packages/unrar.htm
  2. cd into the base season directory using cygwin.
  3. Unrar recursively:
    find Lost.S01E* -iname "*.rar" -exec sh -c 'dir=`dirname {}` && unrar -o- e "{}" $dir && cd "$PWD"' \;
  4. You may need to run this multiple times to catch the rars that the rars may create.

Install latest Chromium on Raspberry Pi B+

Installing the latest Chromium browser on Raspberry Pi B models is a hassle. Although the following tricks work on the other Raspberry Pi models. I wanted to target Raspberry Pi B+ with this tutorial since it requires some special steps.

  1. Download the latest .deb package files:
  2. Ensure you have gdebi:
    sudo apt-get install gdebi-core
  3. Install the packages one by one (install libgcrypt11 first!!!):
    sudo gdebi libgcrypt11
    sudo gdebi chromium-codecs-ffmpeg-extra
    sudo gdebi chromium-browser
    
  4. Run:
    chromium-browser

WordPress as a Service

At two recent WordPress conferences, WPCampus 2016 and WordCamp Boston 2016, I gave a talk along with Andrew Bauer on using WordPress as a Service (WPaaS) in a higher education setting.

In this talk, we covered the organizational and technical benefits of running a multi-network, multi-site WordPress as the primary CMS at Boston University. We highlighted specific strategies, including organizational policies, development workflows and team structure that allow us to serve over a million users per month. We’re here to help dispel the notion that a centralized approach to WordPress can’t successfully be implemented in higher ed.

Slides:

Talk:

Kodi’s Pulsar errors starting up

If you are seeing the following Pulsar errors, check the possible solutions:

Problem: Trying to launch Pulsar

21:31:27 T:2440  NOTICE: [plugin.video.pulsar] 2015-02-03 21:31:27  INFO  btservice        Starting DHT...
21:31:27 T:2440  NOTICE: [plugin.video.pulsar] 2015-02-03 21:31:27  INFO  btservice        Starting LSD...
21:31:27 T:2440  NOTICE: [plugin.video.pulsar] 2015-02-03 21:31:27  INFO  btservice        Starting UPNP...
21:31:27 T:2440  NOTICE: [plugin.video.pulsar] 2015-02-03 21:31:27  INFO  btservice        Starting NATPMP...
21:31:27 T:4984  NOTICE: Thread LanguageInvoker start, auto delete: false
21:31:27 T:4984  NOTICE: -->Python Interpreter Initialized<--
21:31:27 T:4984  NOTICE: http://localhost:65251/
21:31:28 T:4984   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <class 'urllib2.URLError'>
                                            Error Contents: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
                                            Traceback (most recent call last):
                                              File "C:\Users\TVComputer\AppData\Roaming\Kodi\addons\plugin.video.pulsar\navigation.py", line 6, in <module>
                                                navigation.run()
                                              File "C:\Users\TVComputer\AppData\Roaming\Kodi\addons\plugin.video.pulsar\resources\site-packages\pulsar\navigation.py", line 72, in run
                                                data = _json(url)
                                              File "C:\Users\TVComputer\AppData\Roaming\Kodi\addons\plugin.video.pulsar\resources\site-packages\pulsar\navigation.py", line 40, in _json
                                                with closing(urllib2.urlopen(url)) as response:
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 127, in urlopen
                                                return _opener.open(url, data, timeout)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 404, in open
                                                response = self._open(req, data)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 422, in _open
                                                '_open', req)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 382, in _call_chain
                                                result = func(*args)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 1214, in http_open
                                                return self.do_open(httplib.HTTPConnection, req)
                                              File "C:\Program Files (x86)\Kodi\system\python\Lib\urllib2.py", line 1184, in do_open
                                                raise URLError(err)
                                            URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
                                            -->End of Python script error report<--
21:31:29 T:4548   ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://plugin.video.pulsar/
21:31:29 T:4548   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.pulsar/) failed
21:31:29 T:764  NOTICE: Thread BackgroundLoader start, auto delete: false

Solution
Wait for Pulsar to start up. It usually takes about 1-2 minutes for it to load after Kodi has been enabled.

Problem: Deleting missing stale files

17:08:01 T:139736123422464 NOTICE: [plugin.video.pulsar] Deleting stale files set(['C:\\path\\to\\file\\filename.mp4'])

Solution

  1. Go to %APPDATA%\Kodi\ directory.
  2. Delete the cache directory.
  3. Delete the userdata\addon_data\plugin.video.pulsar\cache directory

WordPress failing to insert post into the database

I was recently trying to insert imported data into WordPress. When trying to insert it into WordPress using wp_insert_post, I was receiving the following error:

Could not insert post into the database

It turns out that I was trying to insert data in a non-utf8 encoding, whereas WordPress uses UTF8 internally. All I had to do was run the following PHP function to convert it over to UTF8:

$post_content = iconv('ISO-8859-1','UTF-8', $post_content)

MySQL CSV import skipping rows

I was experiencing problems with loading CSV files into MySQL tables. I noticed that it was skipping every other row in most cases. I was using the following SQL code to load the CSV file:

LOAD DATA LOCAL INFILE 'test.csv'
INTO TABLE games
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 0 LINES;

Solution:
It turns out that the CSV file that I was loading had line endings that my MySQL client did not recognize. I found out that the CSV file was coming from a Windows machine while I was trying to load it onto a Mac OSX machine’s MySQL client/server.

To fix this, I ran the following conversion command, which removed the Windows specific line endings:

cat test.csv | tr -d '\r' > "test.fixed.csv"

I verified that this fixed the file by opening it up in TextWrangler and noting the line ending style on the bottom status bar.

Avoid email submission on SHOUTcast DNAS download

SHOUTcast makes you submit a valid email each time you want to download SHOUTcast DNAS or DSP. I’ve put links below that let you to download x86 (32-bit) and x64 (64-bit) straight without nag screens. These links will not get outdated because they always point to the latest.

Linux x64 link

Windows, BSD, Mac OSX, ARM and DSP links can also be found in the parent directory index.

mDNSResponder and discoveryd hanging in Yosemite: CPU spikes at 100%

Since updating to Yosemite, I have been seeing 100% CPU spikes. You will see message (like the ones pasted below) from the Console.app. For some reason, discoveryd and mDNSResponder start going wild. Most of the instructions found online tell us to restart /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist using launchctl. However in Yosemite, there is no com.apple.mDNSResponder.plist.

Solution
You must restart discoveryd like the following:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist

Console error messages

dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:70 Err:-1 Errno:61 Connection refused
1/23/15 2:20:59.358 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:20:59.477 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:26 Err:-1 Errno:61 Connection refused
1/23/15 2:20:59.478 PM Slack[16482]: tcp_connection_host_start 1929 DNSServiceCreateConnection failed: -65563
1/23/15 2:20:59.508 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:20:59.609 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:20:59.679 PM Google Chrome[15689]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:20:59.755 PM awacsd[265]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:20:59.774 PM coreaudiod[444]: 2015-01-23 02:20:59.774313 PM [BonjourBrowser] Retrying Bonjour start for _raop._tcp. after failure
1/23/15 2:20:59.775 PM coreaudiod[444]: 2015-01-23 02:20:59.774751 PM [BonjourBrowser] Retrying Bonjour start for _airplay._tcp. after failure
1/23/15 2:20:59.775 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:20:59.775 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:00.015 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:15 Err:-1 Errno:61 Connection refused
1/23/15 2:21:00.015 PM Slack[16482]: tcp_connection_host_start 1930 DNSServiceCreateConnection failed: -65563
1/23/15 2:21:00.300 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:00.360 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:00.513 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:00.614 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:00.666 PM sharingd[460]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:00.685 PM Google Chrome[15689]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:00.829 PM awacsd[265]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:00.841 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:00.841 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:01.117 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:01.177 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:01.301 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:01.365 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:34 Err:-1 Errno:61 Connection refused
1/23/15 2:21:01.366 PM Slack[16482]: tcp_connection_host_start 1932 DNSServiceCreateConnection failed: -65563
1/23/15 2:21:01.366 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:01.469 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:01.519 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:01.615 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:27 Err:-1 Errno:61 Connection refused
1/23/15 2:21:01.615 PM Slack[16482]: tcp_connection_host_start 1931 DNSServiceCreateConnection failed: -65563
1/23/15 2:21:01.670 PM sharingd[460]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:01.686 PM Google Chrome[15689]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:54 Err:-1 Errno:61 Connection refused
1/23/15 2:21:01.687 PM Google Chrome[15689]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:01.883 PM awacsd[265]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:11 Err:-1 Errno:61 Connection refused
1/23/15 2:21:01.883 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:01.883 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:01.883 PM awacsd[265]: RRMetaClientItem: DNSServiceQueryRecord: -65563
1/23/15 2:21:01.884 PM awacsd[265]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:02.122 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:02.180 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:02.307 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:30 Err:-1 Errno:61 Connection refused
1/23/15 2:21:02.307 PM Slack[16482]: tcp_connection_host_start 1933 DNSServiceCreateConnection failed: -65563
1/23/15 2:21:02.308 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:02.369 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:02.475 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:02.522 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:26 Err:-1 Errno:61 Connection refused
1/23/15 2:21:02.522 PM Slack[16482]: tcp_connection_host_start 1934 DNSServiceCreateConnection failed: -65563
1/23/15 2:21:02.522 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
1/23/15 2:21:02.674 PM sharingd[460]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:02.691 PM Google Chrome[15689]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:02.938 PM awacsd[265]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:02.938 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:5 Err:-1 Errno:61 Connection refused
1/23/15 2:21:02.938 PM coreaudiod[444]: dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:6 Err:-1 Errno:61 Connection refused
1/23/15 2:21:02.938 PM coreaudiod[444]: 2015-01-23 02:21:02.938188 PM [BonjourBrowser] ### Start browse for _raop._tcp. on if <any>, flags 0x7000000000100000 failed: -65563/0xFFFEFFE5 kDNSServiceErr_ServiceNotRunning
1/23/15 2:21:02.939 PM coreaudiod[444]: 2015-01-23 02:21:02.938754 PM [BonjourBrowser] ### Start browse for _airplay._tcp. on if <any>, flags 0x7000000000100000 failed: -65563/0xFFFEFFE5 kDNSServiceErr_ServiceNotRunning
1/23/15 2:21:02.939 PM coreaudiod[444]: 2015-01-23 02:21:02.939078 PM [BonjourBrowser] ### Browse for _raop._tcp. failed, retrying in 7349 ms: -65563/0xFFFEFFE5 kDNSServiceErr_ServiceNotRunning
1/23/15 2:21:02.939 PM coreaudiod[444]: 2015-01-23 02:21:02.939416 PM [BonjourBrowser] ### Browse for _airplay._tcp. failed, retrying in 7349 ms: -65563/0xFFFEFFE5 kDNSServiceErr_ServiceNotRunning
1/23/15 2:21:03.128 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:03.186 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:03.313 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
1/23/15 2:21:03.374 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:03.478 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
1/23/15 2:21:03.523 PM Slack[16482]: dnssd_clientstub ConnectToServer: connect()-> No of tries: 2

Protoaculous 1.9.0-1.7.2.0 Minified

What
This is an update to a post from 2011: Protoaculous 1.9.0 Minified. In the older post, I published Protoaculous 1.9.0 which was based on Scriptaculous 1.9.0 and PrototypeJS 1.7.0.

Updates

  1. A newer version of PrototypeJS is out: 1.7.2. So I’ve updated Protoaculous to use the newer version.
  2. Switched away from YUI Compressor to Google Closure Compiler since it produces more compressed files.
  3. I was previously using Scriptaculous version number as Protoaculous’ version number. This type of versioning is flawed because it doesn’t work when only PrototypeJS gets updated. So I’m now using Scriptaculous_version-Prototype_version.
  4. I’ve published the script I use to create new versions of Protoaculous on Github: Protoaculous Bundler.

Direct links

  • https://raw.githubusercontent.com/inderpreet99/protoaculous-bundler/master/dist/protoaculous.1.9.0-1.7.2.0.js
  • https://raw.githubusercontent.com/inderpreet99/protoaculous-bundler/master/dist/protoaculous.1.9.0-1.7.2.0.min.js

Warnings
I have not tested how well the combination of the two scripts perform. Please use caution and testing before using it in a production environment. Although previous versions have performed well.

Issues
While generating protoaculous using Google Closure Compiler, I noticed the following issues, which should probably be fixed by the PrototypeJS team:

Generate protoaculous.1.9.0-1.7.2.0.js and protoaculous.1.9.0-1.7.2.0.min.js in dist...
dist\protoaculous.1.9.0-1.7.2.0.js:4619: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
  arr[ preferredDoc.childNodes.length ].nodeType;
  ^

dist\protoaculous.1.9.0-1.7.2.0.js:5602: WARNING - Suspicious code. This code lacks side-effects. Is there a bug?
  if ( elem.parentNode ) {
  ^

dist\protoaculous.1.9.0-1.7.2.0.js:5603: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
  elem.parentNode.selectedIndex;
  ^

0 error(s), 3 warning(s)

Size information

Size of Prototype.js + Scriptaculous = 314K
Size of Protoaculous.js Minified = 166K

Suggestions

I would suggest:

  1. Turning on gzip functionality (mod_deflate on Apache) for all html and js/css/etc assets in your webserver to get filesizes even lower. This would ensure your users get the files even faster.
  2. Adding very long expiration dates (like years) through your webserver on js/css/etc assets. This would ensure your users do not have to download the files again and again. Since the files are versioned, there should not be a problem in cache busting on newer updates.

 

EXT4 repair on Mac OSX

My NAS WD drive recently became corrupt. It had trouble saving large files and running them. My router constantly complained about not being able to properly run Samba/swap on it.

Not having a Linux OS handy, I had a tall task to repair an EXT4 filesystem on Mac OSX 10.10.

I first tried the open source solutions: fuse-ext2, osxfuse, and ext2fuse (read-only). While these tools work great in allowing access to ext4. They do not include any disk repair tools. e2fsprogs from Homebrew also does not include the fsck utilities.

I also tried using the commercial ExtFS by Paragon. It integrates directly with Disk Utility and is able to verify/check the disk for errors. While it reported the errors properly, it had trouble repairing the filesystem and reported my ext4 partition as ext3. It failed to repair reporting: “Error: Disk Utility can’t repair this disk. Back up as many of your files as possible, reformat the disk, and restore your backed-up files.” Also, ExtFS was very buggy as in it consistently froze the System Preferences and Finder (while ejecting and mounting).

Finally, I installed VirtualBox with an Ubuntu VM and added the USB drive from settings. I had to umount the drive from inside Ubuntu and running fsck -y was a breeze. Now ExtFS by Paragon also reports that the Disk is good.