The world is my backyard.
Random header image... Refresh for more!

Posts from — June 2008

Jukebox in a single line

If you are like me, who starts starts iTunes with default library and realize you have heard the same song 8 times in the last week, here are two one-line-Jukebox scripts for you. The scripts randomly choose and play songs right from the command line.

Before using the script make sure you have an mp3 player installed. I have installed lightweight mpg123, however you can use any player. I would recommend mplayer for Linux.

While running the scripts, I pass ~/Music folder argument. Change the path to point to folder where you store your mp3s.

First one is in Ruby, and shamelessly inspired by Kevin Baird’s book.

Open a text editor and save this script. I named it shuffle_play.rb. (You need to have ruby installed on your system. Installed on Leopard and most Linux distributions by default.)

#!/usr/bin/env ruby -w
ARGV.sort_by{ rand }.each {|file| system("mpg123 \"#{file}\"")}

To run the jukebox

ruby shuffle_play.rb ~/Music/*.mp3

For the second, I ported above script to bash, which is even more simple and can run on any Linux or OS X. Lets name the script shuffle_play_shell.sh

#!/usr/bin/env bash
n=0;for songs in "$@" ; do song_array[n]=$songs ;((n++)) ; done; for ((i=0;i<$n;i+=1));do number=$RANDOM; let "number %= $n"; `mpg123 "${song_array[number]}"`; done

To run the jukebox

source shuffle_play_shell.sh ~/Music/*.mp3

Update: The second one is not completely random. It will choose n random songs out of n songs. However it does not checks if each song is played at-least once, thus chances of songs getting repeated. Any suggestions?

June 28, 2008   No Comments

Installing command line MP3 player

Mpg 123 Player

mpg123 is a real time MPEG 1.0/2.0/2.5 audio player for layers 1,2 and 3.

I was playing with Ruby scripts and needed a command line mp3 player which was not a resource hog.

Steps I took for my OS X (Should work on Linux/Unix box):

Download the latest version from the website.

Untar the archive

tar -xvf mpg123-1.4.3.tar

Compile and install the player

./configure --prefix=/usr/local/mpg123
make
make install

Add the path to .bash_profile

echo 'export PATH=/usr/local/mpg123/bin:$PATH' >> ~/.bash_profile

Load the new path

source ~/.bash_profile

Enjoy playing music from command-line!

 mpg123 ~/Music/Bagho_Bagh_Gippy_Grewal.mp3

June 28, 2008   2 Comments

The coward behind the curtain

Stupid-Comment

There is two types of ignorance and stupidity.

  • Ignorance due to virtue – In people who are not exposed to education and thus information. Such ignorance is not just to be pitied upon, but one should try to help them see the world they have not been exposed to.
  • Acquired ignorance and developed stupidity – You find this often in highly educated but religiously, regionally and racially unbalanced, un-secular and aligned top brass. And like many other fields of hypocrisy, we Indians have an edge over it.

My simple blog post on Firefox 3 in Punjabi attracted an example of the second kind.

A comment to the post was this:

You son of a ************(Here he introduced his mother’s name)……..still u ppl r not indians….u still think of a separate state..khalistan…….i never heard any gujuu saying that we have firefox in gujarati…..we ppl gave u shelter and instead of showing gratitude , u r showing attitude……In dia is a land of many religions, states, ppl…so let it be….ppl like u always try to break it…ur community is not bad, even u had some great ppl..and i respect them but because of ppl like u whole community has to suffer…Wat u know abt hindi..hindi is one of the most ancient language and scientific too…wat punjabi is -its a weird form of hindi

Now I have tried to get my head around what was this guy is offended at? Not having Firefox in Hindi or not being born to a Punjabi father?

And guess what? And who is this guy? One of my very known ones from my University’s Pharmacy department. He used a wrong email address while commenting on my blog, used a handle name “Manoj Mishra”.

How stupid? Stupid enough to not know that any website you visit, you leave digital footprints:). A thief who can’t hide! A “Patriotic” Indian, who could not even face his own words!!! What a shame! I’ll allow him his shame and not reveal his real identity here.

[Read more →]

June 23, 2008   1 Comment

Firefox 3 in Punjabi released

Due to the hard work of Punjabi localization team, Firefox 3 includes the release in Punjabi.

What is interesting is that only Indic languages that were included in the Firefox 3 Official release were Gujarati and Punjabi. Even Hindi, the largest spoken language in India, could not make it due to lack of motivated volunteers.

[Read more →]

June 22, 2008   2 Comments

Started with hundred pushup challenge

I’m pretty regular at gym, however I do not like to do much weights.

pushups

I came across hundredpushups.com and found the idea of reaching 100 pushups in 6 weeks pretty cool. At this point I can reach a max of 25 pushups in a go.

To keep a track and also to keep myself motivated, I have created a google spreadsheet to track my progress, which generates a chart in the sidebar. Finished the first day task easily.

I also checked few videos before starting, just to make sure I was doing the pushups properly.

June 22, 2008   No Comments

AjitJalandhar.com now proudly serves you spyware!

Beware! AjitJalandhar.com, one of the earliest Punjabi newspapers online, (and a mouth-piece of a certain political party – but thats a different story) is now serving not just politically biased news, but some freshly baked spyware forcibly to your PC!

Ajit spy Ware

ajit-spyware-download

[Read more →]

June 20, 2008   11 Comments

Synchronizing Nokia 6086

I have a cranky old Nokia 6086. And I’m waiting for Android, just because of its open source license.

Love this phone(or more appropriately “used to love”), because it used to do task “rarest in its times”.

I could use any public WiFi hotspots (My Office and my home included) and route my calls through the internet, and costing me guess what – $0 (To be precise I paid $10 for TMobile@Home service.) So I could talk non-stop to all the hot chicks!! Lol!

However since yesterday it started to show signs of aging.

Long story short, I was searching for a synchronizer using bluetooth. Nokia only makes PC Suite. I have a Mac. And Mac has iSync which is not compatible with Nokia 6086.

6086-not-compatible

[Read more →]

June 15, 2008   No Comments

New to Rails and using Agile book second version?

With Ruby on Rails 2.1 version already here, I have seen a lot of new comers to Rails using second version Agile book asking this question again and again:

Why doesn’t my depot application work?

Well because it is based on version 1.2.3.

Here is a simple way to get it working.

[Read more →]

June 10, 2008   2 Comments

Back home Mississippi

As I was checking out, I met Chad Fowler, the author of “My Job went to India“. As I said hello, he asked “Are you a Punjabi?” :)

Chad Fowler

So the conference came to an end.

Portland Airport

I liked the city, the people, the weather.

Paradise Cafe

And the food. (Unlike Mississippi, where everything has to be meat, or creamy, or barbecued:)

Taking off

From the plane, I took a picture of Mt. Hood, and I gave it a promise – A promise to come back to see it.

Mt Hood

There is lot of homework to do. I’m excited. And I have got a reality check. And I’m excited:)

June 2, 2008   No Comments

Last day at the conference

Today was the last day of Rails Conference. I attended a session on active record and another on what not to do in rails.

Last day of Conference

The main event of the day was keynotes by the core team. DHH got standing ovation from the crowd before he left early to catch his plane.

Core Keynote

This has been one of the best conferences I have been to. Inspiring, knowledgeable and mind opening. Mingling with so many hackers and enterpreneurs was fun and will act as a reality check on where I am heading and should be heading.

Shabbir Merchant From Pune

Later in the evening, Shabbir and I both had rest of the day to check the city. We went to eat at an Indian place, roamed around the city and checked out the largest bookstore in the world. Found a complete section on each – India, Punjab and Sikhism.

Downtown Portland

June 1, 2008   No Comments