Google Analytics

Monday, August 18, 2008

Linux featured in DOA: Dead or Alive movie

Because it's such a classic, I like to re-watch DOA: Dead or Alive every now and again. Based on the video game DOA 3 on Xbox, it vaguely follows the story line of the game. With a rich universe, impassioned drama and superb acting I have no idea why it only got 4.9/10 on IMDB ;)

On the weekend I was enjoying my third or fourth viewing of this theatrical masterpiece when I decided to pause during one of those 'computer code flows down the screen' scenes. To my surprise, this is what I found:

Alpha source code from the Linux kernel scrolling down the screen

For those playing at home, you can find this code in arch/alpha/kernel/err_impl.h from a 2.6 series Linux kernel.

There are some slight differences with the original code though. Random words and tokens are missing. For example, the copyright message has been mostly stripped, random words are missing from the description comment and tabs are displaying as boxes.

Having Alpha source scrolling down the screen didn't really make sense in the context of the scene, but I guess if they're going to just put 'whatever' up there, it's a nice Easter Egg for the nerds to unearth.

Thursday, August 07, 2008

Getting UTF-8 working in Irssi through Screen over SSH

I keep getting asked about this, so I will put it here for reference.

You can usually do it in 4 easy steps:
  1. Terminal emulator environment

    Ensure your terminal emulator is using UTF-8 encoding. If you're using iTerm on OS X, you can find this in Bookmarks -> Manage Profiles -> Terminal Profiles -> Default.

  2. Shell environment

    Configure your shell to use the UTF-8 version of your locale. For example, edit your ~/.bashrc file and change or add this line:

    export LANG="en_AU.UTF-8"

  3. Screen configuration

    In your ~/.screenrc, file, add this line:

    encoding UTF-8

  4. Irssi configuration

    In your ~/.irssi/config file in the settings -> "fe-common/core" section, add the option:

    term_charset = "utf-8";

You will need to quit irssi, exit the screen session and log out of the shell completely, then load it all back up again.

Now you too can impress your friends by using stylish words and phrases such as touché,

בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ



Thursday, May 01, 2008

Random words on command

Today I needed to generate SQL queries to populate a database table with some test data. I was making a Facebook-style search & narrow thing where, as you type, the list of options narrow based on your search string. I wanted to test the efficiency of my implementation, so I figured it would make testing easier if I used real words for the list items.

It seems a lot of people have needed to do this, so it wasn't long before I found a fairly good solution for my purposes. Here's the magic line:

perl -nle '$word = $_ if rand($.) < 1; END { print $word }' /usr/share/dict/words

I really have no idea why this works as I'm no Perl Monger. I also found that I didn't have any words at /usr/share/dict/words, since I was on an Ubuntu server install. I needed to sudo aptitude install wbritish. Incidentally, it worked on my OS X 10.5 machine too. Unix is handy.

I only needed 500 records and calling this 500 times didn't take too long. Much more and you'd probably have to modify your approach though.