Skip to main content


Showing posts from 2010

Using multiple versions of Ruby on the same host

I've recently come across a tool called RVM or Ruby Version Manager. It enables you to run different versions of Ruby on the same host. RVM uses git so my first step was to install git with the Homebrew package manager. Homebrew is an increasingly popular alternative to MacPorts and Fink. Note that you'll need to install Xcode first. /usr/bin/ruby -e "$(curl -fsSL" brew install git Then I just followed the instructions available here . bash < <( curl ) source ~/.rvm/scripts/rvm rvm install jruby,1.9.2-head Here is what the output looks like: info: Downloading jruby-bin-1.5.1, this may take a while depending on your connection... info: Extracting jruby-bin-1.5.1 ... info: Building Nailgun info: Installing JRuby to /Users/rpark/.rvm/rubies/jruby-1.5.1 info: Importing initial gems... info: Installing rake info: Installing Ruby from source to: /Users/rp

Connecting to JDBC data source from OS X perl

Here's another blog post on a similar topic. I recently had to figure it out and I documented it already, so I thought I would share it here too so I don't forget. Here are instructions on connecting to a JDBC data source from OS X perl. I used DBD::JDBC . The process mainly involves setting up a local Java server that provides the front end for a JDBC driver. The Java code implements the JDBC connection to the data source. The perl code talks to the Java server on localhost via DBI so it can access the database. Here are the steps: 1. Check out any documentation about required setup for your JDBC data source. For example, you may need to install an SSL certificate from the server to your client. You may also need to ensure that your server permits database access at all from your client or IP address. 2. Download your JDBC driver and put any .jar files into a lib directory. For example, VJDBC is a JDBC driver that enables you to establish JDBC connections over Java

Connecting to SQL Server from OS X perl

I've been spending my coding time in the offhours working on Perl instead of Ruby. My coding time in general has been very limited, which is part of the reason for the length of time between updates. :) My latest project is to pull data out of a Microsoft SQL Server database for analysis. I'm using perl for various reasons: I need a crossplatform environment, and I need certain libraries that only work on perl. Some of the target users for my code run on Windows. I know that Ruby runs on Windows but it's not the platform of choice for Ruby developers. The vast majority seem to develop either on OS X or Linux. So Ruby on Windows isn't at the maturity that ActiveState perl is on Windows. In fact, I don't even run native perl anymore on my MacBook Pro. I've switched over to ActiveState perl because I don't need to compile anything every time I want to install new CPAN libraries. And because it's ActiveState, I'm that much more confident it will w

Thoughts on the iPad

There are many, many posts on the iPad already. I was quite surprised about the intensity of the debate of its merits, or lack thereof. I've had my iPad for about 5 months now, and I love it. I preordered it and got it on April 30. Since then it has subtly become part of my daily routine. Here is a list of my uses for it, ordered from most frequent to less frequent: Reading books iBooks GoodReader Bible E-mail Looking at RSS feeds Watching movies Games I thought it would be interesting to put together a "collage" of interesting blog posts about the iPad. Here is an analysis of the fact that the iPad is considered to be nothing new. Its critics seize this as a point of weakness but in reality it is probably a point of strength: Instead of praising the iPad, critics express their disappointment, because they expected more. They expected a genre buster. They expected something they’d never seen before, something beyond their imagination. Something revolutionary.

Converting string to unique integer in perl

I'm writing some perl code for a project I'm working on. One of my needs is to convert a string into a 32-bit integer. The catch is that the conversion must be deterministic (i.e. a hash function). I looked at using CRC32 but the resulting integer wasn't always the same each time. I looked at using MD5, but MD5 produces a very long hex string that will overflow a 32-bit integer. I decided to do something a bit weird; because a 32 bit integer has up to 4,294,967,295 values (signed), I could take the first 8 characters in the MD5 value and then convert any of the letters to a corresponding number. So the function looks like this in perl: sub convert_string # Function to convert string into a unique 32-bit integer { my ($str) = @_; my $md5str = md5_hex($str); my $md5strsub = substr $md5str, 0, 8; $md5strsub =~ tr/a-f/1-6/; return $md5strsub; }

Relevance of "Social Studies" as a college major to product management

Whenever people ask me what I majored in at college, I always hesitate a bit before answering. The real answer is  Social Studies , though I typically don't give this answer anymore. People would either give me a puzzled look or a snide comment, such as "Oh, I took that in 5th grade." So I started answering that I majored in sociology. Not many people really know what sociology is either, but at least it doesn't sound like a 5th grade subject. Here's a good explanation  of what the Social Studies program is about: Social Studies is a unique program of study at Harvard College. ...It reflects the belief that the study of the social world requires an integration of the disciplines of history and political science, sociology and economics, anthropology and philosophy. Concerned with the fragmentation caused by increasing disciplinary specialization, the faculty and students of Social Studies seek an integrated approach to the study of social phenomena that synthes

Measuring memory per Unix process

Wow, it's been a long time since I've written anything here. Since my last blog post, I've been taking two classes (in two very different topics), along with the other daily responsibilities of working, raising two children, etc. For a work-related requirement, I had to figure out how to measure memory consumed by a specific Unix/Linux process. This is more difficult than it may seem. For one thing, apparently the memory statistics given by Linux are meaningless. This is mainly because the ps command (and the VSZ metric specifically) only lists the size of the address space referenced by a process, not the actual memory size itself. This page suggests the use of smaps, where /proc/$pid/smaps provides the actual amount of memory used by a process. Because the output of smaps is pretty lengthy, Someone wrote a python script called to make the output more understandable. The main issue is that smaps only exists in Linux, and I had a requirement to measu