Installing ruby 1.9 and mod_ruby on CentOS 5

CentOS 5 still only has ruby 1.8.5 in its repository, while the latest stable release of ruby is 1.9.2.  This article describes how to install ruby 1.9 from source, install mod_ruby from source, and configure Apache to execute ruby scripts.

1. Prepare to install ruby by installing the gnu c compiler.

[root@hostname ~]# yum -y install gcc

This brings with it the following dependencies which are automatically resolved by yum:

cpp glibc-devel glibc-headers kernel-headers

2. Download and install ruby

At the time of writing this article the latest stable version is 1.9.2-p180.  You can always find the latest version of ruby here: http://www.ruby-lang.org/en/downloads/

[root@hostname ~]# cd /usr/src
[root@hostname src]# wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
[root@hostname src]# tar xvfz ruby-1.9.2-p180.tar.gz
[root@hostname src]# cd ruby-1.9.2-p180
[root@hostname ruby-1.9.2-p180]# ./configure
[root@hostname ruby-1.9.2-p180]# make
[root@hostname ruby-1.9.2-p180]# make install
[root@hostname ruby-1.9.2-p180]# make clean

Verify Installation

[root@hostname ruby-1.9.2-p180]# which ruby
/usr/local/bin/ruby
[root@hostname ruby-1.9.2-p180]# ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
[root@hostname ruby-1.9.2-p180]# gem -v
1.3.7

3. Prepare to install mod_ruby

Install the Apache Runtime Environment (apr-devel) and the Apache development tools(httpd-devel).

[root@hostname ~]# yum -y install apr-devel httpd-devel

4. Download and install mod_ruby.

At the time of writing this article the latest stable version of modruby is 1.3.0.  You can always find the latest version of mod_ruby here: http://www.modruby.net/en/

[root@hostname ~]# cd /usr/src/
[root@hostname src]# wget http://www.modruby.net/archive/mod_ruby-1.3.0.tar.gz
[root@hostname src]# tar xvfz mod_ruby-1.3.0.tar.gz
[root@hostname src]# cd mod_ruby-1.3.0
[root@hostname mod_ruby-1.3.0]# ./configure.rb --with-apr-includes=/usr/include/apr-1
[root@hostname mod_ruby-1.3.0]# make
[root@hostname mod_ruby-1.3.0]# make install
[root@hostname mod_ruby-1.3.0]# make clean

5. Configure Apache and Verify the mod_ruby Installation

Create a file called ruby.conf in the httpd module configuration directory. All files in this directory are automatically loaded.

[root@hostname test_ruby]# cat /etc/httpd/conf.d/ruby.conf
LoadModule ruby_module /usr/lib64/httpd/modules/mod_ruby.so
AddHandler cgi-script .rb

Restart apache to reload the new configuration.

[root@hostname test_dir]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

If apache starts ok this means mod_ruby was successfully loaded.

6. Test it!

Make a web directory under the webroot for our test files. Create a couple of ruby scripts in there. In this example I have created one executable ruby script, and one erb file that will be loaded by the ruby cgi and rendered.

mkdir /var/www/html/test_ruby
[root@hostname test_ruby]# cat /var/www/html/test_ruby/index_cgi.rb
#!/usr/local/bin/ruby
require 'cgi'
require 'cgi/session'
require 'erb'

cgi = CGI.new
puts cgi.header
#here is variable i prepared here in the controller
test_var = "kentest"

rhtml = ERB.new(File.new("./example.erb.html").read)
rhtml.run(binding)

[root@hostname test_ruby]# cat /var/www/html/test_ruby/example.erb.html
<html>
<body>
Now i will access this variable here in the view
<%= test_var %>
and again
<% puts test_var %>
</body>
</html>

Make the ruby script executable.

[root@hostname test_ruby]# chmod a+x index_cgi.rb

Add the test directory to apache configuration:

[root@hostname test_ruby]# cat /etc/httpd/conf.d/ruby.conf
LoadModule ruby_module /usr/lib64/httpd/modules/mod_ruby.so
AddHandler cgi-script .rb

<Directory /var/www/html/test_ruby>
        Options ExecCGI
</Directory>

Restart apache again to reload the new configuration with the new directory.

[root@hostname test_ruby]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

In your browser go to hostname:80/test_ruby/index_cgi.rb

Voila!

Over Engineered Bagel Slicer

Is it a telescope!?  Are they trying to examine the bagel after its been sliced?  Are they trying to show the bagel the stars?  Does it also launch bagels to their respective patrons, even if they are driving by a nearby highway?  Because its certainly not doing a good job slicing.  It produced this bagel:

Panera Fail!

Lee gets Subpoenaed, Deposition ensues!

Ken Lee at the Deposition

Subpoenas don’t have to be scary or annoying.  If you are anything like me you don’t have much experience with being subpoenaed and frankly, it can be a bit intimidating.  Well fret not!  As promised, findings have been gathered and now you can follow Lee’s easy legal steps to minimize your inconvenience and maybe even have a laugh;)  Disclaimer: remember, I’m a telecomputer scientist and not a lawyer.  The following legal advice is not legal advice at all;)

Cast: Stenographer, Videographer, Plaintiff’s Lawyer, Defendant’s Lawyer, and your Host, Ken Lee

Rule #1: Don’t let them Bully you!

Subpoena’s are written in a language that can be very misleading for non-lawyers.  They use forceful terms, such as “you are commanded to appear” at such and such place and time, describing consequences such as “warrants”, “contempt of court”, “court intervention”, and even threats of being arrested.  I mean seriously, what ever happened to common courtesy.

The important thing to understand here is that you hold the power.  Generally speaking, there is a court case happening, and either the defendant or the plaintiff’s lawyer believes you have valuable information.  Remember, knowledge is power?  Well this valuable information they think you have gives you power.  In my case the defendant mauled someone outside of a bar.  The defendant was broke, so the plaintiff is trying to sue the bar.  I was with the defendant 5 hours prior to the mauling and could testify to his level of visible intoxication.

Rule #2: what are your terms?

Time is on your side, as they want the information sooner than later.  You can make life painful for these lawyers through a number of techniques.  They will start by picking a time and place and trying to trick you with their empty threats in to a situation that is convenient for them.  ie:  their office, during their work hours.  Pay them no mind.  Ask yourself what is the most convenient for you?  Do you want to make some money?  Did you have to make a trip somewhere anyway?  Figure out what would be the best case scenario for you and make it happen.  In my case they originally proposed for me to drive 30 minutes in the middle of a work day so i could go to their office on the same day several other people were being deposed!  Wouldn’t that be convenient for them and a total pain for me?!  For that insult I penalized them by stalling for 2 months!  A useful stalling technique is to indicate that you are obtaining representation for the matter.  You can also use your work as an excuse as they also cannot force you to miss work, and if you do miss work they must pay you for your opportunity costs.  They will not volunteer this cash however, you must demand it!  Ultimately I decided that my best case scenario would be for them to come to my barn study at 6PM on a weekday.  When I proposed this, they jumped at the chance, after all they want what I have;)

Rule #3: don’t let them waste your time

Now that they are in your place of choice, at your time of choice, you have them right where you want them!  You are in control of the environment and can use that to your advantage to ensure that they are in and out of there in minimal time.  In my case I had the deposition in the summer time.  With it 90 degrees outside, I chose to host the deposition in the second floor of my barn, which is my study, and can get quite stuffy.  With them in suits and me in whatever comfortable outfit I chose I kept the AC off and forced them to sweat it out!  Lawyers are humans too and they are after their own self interest.  If you make it uncomfortable for them, you will increase their incentive to get what they came for and get out, thus decreasing the likely hood they will waste your time.  Also at your house it is easier for you to eat, drink, and kick them out should something go awry!

RULE #4: Have Fun!

Action shot of stenographer snuck while being deposed!

Let your inner child come out!  Have you ever looked closely at that funny typewriter a stenographer has?  Have you ever done a photo shoot?  Honestly, a deposition is a little bit like a red carpet where you are the celebrity.  Both lawyers seek to gain your favor, so that the deposition and the court case goes their way.  As a result they will yes you to death and refrain from doing anything that might offend you.  This provides a great opportunity to cross social lines that might otherwise remain taboo.

RULE #4: Don’t forget to kick a freestyle

Videographer / Rapper

I got lucky!  The camera man wasn’t only a videographer, he was also a R&B and Rap artist.  We closed out the night with some A Capella freestyles.  He really surprised me when he started digging into me with references to the case.  Hoorah for making new friends:)

Lee’s Digital Movie Collection

The age of hoarding movies in our own private collections has come to and end.  With on-demand HD streaming movie services like Netflix and Amazon there is no need for me to keep my own collection.  They do it more reliably, efficiently, and for cheaper than I can do it myself.  So all i need from my digital collection is the names of the movies.  Here goes:

  • Chris Rock – Bigger and Blacker
  • 8 Mile
  • 1984
  • 2001 A Space Odyssey
  • A History of Violence
  • Adaptation
  • Aeon Flux
  • Ali G In Da House
  • Amelie
  • American Beauty
  • American History X
  • Battle Royale
  • Boogie Nights
  • Breaking And Entering
  • Brotherhood
  • Brothers Quay Collection – this was hard to find so i’ll keep it
  • A Bug’s Life
  • Casablanca
  • Chasing Amy
  • Chris Rock – Kill The Messenger
  • Clone High
  • Comedy Central presents Mitch Hedberg
  • Crash
  • Crouching Tiger, Hidden Dragon
  • Dawn of the Dead
  • Death at a Funeral – British Version
  • Der Untergang
  • Sin City
  • Team America
  • Eternal Sunshine
  • Fahrenheit 911
  • Fear and Loathing in Las Vegas
  • Finding Neverland
  • Frost Nixon
  • Garden State
  • Half Baked
  • I Robot
  • Ichi the Killer
  • I Heart Huckabees
  • Jackass
  • Jerry Seinfeld – I’m telling you for the last time
  • Closer
  • Kung Fu Hustle
  • Love Actually
  • Memento
  • Napoloeon Dynamite
  • Ocean’s Eleven
  • Office Space
  • Ong Bak Trilogy
  • Paid in Full
  • Reservoir Dogs
  • Rocky
  • Rounders
  • Scarface
  • Shaun of the Dead
  • Shrek Trilogy
  • SLC Punk
  • Snatch
  • Super Mario 3 time attack
  • The Evil Dead
  • The Royal Tenenbaums
  • The Shawshank Redemption
  • The Warriors
  • The Life Aquatic
  • Training Day
  • Trainspotting
  • Unleashed
  • Willy Wonka and the Chocolate Factory
  • Winged Migration
  • Zoolander
  • Fight Club
  • Doubt
  • Dumb and Dumber
  • 21 Grams
  • 28 Days Later
  • Alien vs. Predator
  • Ali G -HBO Series
  • Amores Perros
  • Anchorman
  • Big Fish
  • Blade Trilogy
  • Bridget Jones Diary
  • Che
  • City of God
  • Cool Hand Luke
  • Devil
  • Dog Day Afternoon
  • Dragon
  • Family Guy
  • Final Fantasy 7
  • Freddy Got Fingered
  • Freddy vs. Jason
  • Get Shorty
  • Good Will Hunting
  • Gran Torino
  • Harold and Kumar
  • High Fidelity
  • Lord of the Rings Trilogy
  • Man on Fire
  • Mrs. Miniver
  • Ninja Scroll
  • Ray
  • Ren and Stimpy
  • Rushmore
  • Seven
  • Shaolin Soccer
  • Spiderman
  • Star Wars Trilogy
  • The Office – British Version
  • Trinity
  • Vanilla Sky
  • X-Men Trilogy
  • Flight of the Conchords
  • Finding Nemo
  • Sukiyaki Western Django
  • I Claudius BBC Series
  • Let the right one in
  • Pineapple Express
  • Romeo Must Die
  • School House Rock
  • She Hate Me
  • Step Brothers
  • Taken
  • The Graduate
  • The Great Dictator
  • The Reader
  • The Wind in the Willows
  • The Wrestler
  • The Big Lebowski
  • The Curious Case of Benjamin Button
  • The Good, The Bad, and The Ugly
  • The Twilight Zone
  • There Will Be Blood
  • Tropic Thunder
  • Alice in Wonderland

This reminds me of the movie “Up in the Air”, specifically the bit about motivational speaking and “What’s in your backpack?”  Free yourself from the burdensome baggage you carry around that weighs you down without contributing to your happiness.

Upgrading from Rooted 2.1 to Rooted 2.2 on the Droid Incredible

Why Root?  Free Wireless Tether.. enough said.

Backup

First things first, backup all system applications and data.  I did this using the Titanium Backup App for rooted android phones which produces a backup on your sdcard.  I then moved the backup to my pc by connecting my phone to my pc via usb and dragging and dropping the Titanium Backup folder from my sd card to my desktop.  I also did a contact backup using VZ Wireless Backup Assistant for good measure (Settings, Accounts & Sync, Backup Assistant)

Unrevoked Forever

Next I had to make my current root permanent using unrevoked forever. The unrevoked forever method toggles a non volatile memory register on the radio chip.  This is there by design and when toggled disables a variety of system checks, allowing custom executables to be installed.

Now that I had my permanent root installed I thought I would go ahead and accept the upgrade invitation that had been harassing me all day long.  Unfortunately this did not work and first accosted me with an error message and then rebooted back into my 2.1 installation.

Downgrade

After some internet scouring i determined that I had to first replace the custom recovery I had installed when I rooted my phone originally with the stock recovery.  Only then could I apply a stock OTA update.  I found this android forum which provided downgrade instructions including a link to the stock recovery image in a file called PB31IMG.zip.  Finding that file and downloading it was the least pleasant part of this task.  You find it on free download sites that make you wait for 90-360 seconds before proceeding to download this 100+MB file at 100Kbps… sheesh… my coffee is getting cold… 20 minutes later, move it to your sdcard, reboot while holding the volume down and voila!  Once my phone booted up it was back to a stock installation and all my data and apps were gone.

Pre-Upgrade Upgrade

Now that I was back to stock 2.1, I had to apply another update to get to the latest version of 2.1 prior to the release of 2.2.  I found the requisite files over at xda-developers and brought my phone up to software number 1.22.605.2.

Upgrade to Froyo

http://forum.xda-developers.com/showthread.php?t=770091

Root

first re-install a custom recovery image and then apply the su update:

http://unrevoked.com/rootwiki/doku.php/public/forever

Restore from Backup

Install Titanium Backup from the app store and restore all apps and data.  This brought back everything from text messages and  contacts to remembered wireless passwords.  Following the backup, everything wasn’t perfect… there were a couple of things here and there that required tidying up.. but all in all nothing major.  Most importantly Wifi Tether still works!

Google Outage caused by Akamai

Sitting at a cafe I attempted to load www.google.com in firefox on my macbook pro.  I was surprised to see www.mediaplex.com load.  I immediately suspected my macbook had been hacked so i turned on a packet trace tried again to see who’s web server I was actually communicating with.  I found they were going to an ip address belonging to Akamai.  Some reading on the net revealed to me that Akamai provides content delivery service to both google and mediaplex.  10 minutes later everything was back to normal… Did Akamai’s data center serving NYC just hiccup?

My First Apple – 15″ Macbook Pro

My very first Mac arrived last week and I have been busy exploring it!  Let’s get right into the findings;)

Specifications

15" MacBook Pro
Intel Core 2 Duo 2.8 Ghz
4 GB RAM
1.07 Ghz System Bus
Nvidia GeForce 9400M/9600M GT

First Impressions

Brought the software up to date without any problems.  The screen is beautiful and it really shows when you watch HD movies.  Boot time is reasonable: 25 seconds from powered off.  The edge where your wrists lie is sharp as a razor.¹  Various commands were mapped to ctrl – X.  I remapped them in the keyboard preferences to command key as that key is slightly larger and more accessible.  The Dock, Expose, Stacks, and Spaces are all really great features for quickly navigating your open, minimized, and closed applications.²  I mapped Expose to the bottom left corner in System Preferences and Spaces to the bottom right corner.  Activating Expose and Spaces in sequence gives a birds eye view of all your open applications and even allows you to move them between spaces to organize them.  I was dissapointed with safari, the default browser. First it has no favicons in the tabs, as firefox does, and no easy way to enable them.  This makes it hard to differentiate between tabs when you have many tabs open.  Also, it doesn’t support a full screen mode, a must imo on any screen smaller than 22 inches;)  Thirdly it lacks support for the awesome things you can do with the multitouch trackpad, more on that later though.  By default to “primary click” on something you have to push down on the trackpad until you hear a click.  I thought this was a little too much work so in the Trackpad System Preferences I enabled one finger “tap to click.”  The second time using the computer it froze, the menu bar at the top disappeared and the system was unresponsive until a hard reboot.  This hasn’t happened again in the following week.

Important Trackpad Shortcuts

  • 4 fingers down – expose – overview of windows in workspace
  • bottom left corner – expose
  • bottom right corner – spaces – overview of all workspaces
  • 4 fingers up – show desktop – Activated through System Preferences – Trackpad
  • twist right and left change tabs in firefox – This requires a firefox config change detailed here.
  • 3 fingers down – close tabs in firefox – This requires a firefox config change: (about:config – Preference Name: browser.gesture.swipe.down, Value: cmd_close)
  • 3 fingers up – scroll to the top of the page
  • 3 finger tap – open link in new tab – This requires the installation of a third party software – MiddleClick and it must be configured to start when you log in (System Preferences -> Accounts -> Login Items)

Software

  • transmission – feature rich bittorrent client
  • middleclick – turn 3 finger tap into a middle click
  • macports – package manager for installing free software (the first thing i did with this was “port install wget”)
  • porticus – a gui for macports
  • openoffice.org
  • vmware fusion – trial version, full version costs 80 bucks… we’ll see about that;)  So far installed centos and google chrome virtual machines without hitch.
  • firefox – superior web browser

System Startup

So far I have counted 3 ways to configure applications to start on boot/login.

  1. User Friendly GUI – System Preferences -> Accounts -> Login Items
  2. User Friendly GUI – System Preferences -> Sharing
    1. Web Sharing means Apache
    2. Remote Login means ssh
  3. Command Line – Now this way is super complicated and is an example of an area that Red Hat Linux is currently more mature than Mac OS X.   Here is a brief list of somewhat analagous components of the start up process between Red Hat and Mac OS X.
    1. ckconfig list  in red hat equals launchctl list in Mac OS X.
    2. service in red hat equals launchctl in Mac OS X.
    3. /etc/init.d/ in red hat equals [/System]/Library/LaunchDaemons/ in Mac OS X.

Random Observations

  • In the Spaces preferences you can choose to have an affinity between a space and an application so that whenever you open an application it always gets opened on that space.
  • when ls -l reveals an @ at the end of the permission string to find out what that is for you must do: xattr -l
  • window groups in mac’s terminal are neat.  Arrange your windows the way you like once!  Then save the window group and every time you open the terminal application all the windows in your group get opened, placed, and sized.  This plays nice with the Spaces Applications affinity tip right above.
  • add spaces to the dock
  • softwareupdate command line tool

Bugs

I experienced what seemed like the same bug twice.  Basically I enabled a System Preference and after a random amount of time that preference became disabled, though in the preferences gui it still indicated that it was enabled.  To fix I had to disable, reboot, and re-enable.  This happened with the automatic login feature that allows you to come right to the desktop without choosing your user and logging in, and also with 3 and 4 gestures in the trackpad preferences.

Footnotes

¹ Popular solutions on the internet include propping the laptop so the angle is less dangerous, putting electrical tape on that edge (i did this one), and sanding it down (i may try this if i don’t like the tape, so far i can’t say i’m thrilled with the tape lol).

² http://www.apple.com/support/mac101/tour/

What do these 3 countries have in common?

(Spoiler Alert! Answer at bottom)

Step 1: Identify the countries;)  South Korea, Israel, Singapore.

These 3 countries are all:

  • first world / developed countries with very high economic growth
  • small in area and population
  • ranked in the top ten for active military per 1000 people
  • have a draft requiring men (south korea and singapore) or men and women (israel) to spend 18+ months in the army full time and then participate in the reserves
  • have high ratios of reserve troops to active troops, with large portions of the population participating in the reserve army
  • have hostile relations with neighbors or have been invaded by neighbors in the past (singapore by japan)

Further Reading:

Economic Indicators

State of the Internet

Websense is a San Diego based Internet Security Company with roots in web filtering.  A quick google has revealed criticism about Websense falling into two categories:

  1. They serve repressive regimes in China and Yemen in their goals to censor the internet.
  2. In America, where they are used widely both in Corporate and Government deployments, there are too many false negatives.  This means that sites become censored which should be available.

They have released some interesting findings from 2009 here.  Among the highlights are:

  • 71% of Web sites with malicious code are legitimate sites that have been compromised.
  • 95% of user-generated posts on Web sites are spam or malicious.
  • Phishing lures have doubled since the first half of the year representing approximately 4% of spam email.
  • US, Russia, China and Brazil are consistently in the top 5 countries hosting crimeware and receiving stolen data.
  • The average time it took for anti-virus vendors to deliver a patch once malware was identified has more than doubled from 22 to 46 hours, comparing the first 6 months of 2009 with the last.