Raam Dev

Hello, future.

A Time When Chain Letters Were Fun

When writing Bash scripts I often use the Advanced Bash-Scripting Guide for reference. By now I've probably browsed through almost every chapter in the guide, that is except one: Recess Time. The chapter never seemed to apply to what I was looking for at the time, so I never bothered to look at it -- until today.

There, I discovered this fun piece:

Fellow Linux user, greetings! You are reading something which
will bring you luck and good fortune. Just e-mail a copy of
this document to 10 of your friends. Before making the copies,
send a 100-line Bash script to the first person on the list
at the bottom of this letter. Then delete their name and add
yours to the bottom of the list.

Don't break the chain! Make the copies within 48 hours.
Wilfred P. of Brooklyn failed to send out his ten copies and
woke the next morning to find his job description changed
to "COBOL programmer." Howard L. of Newport News sent
out his ten copies and within a month had enough hardware
to build a 100-node Beowulf cluster dedicated to playing
Tuxracer. Amelia V. of Chicago laughed at this letter
and broke the chain. Shortly thereafter, a fire broke out
in her terminal and she now spends her days writing
documentation for MS Windows.

Don't break the chain! Send out your ten copies today!

It gave me a few laughs and made me realize that a time probably existed when chain letters were actually fun to read!

Instant Word Definitions on the NYTimes Website

The New York Times has a great website. One feature I accidentally discovered today (although I believe it has existed for several months) allows you to select any word from within an article and bring up the definition of the word. The feature uses this Javascript to place a little question mark icon next to the word when you select it:

New York Times Dictionary Lookup

Clicking the question mark opens a new window with the definition and even an encyclopedia entry (if one exists) using a Reference Search powered by Answers.com.

Some would argue (and I would tend to agree) that such a feature should be left to be implemented in a browser extension. Never the less, it's a really cool feature and it reminded me how much of an effect technology is having on print publications. Just think, 20 years ago reading the newspaper and instantly getting the definition of a word by selecting it would have been science fiction.

Introducing my New Tech Blog: Solid State Raam

For quite some time now, I've been meaning to set up a blog dedicated to technology. Well today, after writing a long detailed post about ripping DVDs, I realized that I had procrastinated long enough. I already had a domain picked out and the famous 5-minute WordPress install meant I couldn't use set up time as an excuse.

When I started searching for a suitable theme to use on the new site, I quickly recognized the black-hole-for-time that process becomes and that it would probably put me back into the procrastination phase. So for now I'm just using a (slightly modified) default theme. OK, now the only thing missing to get this blog going was action.

With all that said, I pull the trigger and introduce Solid State Raam, a blog that will feature my explorations (and exploitations) of the digital world. The first post, Ripping and Converting DVDs to MPEG-4 on Mac OS X, is exactly the type of post I would hesitate to post on this blog for lack of "personality".

While I talk a lot about technology in this blog, I feel that the long detailed tutorial-type posts are out of place. This is my personal blog and the raw posts on technology feel a little too impersonal. Don't get me wrong, I will still talk about technology here; technology is a huge part of my life and if I stopped talking about it I would probably have very little to say!

For the most part you won't notice very much change here. If anything, I may start expressing my opinion more and talking more about the non-technology things that interest me -- both of which I feel an increasing urge to do. 🙂

Ripping and Converting DVDs to MPEG-4 on Mac OS X

I've been converting a lot of my DVDs to MPEG-4 recently. The process is much easier than I always imagined, so I decided to explain the procedures I use here. All of this is done on my Mac, so the directions are somewhat Mac-specific. That said, HandBrake (the main application used in this process) is open-source and available on Windows and Linux. You should be able to find MacTheRipper-equivalents for Windows and Linux (and if you know of some, please mention them in the comments!).

Download & Install Software

  1. Download MacTheRipper (v2.6.6 is listed on that site but I'm using v3.0. Search BitTorrent for the newer version if you're interested.)
  2. Download HandBrake (I'm using v0.9.3)
  3. Install the above applications

Rip the DVD Using MacTheRipper (what an awesome name!)

  1. Insert the DVD
  2. OS X will automatically start playing the DVD. Press CMD+Q to quit the application.
  3. Launch MacTheRipper (and be careful he doesn't hurt you)
  4. MacTheRipper

  5. Leave the default options and select File -> Save To...
  6. Create a new directory to temporarily store the raw contents of the DVD and select it
  7. Click Open. MacTheRipper will automatically start ripping the raw contents of the DVD to the directory you selected
  8. When the ripping finishes, quit MacTheRipper

Convert the Raw DVD Data to MPEG-4 Using HandBrake

  1. Launch HandBrake (don't break your hand)
  2. Upon launching, you should be presented with the Open dialog. You want to select the directory to which you ripped the DVD using MacTheRipper. Note: Select the directory that contains the VIDEO_TS directory, but not VIDEO_TS directory itself! The other directories contain important data, such as AUDIO_TS for audio data.
  3. Click Open and HandBrake will scan the various titles in the raw data. When finished, you'll be left with the main HandBrake screen
  4. HandBrake Main Screen

  5. The correct title should already be selected and it should be the longest one in the list. If it's a 2-hour DVD, you don't want to select the title that says 1 minute. There may be lots of short titles mixed in and these may be extras on the DVD or previews.
  6. After you've selected the correct title, choose browse and select a location where you want to save the converted video. After selecting the location, you can change the filename or leave the default. I like to store various bits of information in the video filename, such as the year the video was released, whether it's widescreen or full screen, and the codec and audio formats. For example:

    Gattaca.1997.WS.DVDRip.XviD.AC3.avi

  7. Now select the format. I usually choose AVI for the best compatibility.
  8. For video codec, choose "MPEG-4 (XviD)"
  9. Next to "Quality:", select "Target size (MB)" and use the following guidelines. I like to retain as much of the quality as possible, so I follow these rules. Remember, the higher the file size, the better the quality. If you don't care so much about quality or don't have lots of free space, you can just use 700MB for DVDs. I use 1400MB for DVDs, and smaller sizes for TV/Documentary or episodic movies.

    Here are the sizes I use depending on the length of the movie or episode:

    175MB (20-30 mins)
    350MB (40-55 mins)
    1400MB (90 min+), also known as 2CD quality

  10. Click the "Audio & Subtitles" tab
  11. Choose the best audio source quality available. Sometimes the DVD will contain 6-Channel 5.1 audio, but it won't be selected by default.
  12. If it's available, select "AC3 Passthru" under "Audio Codec".
  13. HandBrake Audio Settings

  14. With everything configured, click Start. If you're converting a DVD that is a collection of shorter movies (like the Outer Limits DVD I'm ripping in the example), you can simply click "Add to Queue", repeat the above process for each of the titles, and then click Start when everything is queued up. If you plan to do this though, you should definitely convert at least one episode first to make sure it comes out correct.

Depending on the speed of your computer, the quality, and the length of the movie you're converting, this process could take anywhere from 30 minutes to 3 hours.

When HandBrake finishes, try watching the resulting AVI and make sure it plays correctly (with sound and all). If you're not happy, delete it and repeat the process again. Once you're happy with the AVI, you can delete the raw data that you ripped earlier with MacTheRipper (it takes up 6-7GB of space!).

Made Typography Changes to my Theme

I've made a few typography changes to the theme that will hopefully make it more readable. You may have noticed the content font is slightly bigger and the hyperlinks are no longer bold and black. I also darkened the post title font to make it more prominent and decreased the sidebar font by one size and the random quote font (at the top) by two sizes.

A Realization that GUI Dependence can be Harmful

After an arduous three days without my laptop, I finally have it back in my possession. I managed to get by using an old Thinkpad running Linux, a Windows XP desktop, and a spare G4 Mac Mini running OS X (all three of which saw very, very little use while I had my MacBook Pro). Every bit of my email is stored server-side (IMAP) and any important files were accessible on a backup drive, so it was really only the computing environment that changed.

Despite only the environment changing however, I observed something interesting: I felt a lot less creative and even mentally (and perhaps even emotionally) handicapped without my laptop. It's the first time I can remember feeling that way from something as simple as a piece of electronic machinery. I'm convinced it was the graphical user interface (GUI) I became attached to and, being someone who hates feeling attached or in any way dependent, the experience has encouraged me to continue moving towards console-based solutions for my daily computing needs.

Maintaining things on a remote console means the environment will stay the same regardless of the computer I'm using to connect. The "computing environment" essentially becomes the console window itself. Advantages to using console-based programs are numerous, that is once you get past the learning curve. But the same way a one-finger typist isn't very productive until he learns to type, console-based apps won't allow you to be productive until you become familiar and comfortable with the environment.

For all real-time communication (IRC, AIM, and Jabber) I've switched to using screen + irssi + BitlBee. Previously, I was using irssi for IRC and Adium for instant messaging. For email, I've been meaning to set up mutt for quite some time, but both the complexity and my daily reliance on email have caused me to procrastinate.

But I realized my console-migration doesn't need to end with IRC, IM, and email. For example, when my coworker mentioned the idea of an IRC Twitter interface, I looked for one and discovered tircd, an IRC proxy to the Twitter API. This made me realize that even things like posting to my blog could be done through IRC with the right proxy (similar to the way I'm currently blogging from the command line). And if a particular IRC proxy does not exist, I can just as easily write one myself and share it with the community!

MacBook Pro Suffers from Defective NVidia Chip

If you've been following me on Twitter, you may have heard that my MacBook Pro is dead in the water. It was working fine this morning but when got to the office and opened the lid, the screen remained black. I tired a hard reboot but no matter what I did it wouldn't come back on.

After a short meeting at the office, I headed back home to see if I could restore from a backup. (My latest backup is a few weeks old, so I was really hoping the drive itself was fine.) When I got home I took the laptop apart, removed the drive, and installed it in an external USB enclosure to check if it was OK. Much to my relief, when I plugged it into a spare Mac Mini the drive showed up fine. I quickly rsync'ed the original drive with my backup drive to make sure I had an up-to-date copy. With a 320GB drive and only 6GB free, the backup took some time.

While waiting for the backup to finish, I did some research to see if anyone else had this blank screen problem. I quickly discovered that I was most definitely not alone. Thousands of people have experienced this same issue. (I vaguely remembered hearing news about this issue, but didn't pay attention.) The Apple Support article on this problem describes the symptoms:

In July 2008, NVIDIA publicly acknowledged a higher than normal failure rate for some of their graphics processors due to a packaging defect. At that same time, NVIDIA assured Apple that Mac computers with these graphics processors were not affected. However, after an Apple-led investigation, Apple has determined that some MacBook Pro computers with the NVIDIA GeForce 8600M GT graphics processor may be affected. If the NVIDIA graphics processor in your MacBook Pro has failed, or fails within two years of the original date of purchase, a repair will be done free of charge, even if your MacBook Pro is out of warranty.

So I brought the laptop to the local Apple store and, after running some tests, the technician confirmed the problem was indeed the NVidia chipset. My MBP is 6 months past the 1 year warranty, which means only 6 months remain before Apple would make me pay $1,200+ for this repair. I'm just happy it happened sooner rather than later and that I don't have to pay a dime, even if it does mean trying to survive without it for a few days.

Leslie Orchard on the Usefulness of Tagging

In response to the Do Tags Work? article by Cathy Marshall, Leslie Orchard, who used to work for Delicious, wrote why he believes tags do work. My first thought when reading Cathy's article was that Flickr seems to be a bad subject for testing the usefulness of tagging, since Flickr doesn't require the use of tags. For this reason, Leslie says that users are more likely to write good titles and/or descriptions of their photos, leaving tagging as only an afterthought. The tools used to bookmark pages in Delicious however, automatically fill in the page titles and descriptions (using selected text, if any) often leaving tags as the only user-generated input. Perhaps tags are only useful for certain types of content.

Cathy Marshall on the Effectiveness of Tagging

Cathy Marshall, a senior researcher at Microsoft, conducted a short study on the effectiveness of using tags to describe content. The article, "Do Tags Work?" is a bit lengthy (and needs editing), but the findings basically show that people generally don't use verbs when tagging and that the titles and descriptions they write are almost always a more useful definition of the thing being tagged (especially when searching across large datasets). The tags are, if anything, only useful to the tagger himself (and even then, time is likely to erase from memory the words he would have used since the tags most likely did not contain verbs).

Sinuses Overreacting to Nose Breathing

This morning while doing my cardio workout (30 minutes, 3 miles) I decided to put to practice the nose breathing I wrote about last week. During the entire workout I inhaled through my nose and exhaled through my mouth. When I finished, my nose started tickling and I began sneezing non-stop, as if I suddenly became allergic to the world. Its been six hours and my sinuses are still overreacting. Could my nose be so underused that it doesn't know how to handle regular air?!

Blogging from the Command-Line

I'm a command-line person. If you can show me a command-line version of something I already do in a windowed environment, I'll get stuff done faster. I often look for command-line solutions to tasks that become repetitive and feel as though time could be saved by doing them on the console.

A recent example of this is the posting of asides on my blog. Asides are often very short (one or two sentences at most -- they appear on my blog without a title) and navigating the WordPress Administration interface in a web browser simply to post one or two sentences became very time consuming and distracting. Since I'm constantly editing files and code on the console using my favorite editor (vi), being able to quickly create and post an aside from the same environment would be awesome.

Before writing a tool that allowed me to post to my WordPress blog, I searched Google to see if someone else had already written something. Sure enough, I found blogpost, a script written in Python by Stuart Rackham:

blogpost is a WordPress command-line weblog client. It creates and updates weblog entries directly from AsciiDoc (or HTML) source documents. You can also delete and list weblog entries from the command-line.

It uses XML-RPC to post to WordPress blogs and also supports automatically uploading media files (images, videos, audio, documents) that are referenced within the AsciiDoc (or HTML) post file. Check the blogpost man page for full details.

Remember, my main goal here is to make posting short asides easier. I'm perfectly happy using the WordPress web interface to write longer posts. In fact, I prefer the web interface for longer posts because I get things like automatic spell checking (through OS X) and automatic draft saving (through WordPress).

After installing blogpost and modifying the configuration file to include my WordPress login details, I created a file called post.txt using the vi editor and, after saving the file and closing vi, I published the aside using blogpost:

$ blogpost.py --title="My Test Aside Post" -U --doctype='html' create post.txt
creating published post 'My Test Aside Post'...
id: 2758
url: https://raamdev.com/2009/01/24/my-test-aside-post

$ blogpost.py cat --categories="Asides, Blog Entries, General" post.txt
assigning categories: Asides,Blog Entries,General

Note that I only need really basic formatting (i.e., HTML for links), so I use the --doctype='html' option. This allows me to type raw HTML in vi when I'm editing the post file, just as I do now in WordPress (I don't use the Visual Editor).

While the options and flexibility provided by blogpost are great, the process of publishing an aside needed to be more automated to solve my problem. Creating a new file in vi, typing all those options, running two separate commands, and then deleting the file every time I wanted to post a few sentences on my blog didn't make a whole lot of sense. So I whipped together this little shell script to help automate the steps above:

#!/bin/sh
##
## aside.sh - automates publishing asides using blogpost.py
##

# Open a temporary file in the vi editor
vi aside.$$

# Display new aside before publishing
echo "New Aside:"
cat aside.$$
echo

# Prompt for an aside title
echo "Enter a title for this Aside:"
read TITLE
echo "OK!"
echo

# Using the temp file saved above, post the Aside
blogpost.py --title="$TITLE" -U --doctype='html' create aside.$$
blogpost.py cat --categories="Blog Entries, Asides" aside.$$

# Remove the temporary file
rm aside.$$

Now posting an aside to my blog is as simple as running ./aside.sh, typing the aside in vi, saving and quitting (:wq), and then typing a title. The rest of the work, including cleanup, is taken care of by the script!

Stuart did an excellent job with blogpost and if you have a blog and use the console (and why shouldn't you?!) I recommend you check it out. The blogpost README is a great place to start, as it includes prerequisites and installation information.

The C Programming Lanaguage is Very Much Alive

A recent survey says almost half (47%) of all new open-source projects in 2008 used the C programming language. For a language that is more than 36 years old (centuries in technology-terms), that's pretty damn impressive. This reinforces my recent commitment to learning the C lanaguge and makes me realize just how useful familiarity with C will be as I continue my journey into the Unix world.

How Last.fm Uses IRC

Richard Jones, one of the co-founders of Last.fm, has a writeup describing how Last.fm uses IRC. I'd really like to see IRC used for more stuff like this, including communication in general. (In the comments, one guy describes how him and his friends use their own private IRC server for communication.) It's sad that a lot of people don't even know what IRC is, let alone use it. If you're one of those people, check out The IRC Prelude and the Wikipedia page. If you're using Windows, check out the free mIRC client (I use irssi on Linux) and if you don't feel like installing anything, check out the awesome web-based client Mibbit.

The Importance of Breathing Through Your Nose

Have you ever wondered about the importance of breathing through your nose vs breathing through your mouth? While searching the Internet for an answer to why the cold air seems to freeze up my chest and make breathing very difficult, I stumbled across The Science of Breath. The section on Nostril vs Mouth-breathing had this to say about cold air:

And, moreover, such incorrect breathing admits cold air to the organs, thereby injuring them. Inflammation of the respiratory organs often results from the inhalation of cold air through the mouth.
...
Not only do the nostrils serve this important purpose, but they also perform an important function in warming the air inhaled. The long narrow winding nostrils are filled with warm mucous membrane, which coming in contact with the inhaled air warms it so that it can do no damage to the delicate organs of the throat, or to the lungs.

The author says that many diseases can be attributed to the habit of mouth-breathing and says that smallpox, which killed many men-of-war in foreign countries, did not kill a single "nostril-breather"; it only affected those who breathed through their mouths (though I can't help but wonder how he obtained nostril vs mouth-breather data).

I have observed that I breathe through my mouth most the time. Between the ages of thirteen and eighteen I had asthma that was bad enough to make climbing a flight of six stairs difficult. I suppose the habit of mouth-breathing could have formed when I had asthma: Since my lungs needed to get as much air as possible, I subconsciously developed the habit of always breathing through my mouth. (The asthma disappeared when I stopped eating dairy and started exercising.)

What other implications could mouth-breathing have? Of all the organs in our body, the brain uses the most oxygen. What organ is closest to the brain? The nose! Could breathing through our nose somehow provide our brain with a little extra oxygen, thereby increasing its function? When I breathe through my nose, my head automatically feels better; my brain feels clearer and refreshed with every breath. I don't feel any of that when I breathe through my mouth.

I'm going to start doing daily breathing exercises and make a conscious effort to breathe through my nose. The Summary of Techniques and Exercises section of the aforementioned site has some incredible breathing exercises (try a few!).