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.

Releasing DholCutz Bhangra Radio version 2 for Android

After many bad reviews, I finally decided to update DholCutz Bhangra Radio for Android, so version 2 is here. It has the following updates:

  1. Harder, Better, Faster, Stronger
  2. AAC+ Higher sound quality!!!
  3. Background vi hojanda mitra!
  4. Instant song title updates
  5. Links to Requests and Chat
  6. Ganeya Di Agg!

Android Play Store App link: https://play.google.com/store/apps/details?id=com.inderpreetsingh.dcr&hl=en

Screenshot:
Main Screen

mb_strrchr in php 5.1 for compatibility

I needed php’s mb_strrchr function, which is only in php 5.2+. However, my workplace is stuck in php 5.1 and cannot upgrade to php 5.2.

I decided to write a forwards-compatible mb_strrchr() that worked in php 5.1 at least. Please test thoroughly before using. It seemed to work great for the cases I needed it for:

// php 5.1 compat
if( !function_exists('mb_strrchr') ) {
	function mb_strrchr( $haystack, $needle, $part = false, $encoding = '' ) {
		
		$pos = mb_strrpos( $haystack, $needle, $encoding );
		if( $pos === false ) return false;
		
		if( $part === true ) {
			return mb_strcut( $haystack, 0, $pos, $encoding );
		} else {
			return mb_strcut( $haystack, $pos, mb_strlen($haystack), $encoding );
		}
	}
}

VirtualBox Images CentOS keyboard settings problem

I was using readymade CentOS images for VirtualBox from VirtualBoxes CentOS images. I noticed that some of the images come with weird keyboard settings, such that you can’t use the pipe (passing information from command to command), dash (for command parameters), @ (email sign), etc keys. In other words, when you try to type these keys, other keys would appears and vice versa. All of these keys are crucial to running any commands on the CentOS server.

The problem is that the VirtualBox image stores the keyboard setting that was used when it was created. Since this server image was built in Italy, and I am located in the US, there were obviously key differences.

The obvious solution is to change it to your preferred keyboard layout. There are 2 ways of doing it:

  1. Easier way: Install system-config-keyboard through yum. The caveat is this will install 75+ other bloat packages that you probably don’t need. However the command system-config-keyboard would configure your keyboard for you.
    yum install system-config-keyboard
  2. Advanced way: Use
    loadkeys

    command to change the keys temporarily and then make a change to

    /etc/sysconfig/keyboard

    to make a permanent change (after restart).

    loadkeys us # or your own locale
    vim /etc/sysconfig/keyboard # replace KEYTABLE value to your locale