Recover your iPod playlist within seconds

I had to leave for Goa the other day and I was packing my bare essentials when I came across my age old forgotten iPod. Finding it out of blue was a bliss and I decided to take it along. I put it on charge and it was ready to rock.

2015-08-30I never realized what wonder old playlists can do. Listening to those old tracks I felt as if I was transported back to those good old carefree college days. After returning from Goa I decided to export those tracks to my computer, however there was an issue. We all know for some reason Apple renames music files and rearrange them in random folders. This makes it impossible to figure out which file corresponds which track.

Here take a look:

ipod files list

These are all random filenames. However to my relief these files were not encrypted and their ID3 tags were still intact. That meant all I needed to do was rename these files and I was good to go.

However given the size of my playlist (6.5 GB) there was no option to do this manually. So I wrote a little script that could help me out.


My script goes through these files, collecting their ID3 tags, maintaining a hash and finally copying these files over user provided destination to respective folders based on album name and the file itself is renamed on track title. Running the script restored back my playlist within 105 seconds. Here’s the benchmark:

0.160000 7.470000 7.630000 (105.228952)

And this is how my playlist looks now on my file system:

Selection_007 Selection_008

Here is the source code:

Feel free to star, fork, follow or contribute on GitHub. :)

plugin, wordpress

Announcing Release of “The Video Popup” plugin at WordPress Repository

My plugin “The Video Popup” got approved and is now available for download in wordpress repository. Its a light-weight plugin that generates a YouTube video popup when a page is scrolled to the bottom. You can check it out here:

The next version of the plugin is expected to have:

  • support for vimeo
  • custom point of trigger
  • overlay video popup

Feel free to suggest more features in comments below or rate the plugin in the repository. ;)

Project Euler, ruby

Project Euler in Ruby

I recently started solving project Euler. I am using Ruby to solve these problems. My aim is to get results in optimum time. I try refraining myself from using brute force however I have used them couple of places where the sample data was limited and it did not make any considerable difference in performance.


In the process I also tried implementing a few mathematical algorithms like – Fermat’s Factorization and Quadratic Sieve wherever necessary. Its a great experience solving these problems. Given the nature of these problems it demands you to be intelligent in your approach. Many times its quite tempting to use brute force and I did that too (ended up restarting my crashed laptop).

And boy! its fascinatingly addictive. I’ve been digging wiki for countless algorithms, analyzing their pros and cons and selecting them accordingly for my solution – and not to mention coding them.

As Project Euler discourages posting answers online, I won’t be posting answers however I will be sharing my solutions. In the end of each solution I have posted Ruby Benchmark score calculated on my system.

Here’s the link to my GitHub repository:

Its a work in progress, so feel free to fork it, star it and collaborate to make it better.

Cheers! :)


The Video Pop-up Plugin: WordPress

This plugin is still not released. You can access the source code here:

Its been long since I originally wrote this plugin, however I think now it would be nice to get it out in the wordpress repository and let it live its life!

This post serves as the formal introduction to the plugin. Let’s start from the basics.

What do you mean by video pop-ups?
A Pop-up launches when you visit certain websites. Their main aim is to try to catch the visitors attention and to bring something to their notice. As the plugin name suggests, it will help you pop-up videos on your site.

Currently the plugin supports only youtube videos. I hope to extent support for vimeo soon by the next version upgrade.

When is the pop-up triggered?
The pop-up is triggered when the user scrolls to the bottom of the page (footer). This makes sure user has least distractions on the site, only when he reaches to the end, he gets the pop-up. This makes its less annoying for visitors. However future version may provide customization over trigger.

How to setup the plugin?
Once you install the plugin to your site, you need to activate it. After the plugin is activated, you can find ‘Video Popup’  settings in your dashboard left pane.


Click on the ‘Video Popup’ setting button to get the settings page. As below:


By default the height is 325px and width is 420px. You can however define your own custom dimensions.

Once you save changes, the popup gets activated.


Users have the option of minimizing/maximizing the video.


Getting Started With Google Web Starter Kit

Yesterday (Friday 20 Jun 2014) Google released its web starter kit. Here’s the formal overview of the project (GitHub):

“Web Starter Kit is a starting point for multi-screen web development. It encompasses opinionated recommendations on boilerplate and tooling for building an experience that works great across multiple devices. We help you stay productive and aligned with the best practices outlined in Google’s Web Fundamentals.”

The first thing that comes to one’s mind is – ‘Is this a bootstrap or foundation alternative?‘.

As per the developers the web starter kit is a very basic boilerplate to get started on web development and it is not developed to compete with bootstrap, foundation or any other such framework.

I tried to develop a basic webpage using the web starter kit. The first thing you realize is its very light weight. Its built on node, ruby, sass and gulp. It was my first experience with gulp and have to say I was impressed. The way it organizes the website assets and helps in testing with various browsers is amazing. It even takes care of minifying your css and js files.

Getting started

Getting Web Starter Kit

Get the framework directly by cloning it from github.

git clone

The working directory will be: web-starter-kit/app

Installing Dependencies

As mentioned above, web starter kit is built on node, ruby, sass and gulp, which means you need to have these on your system before kicking-off with the starter kit.

You can check the same with following commands:

node -v
ruby -v
sass -node -v
gulp -v

If these commands respond back correctly, you are good to go, else install them as follows:


sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Ruby (using rvm)

sudo apt-get install curl
\curl -L | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvm install ruby
rvm use ruby --default
rvm rubygems current


sudo gem install sass


sudo npm install --global gulp

This will install Gulp globally. Next, install the local dependencies Web Starter Kit requires:

cd web-starter-kit
sudo npm install

Finally to build the project, go to web-starter-kit/app and run:


That’s it! We are good to go now.

Starting the server:

Start the server by typing:

gulp serve

This will load you application on the browser. With gulp serve running, start editing your application in a different tab and observe the changes instantly in the browser.

Here is the demo webpage I made using the web-starter kit. Clone it to get basic idea of how it works. Fork to contribute building a better demo app. :)


Taking localhost To Internet

There can be many situations where you may want to get your localhost to internet. I was working on a project recently that involved using stripe. When working with tools like stripe that involves money transfers you need to listen to all the events generated in the process. Solution to that is a webhook. However the problem is, when in development, webhooks cannot connect (POST data) to your localhost. Therefore you need a way to take your localhost (development environment) to the internet.

Other such instance can be when you are designing a website for some remote client. You have completed all the development in your localhost, but before hosting the site your client needs to review it. You again need to somehow take your localhost to internet so that your client who is sitting in the other part of the world can review it.  There can be many such occasions like these.

There are several tools available for this purpose. Some of the prominent ones are: ngrok, PageKite and ProxyLocal. I however use ngrok, so this post will explain only about using ngrok in the simplest possible way.

ngrok is simple to use and hardly takes a minute to get started. It comes both as a free as well as paid service, we however will focus only on the free service.  To get started, you need to download the binary file from here. As the official website says, “a single binary with zero run-time dependencies for any major platform” and that’s all you need to get started.

Download the file to any preferred location and unzip it. On unziping you will get a binary file named ‘ngrok’ and that’s it!

Now to get your localhost online simply run the file with the desired port number. In most of the cases the port number will be 80 (default HTTP port).  In such case run:

./ngrok 80

And done! Your localhost is now on the internet. The above command will output something like this:



The address mentioned as Forwarding is the one you can use to access the localhost on the internet. In this case:

Similary say you are working on a rails project. As webrick’s default port is 3000, you will run:

./ngrok 3000

The output will be like:

ngrok 3000


Also you may notice, ngrok provides a web interface too that can be accessed on address:

Stop the tunneling by: Ctrl + c

Hope this helps you! :)


Solving WordPress Pretty Permalink 404 Error

While working on a project recently I came across a weird error. I was examining the wordpress taxonomy tables for slugs when I realized pretty permalink was not working for my localhost wordpress setup. On making a few google searches I realized people face this quite often and yet I had to google and experiment for about 30 more minutes before solving the issue, and therefore I decided to write this post.


First thing to check:

When WordPress creates custom permalinks or slugs, it overwrites the server’s defaults setups in its own .htaccess file.  For those who don’t know what .htaccess file is, here’s a quick definition (wikipedia):

“A .htaccess (hypertext access) file is a directory-level configuration file supported by several web servers, that allows for decentralized management of web server configuration. They are placed inside the web tree, and are able to override a subset of the server’s global configuration for the directory that they are in, and all sub-directories.”

In simple words you describe your site specific server configurations in this file. As wordpress does most of such technical things all by itself, you should ideally not be worried about what goes in this file. However there may be situations when wordpress is not able to create/modify this file due to file permission issues. Make sure this is not the case.

Go to the wordpress folder. In my setup (debian/apache2) I go: /var/www/wordpress

To list all file permission do:

ls -al

Incase the file is not present. create a .htaccess file using

touch .htaccess

Now make sure wordpress has all the authority to modify it. If you are in your local system, you can safely do:

sudo chmod 777 .htaccess

To make sure this worked, re-enable to pretty permalinks from wordpress admin panel, save the settings and open the .htaccess file. It should contain something like;

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Meaning wordpress is able to modify it. Check if your issue is resolved.


Step Two

If 404 is still haunting your posts it means the problem is beyond the scope of your wordpress directory. We now need to look for master server configurations. You can find them in your httpd.conf file.simpson404

Note:  httpd.conf is empty (or nonexistent) in some distributions.

That was the case with me, so we can edit apache2.conf instead. Typically you can find this file here:


In the conf file, look for:

<Directory /var/www/>
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted

As you can see the AllowOverride option is set to ‘None’, therefore it is blocking our .htaccess file to override the server configuration for our particular site. Replace ‘None’ with ‘All’ to fix this. conf file should now look like:

<Directory /var/www/>
   Options Indexes FollowSymLinks
   AllowOverride All
   Require all granted

Now restart the apache server by:

sudo service apache2 restart

Check the links in the browser. As we just edited the main server config file, our links should start working.


Still No Luck?

There maybe be possibility that your issue is still not solved. One explanation can be that this master configuration is getting overridden somewhere. Check the ‘sites-available folder’ inside apache2. Here: /etc/apache2/sites-available

In 000-default.conf make the same changes as above i.e. setting AllowOverride All

Restart the server again and check the links in the browser.

Incase its not working yet, we come to the last thing that can go wrong. mod_rewrite is yet not enabled. To enable mod_rewrite for Apache do:

sudo a2enmod rewrite

sudo service apache2 restart

Check the links and they got to be frigging working now!!