Archive for September, 2010

September 28th, 2010

Connecting Ruby to Microsoft SQLServer

by Tim Cull

There are many excellent posts out there about how to connect Ruby to Microsoft SQLServer. The problem I had is that none of them actually worked for me! So, I’m going to add my list of instructions to the noise in hopes it helps someone out there

The Setup

I’m using Windows 7 32-bit. The Ruby I have installed I got from http://rubyforge.org/frs/download.php/72075/rubyinstaller-1.9.1-p430.exe and looks like this:

ruby -v
ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Secondly, and this is very important, I have DevKit installed. I downloaded http://github.com/downloads/oneclick/rubyinstaller/DevKit-4.5.0-20100819-1536-sfx.exe and installed it according to the instructions on the DevKit wiki. Many of the tutorials out there neglect to mention that you must have DevKit installed in order to install some of the gems required.

The instructions I’m giving you here only work with *exactly* the setup I described. If you have a slightly different setup then this might not work. It’s very finicky. Even having a different one click installer can make it not work.

Step By Step From a Fresh Ruby Install

I installed my ruby to d:\Ruby191 with the one click installer. Then I extracted DevKit to d:\Ruby191\devkit and ran:


cd d:\Ruby191\devkit
ruby dk.rb init
ruby dk.rb review
ruby dk.rb install

When running “ruby dk.rb review” make sure it says it’s pointing to your Ruby install.
Next I downloaded dbi-0.4.3.gem, dbd-odbc-0.2.5.gem and ruby-odbc-0.99992.gem to my local file system.

Next, I ran exactly these commands. The versions and extra arguments matter!

set RUBY_HOME=D:\Ruby191
set LIBS=..\..\libs\ruby
gem install rake
gem install rubygems-update
gem install --include-dependencies rails
gem install deprecated --version=2.0.0 @rem the version matters. get exactly this one
gem install --local %LIBS%\dbi-0.4.3.gem
gem install --local %LIBS%\dbd-odbc-0.2.5.gem
gem install --local %LIBS%\ruby-odbc-0.99992.gem @rem this requires devkit

Lastly, I wrote this sanity check script and it worked:

require 'dbi'

# Replace MY_DSN with the name of your ODBC data
# source. Replace and dbusername with dbpassword with
# your database login name and password.
DBI.connect('dbi:ODBC:MY_DSN_NAME', 'username', 'password') do | dbh |
# Replace mytable with the name of a table in your database.
p "selecting getdate"
dbh.select_all('select getdate()') do | row |
p row
end
p "done"
end

So that’s it. Another of the many tutorials out there that will work on exactly one setup and probably not much more. Have fun!

September 11th, 2010

It’s Official: I’m an InfoQ Editor Now

by Tim Cull

I’m pleased to announce I’ve got a side gig, writing the latest and greatest Java news over at InfoQ. It all started with my “8 tips for legacy Java code” article, after which they asked me to write regularly for them: one quick news post a week.

So, if you’ve got some Java news you think the rest of the world will be interested in, please let me know. Introductions to people I can interview are even better!

September 10th, 2010

Quick Props for a Fantastic User Experience: Xdebug

by Tim Cull

I just had one of the best user experiences ever trying to install Xdebug for PHP.

Get this: you paste information about your installation using the extremely common “phpinfo()” function and the website parses the free-text output and tells you:

  1. Exactly what to download and from where
  2. Exactly what to put in which configuration file with paths tailored to your setup and, here’s what kills me…
  3. Exactly where that config file is on your file system

Now that’s looking at things from your user’s point of view.

September 9th, 2010

Overdue: Apple Relaxes Restrictions on Developer Tools

by Tim Cull

Apple has finally removed the self-destructive restrictions they put on developer tools. I couldn’t believe they’d do that in the first place and it’s good to see they saw the light. The question is: is it too late? I for one vowed to choose Android over iPhone when I had the option and lifting the restrictions now hasn’t really changed that inclination.

September 1st, 2010

The little known and underappreciated HTML Header element

by Tim Cull

I happened across an HTML element I didn’t know existed today. The ‘header‘, which is not to be confused with the ‘head‘ element, is a section of the HTML body that can contain, you guessed it, header information like a table of contents or some titles. It’s been supported by browsers for ages, including IE6.

I just figured I’d post something about this under-appreciated element here to boost its Google recognition a smidgen and separate it from its better-known, more-popular-at-parties cousin: the ‘head’.