December 23, 2007

Encoding iPod Video

You never know how many times I tried to encode videos for my iPod and could not quite figure out how things work. Oh yes, I know there are a lot of tools available for Windows (although most of them are commercial software). On Linux, I was pretty sure it was possible to encode and transfer movies to my video iPod. But oh man, it was hard to actually figure out the tools to use and the options I had to choose for getting an iPod-friendly video. Several times I tried installing ffmpeg, building it from source, installing other libraries that ffmpeg depends on, blindly following directions from forums, etc. But the result was the same: I could not invoke ffmpeg successfully to get an iPod-friendly video. It always complained about some incorrect command-line option, or missing component, or something else which I couldn't fix. Today I finally found the tool that can convert give me iPod videos! I have been using Avidemux for quite some time to do some video editing, without ever realising that Avidemux can write MP4 files that iPods like. Here is the configuration for output video:
  • Choose Mpeg4 (lavc) as the video codec.
  • Click Filters button and change the video size to 320x240. If your source video is not compatible with this size, resizing will result in skew/stretch of the video. You may add some black borders to make the size, a multiple of 320x240. For example, I added 96 pixels on top and bottom to make a 640x288 video to 640x480. Then resizing it to 320x240 will not change the aspect ratio of the video.
  • Choose FAAC as the audio codec. Click on Filters and choose Stereo for Mixer option.
  • You can change audio bitrate by clicking on Configure button.
  • Choose MP4 as the video format.
And that's about it. Choose Save > Save Video... from File menu to get your video :-) Edit: Added the mention of Stereo type for audio. Otherwise iPod won't play the audio if your source audio has more than 2 channels. Also removed the step of setting video bitrate, which is not quite necessary.

December 17, 2007

GUI for MSify

I just added a graphical interface to my Sify Broadband client for Linux. Try it out and let me know your comments. (Start at http://code.google.com/p/msify/wiki/GettingStarted). You can still use the earlier command-line based interface if you like to stick to it.

December 11, 2007

Arjunaru Villu

Tonight, while coming back from office, my iPod played Arjunaru Villu song from Gilli. That's one of the songs that I love for a few reasons and hate for a few other reasons. I love it because it reminds me of the experience I had in the movie hall when I was watching it. We planned to go to that movie about an hour before the show time. My mom never lets us go for a night show cinema. But I was in Madurai then, so I didn't have to get my parents' permission to go to the movie. We went to the theater by bus. (oh, I love those city buses!) Since it was a Dharani's movie, I didn't expect much from the movie. The first half of the movie was very good. Generally I don't like songs in movies, except for a few songs. I really enjoyed Arjunaru Villu song in the movie. After the interval, maybe because my expectation had grown then, the movie felt crappy. Speaking of that song, I like it because of Vidya Sagar's work on it. The tune, choice of the singer, composition, everything just fits together beautifully. But the lyrics is awful. I especially hate the lines எதிரியைக் கொல்லு இமயத்தை வெல்லு and ஏறு முன்னேறு, இது கரையே இல்லாக் காட்டாறு. (The latter one seems completely illogical -- how can there be a river without banks? Even if such a river exists, we won't call it a river.) Besides all that, I love to drive with that song playing. It's a wonderful experience. Thanks Vidya Sagar!

Spam fighting

I know, using hacks is a Bad Thing. But sometimes hack is required. When no clean solution exists, like every other programmer, I use some hacks at least to remain sane. For instance, JobsAhead keeps annoying me all the time with their spam. There is an "unsubscribe" link in the spams they send, but god only knows where on their UI you have to click to get rid of their spam. So I just changed the contact email in my JobsAhead profile to nosuchidiotexists@yahoo.gmail.com. I expect this will block one source of spam. But you know about the job consultants here? They just don't care who you are, what crap (so-called immediate opening at an MNC) they send to you, etc. All they have is a huge pile of email addresses, and they keep spamming everyone all the time. I have a Gmail filter[*] that removes all those crap from my inbox. OK, so here's my advice to you, if you are serious about your email: do not ever let these job consultants know your email address. They will spam you to death. If you want to use any job search service, create a new email address and use that. As soon as your job search is over, you can get rid of that email address without worrying about our beloved job consultants spamming you. TTFN * This is my Gmail filter, if you are interested: Filter criteria: subject:(opening OR openings OR immediate OR interview OR interviews OR requirement OR requirements OR walk-in OR "walk in" OR walkin OR (opportunity job) OR "urgent position" OR "urgent positions") Actions: Apply label "jobspam?" and skip inbox.

November 29, 2007

When I bought my Palm Treo 650 about a year and a half ago, I was sooo glad that I bought it for a really cheap price. It was my first international trip. I was in our Silicon Valley office for the new-joinee training. I don't know if I learned enough stuff during the trip; but I definitely bought quite a lot of stuff. In addition to buying electronics for me, I also bought plenty of shirts, a lot of stuff from Google Store for me, my friends, Pascal, etc. Only when I had to pack all the stuff I realized how much stuff I had bought. After starting to use the Treo, I started liking it more and more. It's no-nonsense UI, ease of use, build quality, battery life, quality of the touchscreen, integration with my beloved Linux computer made me happy. Those who believe "reality is far from ideal" are correct. The phone has its own glitches. But you know, it was far better than the Nokia 7710 I was using. A few months back I got tired of big phones. Wanted to get a phone which I can use to make calls, with no fancy features. I settled for a Nokia 5200, which is a pretty low-end phone with Bluetooth support. I could not use it for more than a month. Nokia's UI made me grumpy. Even when I fondly used my Nokia 3120 and had great love for Nokia phones, I hated their UI. (quick question: what is the average number of keypresses you need, to do anything on a Nokia phone?) And a few other minor usability issues. So I switched back to my Treo. Last week I was bitten seriously by Treo's infamous "ghost jack" problem. I decided to change my phone and started looking for a good phone. I didn't want to buy some really good phones for personal reasons, including iPhone (no thrid-party apps), HTC Touch or S710 (yucky Windoze mobile OS). And I already have an aversion towards Motorola's and Nokia's. Syncing with a Linux computer is something that is not support by almost all the phones. So decision made: be happy with the Treo until some superstar company releases an Android phone.

November 25, 2007

MSify

<shameless plug> After living on my laptop for about a year, my Sify Broadband client has found a new home in Google Code. For the lack of a better name, I am just calling it MSify, and it's available at http://code.google.com/p/msify. If you use Sify Broadband on a Linux computer, try it out. Feedback, bug reports, feature requests are always welcome. </shameless plug>

October 08, 2007

Suddenly I have a question. About me. Am I a hypocrite? May be. Or may be not. I brag all the time that I respect others. Well, until now I believed that I had respect for others. Now, I am not very sure if I can still say the same thing about me. I use all kind of swear words. Most of the times I don't mean those words when I use them. But, I really do get pissed off when I see some incompetently developed software (which I have to use for some reason). In several posts of this blog, I have complained that some random software developer did something stupid to make me unhappy. One of my colleagues asked me a few days back: "Is there any software that you really like?" when I was cursing Adobe Reader for it's stupid behaviour on the print dialogue. I hate Hyderabad mainly because all the time I have something to complain about the people of Hyderabad. What do this all mean? Do I have no respect for people whom I don't see face-to-face? Am I a hypocrite when I say "I have respect for other people"? Possibly. If you have spent some time with me and you think you have something to say about me/this post, please write back. Oh yes, I encourage you to be brutally honest.

September 29, 2007

KTorrent Troubleshooting

Some torrent files may confuse KTorrent and it may go into an infinite loop consuming all CPU cycles but essentially doing nothing. I had a similar experience just a few hours ago. How did I solve it? I used the command ktorrent --debug to see what it does. Reading the debug output helped me find the directory* where KTorrent stores the current torrent files' information. I just removed the directory of the torrent that was causing trouble. Voila, KTorrent is back again to normal! [*] $HOME/.kde/share/apps/ktorrent/tor*

September 27, 2007

Have I become allergic to governments?

Crap! What are these people doing? A few months ago I had to pay 1000 rupees for all my flight tickets in the name of tax. Air Deccan sold tickets for 150 rupees onwards and the government took a whopping 1000 rupees. Now the tax is increased to 1500 rupees. I come in the "rich people" category of the Indian government and I don't have any of that "IT-exemptible savings" so I end up paying 30% of my salary in the name of Income Tax. Whatever I spend the remaining 70% for, I have to pay taxes (again). For petrol I buy, more than 70% of the price is nothing but tax. Wherever I go I pay 12.5% VAT. All this for what? For these idiots to stop me on the road and make me bribe them for not wearing a helmet. And, these laws are for the benefit of me (i.e. the people). I don't understand one thing -- who are they to decide what's good for me and what's not?

August 16, 2007

Sify Broadband Client for Linux

I wrote about my home-grown Sify Broadband client some time ago. As with any program it needed some tweaks. Now it's pretty much stable. This is how now I connect to the Internet.
  • Configuring the network: My laptop has to use a DHCP-based network in my office. Sify requires that I use a static IP address. I have added a virtual network interface to the computer by adding these lines to my /etc/network/interfaces file:
    iface sify inet static
    address 10.15.66.107
    netmask 255.255.255.0
    gateway 10.15.66.1
    dns-nameservers 202.144.10.50 202.144.13.50
    When I am at home, I activate this network settings on eth0 by running: $ sudo ifdown eth0 $ sudo ifup eth0=sify
  • Signing into Sify network: $ sify.py i
  • Signing out of Sify: $ sify.py o
Requirements For this script to work, you must have the following installed:
  • Python 2.4
  • BeautifulSoup (Python XML parser library)
Download and Install ** Update: This project is now hosted on Google Code. See http://code.google.com/p/msify/wiki/GettingStarted for more information and to download the latest version. ** Download the zip archive at http://www.megaupload.com/?d=QR5TC7DK. Extract the contents of the archive into a local directory in your computer. Edit the .sify file and specify your username, password, IP address etc. Then run sify.py to login or logout. Fine Print
  • I developed and tested this on a Kubuntu Dapper machine. It works fine for my usage; but I cannot guarantee that this will work for you. I don't provide any warranty of any sort.
  • This script is released under GPL V2. Feel free to change and/or redistribute.

August 13, 2007

Don't attach those Windoze Media format files, puhlease...

<rant> It's been more than two and a half years since YouTube was launched. It's the most famous video sharing service on the Internet today. I know a lot of people know about it. But the problem is they don't use it. Very often I get emails with a zip files attached to it. The zip file contains one single WMV file. Instead of taking all the pain to zip a WMV file (which results in almost no file size difference; but a hell lot of annoyance), if at all they upload it to YouTube or some other fancy video sharing program they like, it would be a pleasant experience for us to watch it. </rant>

July 14, 2007

Thanks Chinmayi

You wake up in the morning and switch on your computer. You find that there are 95 scraps in your Orkut profile. Many of them are from strangers whom you have never seen and quite possibly won't ever see in your life. How would you respond to those scraps? To be honest, I would just delete my Orkut profile and get away from there. But Chinmayi, the singer, responds to most of scraps (or maybe all of them?). Yesterday I just found her profile in Orkut, and I couldn't resist my want to say a "Hi" to her. I don't know anything about music; I just listen to songs as a not-so-serious hobby. I like Chinmayi because of her voice. After reading her blog and seeing her on Vijay TV, I really started liking her personality. I could even say that I am a fan of her. When I wrote a scrap on her Orkut scrapbook I didn't expect her to respond to my scrap. I know she is very busy. If my assumption is right, Carnatic music practitioners like her do practice daily for at least a couple hours. All the weekends she has concerts. As she is working in the movie industry, most definitely she will have to meet with many important people. Surprisingly, I got a response from her! I was really happy to see her scrap on my scrapbook. When I searched for my scrap in her scrapbook I got the next surprise: 95 new scraps have been written on her scrapbook in one single day! And, she is taking time to respond to my scrap. Most definitely she doesn't know me, I am not ever going to meet her at all in my life. But still she takes the time to acknowledge my message. She has about three blogs and a web site. In addition to these many scraps, she would get comments for her blogs, feedback for her web site, and emails sent directly to her mailbox. All I could think of is that she is a good woman. I want to thank her for the respect she has shown to my message. But this time I just say it here, in my blog -- because I don't want to spam her again. Thanks Chinmayi!

July 04, 2007

Code Duplication

You might have heard people talking about not duplicating code so that it becomes easy to maintain. Back those days, I didn't know all these and used to make a hell lot of mistakes while programming. By the word mistake, I mean doing something that makes developing and maintaining software harder than it ought to be. Of course, that helped me learn a lot of principles. The first thing I learned from my mistakes is not to duplicate code/ideas. Since I was bit by duplicated code very often, I try my best to reduce duplication as much as possible. In this post I am giving a few examples to show how I try to avoid duplication. Obvious Duplication The first pattern I recognised in my code was something like the following.
if exam.mark >= 35:
    exam.result = 'pass'
    logging.debug('Setting result to pass.')
    return 'pass'
else:
    exam.result = 'fail'
    logging.debug('Setting result to fail.')
    return 'fail'
Obviously this code is duplicating ideas, so must be refactored. How will you refactor this to take away the duplication? I will write it this way:
if exam.mark >= 35:
    exam.result = 'pass'
else:
    exam.result = 'fail'
logging.debug('Setting result to ' + exam.result)
return exam.result
(To be more precise, I will also replace the literals 35, 'pass', and 'fail' with appropriately named constant variables.) More Subtle Cases This is (part of) a PyUnit test case for an imaginary function double, that takes a number and multiplies it by 2.
def testDouble(self):
    inp = 5
    expected = inp * 2
    actual = double(inp)
    self.assertEqual(expected, actual)
Here, I have used the variable inp to avoid having to duplicate the test input I am passing to double. As another example, see this code that assigns a grade to a student based on the mark they have scored.
if mark < 35:
    grade = 'N/A'
elif mark >= 35 and mark < 50:
    grade = 'D'
elif mark >= 50 and mark < 70:
    grade = 'C'
elif mark >= 70 and mark < 90:
    grade = 'B'
else:
    grade = 'A'
I would rewrite this code like this to avoid duplication of the boundary values (although this is a very small duplication).
if mark < 35:
    grade = 'N/A'
elif mark < 50:
    grade = 'D'
elif mark < 70:
    grade = 'C'
elif mark < 90:
    grade = 'B'
else:
    grade = 'A'
Tell me about the ways you follow to make your code more maintainable.

July 01, 2007

Web Development 101

They say a picture is worth 1000 words. So a video should worth more than a picture. Definitely a hands on experience is worth much more than a video. All you starting web developers: here is your most important lesson. I'll tell you what I did to learn this lesson. If you follow what I did, hopefully you will also learn :-) Steps to follow:
  1. Think of a very good Tamil song that you don't have right now, but would love to add it to your music collection.
  2. Google for it and most likely you will get a link for that song in Raaga.com. (If not pick another song; in this particular exercise, we are gonna learn from Raaga.com.)
  3. Click on the link in Google results and if you are lucky, you can listen to the song in their site. If you run any non-Windoze OS you're doomed.
  4. Then you decide: alright, I really like this song and I'm gonna download. Click on "Download" button. You will be politely informed (with a JavaScript alert) that you got to log in if you want to download.
  5. So, you click on Register link. And you know the rest: I am too lazy to type all that now.
  6. You will have to activate your account, this, that, and all other bullshit.
  7. After you have downloaded that song, sit back and think "do I want my site to be as brain-damaged as Raaga.com?"
If you are really unfortunate (like me) you will end up visiting their site often and curse them every time. See my shopping cart now: I have no idea how item 2 and 3 differ. Worse, I cannot find that out at all. That's all for now. Now you're free to dream about your cool web site.

June 14, 2007

No peace yet :(

Nowadays every single day I am reminded of Tamil Nadu politics wherein there are effectively only two parties and people have no idea which one to vote for. Because both are equally bad. I switched from Windows to Linux because Windows was buggy and it could not stand my usage for more than 2 or 3 days. It kept crashing all the time and "Click OK to restart your computer" dialogue boxes were freaking me out. Now my Kubuntu installation is good by itself; but the awfully f***ed up Flash Player for Firefox makes Firefox unusually and intolerably slow, unresponsive, and whatnot. Jeez.. when are we going to get a good computer with software written by responsible human beings who could empathize with the real users. I know, this is how life is; but it just sucks :-(

June 10, 2007

Linux to Windows to Linux

Well, I am now moving back to Linux. I installed Windows on my laptop a month back (because I missed some Windows applications) and was using it till yesterday. There are certain things about Windows that just piss me off:
  • Mediocre shell (not the command-line shell): Windows GUI needs a lot of improvements. Forget those usability metrics; it crashed five times in two days (yesterday and the day before). I usually keep too many windows and a number of Firefox tabs open. And whenever Windows shell crashes I am forced to log out and log in to get that stupid shell again. It just sucks. All my applications lose state (well, almost all). After logging in back, it takes a while for the computer to become stable because there is a ton of things happening in the startup.
  • Software updates: While I always want to keep my computer up to date, Windows uses a poor model for overwriting a file which is open now. Upgrade IE? Restart computer. Upgrade Windows Media Player? Restart computer. Upgrade Adobe Reader? Restart computer. Security updates for Windows? Restart computer. I simply could not tolerate this nonsense. When I was running Kubuntu, I have had my computer running for about 2 months without restarting or logging out. Just hibernate and wake up. All the while I was updating all kinds of software in my machine. It just works.
  • Slow apps, slow devies: as soon as I insert a disk inside the optical drive, the whole system including all the apps and OS just stalls for a few second. Until Windows recognizes the CD, you got to wait. No need to say that Microsoft applications (like IE, WMP, Office, etc) are irritatingly slow and occupies all of our system resources. (I don't use them at all; but they are part of the computer. They get automatic updates, this that etc.)
  • Backup: When in Linux, all I needed was a single command to backup all my data to my iPod. But in Windows land, I have to search hard for a free backup software, install it and learn it's stupid user interface before using it. Heck, it takes hours to do incremental backup. Linux does that in a few minutes.
All this said, I was thinking for a lot of time before deciding to go back to my beloved Linux. I switched to Windows a month back because I wanted to use some nice Windows applications which I really missed. Support for iPod is not at all good in Linux. "But you know, that's life. You got to choose something and you'll regret your decision later on," I told myself when I formatted my hard disk to install Linux.

May 20, 2007

don't be nice to me!

I don't know why; but I get really pissed off when I find that people are "being nice" to me. No. I don't want anyone to be nice to me; I want people to be true to me. If I say something stupid, tell me in my face that I am stupid. I might be offended at certain times; but it's sure far better than the pain I experience when I find that you were just nice to me. I know it's very easy to be nice than being true. I know I ask for too much from the people I relate to. But that's me. Please don't be nice to me!

February 07, 2007

A bad web site

Have you ever seen a web site that is designed by technically illiterate programmers/designers who have a bad taste? If not, try http://www.pizzahut.co.in/. No, don't go to this site when you need some information about Pizza Hut. That site is designed to frustrate people who know what web sites are for. (I've warned you ;-)

January 29, 2007

Does Firefox use all your CPU?

Is your computer very slow because Firefox uses a lot of CPU even if it's not actively doing anything? For the past few days my computer was slow in general, and Firefox was horribly slow. The reason was that Firefox was using more than 70% of CPU all the time -- even when Firefox was idle. A quick Google search took me to the solution:
If you encounter problems with sites do not just complain that FF is not working but post the site address here for other people to check. No one doubts that you have problems but to decide if it is a FF problem or something with your system we must be able to check these sites.
I closed a few tabs (which I had open for the past few days), and my machine was back to normal :-)

January 08, 2007

Renaming files in a jiffy

Want to rename a bunch of files in a directory? If you are using a *nix operating system, it can be done with a single command. A set of files I downloaded from a website had filenames of this pattern: sitename.com_someprefix_filename.txt. If at all I had been using a Windows box, that would have been a nightmare -- I could not do it without writing a Python program. Fortunately, I am using a Kubuntu Linux box; so I can rename all the files with a single command:
for i in *.txt
do
   mv $i "`echo $i | sed 's/TheWebSite.com_[^_][^_]*_//'`"
done 
If I put this in a shell script, I won't even have to type this long command again and again. Now I realise why Windows is not for power users (like me).