Ruby 1.9.1 Released!

Here’s where to get it via svn. Or you can try the links below:

ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz

ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.zip


ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.bz2

The best thing to do is just svn export the directory. Then just follow the instruction from my previous post on installing. For Mac users, just following autoconf -> ./configure –prefix=(where you want installed, for me it’s ~/.ruby19) –enable-pthread -> make -> make install.

For details, take a look at the news file by clicking here.

Finding Object by Its Object ID

Ruby comes with a wonderful module called ObjectSpace that allows me to find a lost object as long as I have its object_id and granted it hasn’t been GCed. Here’s a bit of code to illustrate this.

>> a = "hello"
=> "hello"
>> id = a.object_id
=> 3116970
>> a = nil # oh no!
=> nil
>> b = ObjectSpace._id2ref(id)
=> "hello"
>> b
=> "hello" # the original "a" has been restored to "b"

Armed with this, I can now see how long objects live after a request has been served by the Rails.

My Netbook As a New Server

Rather than burning my HP 2133, I thought it would be interesting to see if I can convert this as a server. Considering the fact that it does have 1.2 Ghz processor, far faster than the processors I used to work on ten plus years ago.

The weapon of my choice here is to use Ubuntu 8.04 Server for obvious reasons. After few failures, I realized that the server image is somewhat different from the USB key I used to install the desktop version. Therefore, rather than waste any more time, I used Sabrent USB 2.0 cable to SATA & IDE cable. I took out a DVD writer from my old desktop and used it to install the server. I can’t tell you how convenient this adapter is. It’s a must for every geek.

After installing Ubuntu server, I configured everything, closed the lid, and took it out for a test drive. Turns out, with 120GB of HDD, it serves beautifully as a Samba server. There’s no difference in performance, since the bottleneck really is the network. It serves as a great Apache server too. It’s a great little web server and even runs MySQL alongside without any problem.

I’m very pleased with the performance of the netbook as a server. I think these netbooks can be converted into inexpensive home server or even small business server using Linux. No, I wouldn’t use it to serve up anything that requires serious resource, but who knows?

Introduction to Pair Programming

Stumbled on this video on pair programming. Well worth the look.

Hate My Netbook!

34-147-676-12.jpgBeing an early adapter has its good and bad points. What’s good is that I carried around a small laptop (before it became a “netbook”) everywhere and, paired with Ubuntu and EVDO, I really really looked cool. I love the portability of my HP 2133 (Via 1.2 Ghz/120GB HDD/1GB RAM) and the cuteness of it.

Well, here comes the parts I hate.

First of all, this thing is so underpowered that I can’t play any decent video on it. I’m not expecting HD stuff, but this thing struggles with small screencasts. Compiz doesn’t work and I really really love wobbly windows. I know it’s childish, but hey, why not?

The biggest beef I have with this unit is the battery life. I’d be lucky if this thing lasts hours and half. I was looking into getting a bigger battery, but the price is just ridiculous. It kinda defeats the purpose of portability if it has to be plugged in all the time.

I’m looking into new netbook based on Intel Atom processor and “all day” battery life.

Ruby 1.9.1 Release Candidate 2

Ruby 1.9.1 Release Candidate 2 has been released. You can use the preview install instruction to install. I certainly will upgrade.

Locations:
The source
ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-rc2.tar.gz

Installation Screencast
http://www.rubyhead.com/2009/01/14/installing-ruby-191-from-source-on-ubuntu-screencast/

Installation on Ubuntu
http://www.rubyhead.com/2009/01/11/installing-ruby-191-preview-1-rails-on-ubuntu-804lts-hardy-heron/

Installing memcached on Mac OS X Leopard

This is how I install and run memcached on my MacBook Pro. It also runs on boot. The script can be downloaded at http://www.joonworld.com/files/memcache_on_mac .

1. Get and install libevent
wget http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz
tar xvzf libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
autoconf
./configure --prefix=/usr
make
sudo make install

2. Get and install memcached from source
wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar xvzf memcached-1.2.6.tar.gz
cd memcached-1.2.6
autoconf
./configure --prefix=/usr
make
sudo make install

3. Set it up to run at boot. The plist file is on my server.
wget http://www.joonworld.com/files/com.danga.memcached.plist
sudo mv com.danga.memcached.plist /Library/LaunchDaemons/
sudo launchctl load /Library/LaunchDaemons/com.danga.memcached.plist

Here’s the content of the plist file. You can customize this by changing the parameters.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.danga.memcached</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/memcached</string>
<string>-d</string>
<string>-u</string>
<string>root</string>
<string>-p</string>
<string>11211</string>
<string>-m</string>
<string>64</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

How I Develop Ruby on Windows

Links:
VirtualBox => http://www.virtualbox.org
Ubuntu => http://www.ubuntu.com

Definition of Beautiful Code

I’ve been hearing developers talking about “beautiful code”, heck, there’s even a book titled with it. What is “beautiful code”? From my observation, “beautiful code” is defined as code that I write or anything that you write that I’m not involved in. On the other hand, the “ugly code” is defined as any code other morons write.

One of the things I enjoy about my chosen profession is that it allows creativity and at times, interesting expression; much like the art of writing. After all, we all say we “write” the code, just as an author of a book would say. Just as a good book or a painting, I firmly believe that everything’s subjective. In other words, it’s truly in the eye of beholder.

So next time you run into the “ugly code”, just take a step back and compliment the writer for his/her creativity rather than lash out at him/her. We all can take a step back and be kind to each other.

Sample From My Tutoring Session – In HD

Ben and I use Skype and VNC to do this since he’s in Seattle and I’m in New Jersey. This is from a session where we go over various asynchronous processing techniques. It’s not all business though. I can’t speak for Ben, but I have a great time.

Next Page »

Clicky Web Analytics
Powered by Olark