Archive for 2005

Posted on November 17, 2005 at 5:56 pm

Yeah, I know. But hey, sometimes you gotta live on the edge.

If you don’t already have ODBC talking to MS SQL Server on your Mac, you’ll need to get that set up and tested first.

We need a couple of extra pieces of software to let Rails talk to the server via ODBC.

Ruby-ODBC:

cd /tmp
wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.996.tar.gz
tar vxzf ruby-odbc-0.996.tar.gz
cd ruby-odbc-0.996
ruby extconf.rb
make
sudo make install

Ruby DBI ODBC driver:

cd /tmp
wget http://rubyforge.org/frs/download.php/655/ruby-dbi-all-0.0.23.tar.gz
tar vxzf ruby-dbi-all-0.0.23.tar.gz
cd ruby-dbi-all
ruby setup.rb config --with=dbi,dbd_odbc
ruby setup.rb setup
sudo ruby setup.rb install

The format of the database.yml will be slightly different than the norm:

development:
  adapter: sqlserver
  mode: odbc
  dsn:  the_dsn_you_created_and_tested_in_iodbc_administrator
  username: username
  password: password

There is currently a bug in script/console that will throw a BUS error when trying to access the database, but everything works outside of the console.

You should also be aware that SQL Server isn’t currently supported very well in Rails. I ran into a couple of bugs today and submitted patches for them:

Posted on at 5:38 pm

Getting ODBC working on OS X is pretty easy, but you’ll have to find the damn drivers first. First grab the newest iODBC SDK from the Software Availability page, and then grab the the Universal Data Access Drivers from the OpenLink download page. Install the SDK first, and then the drivers.

Once you’ve installed both of those packages you will have a new iODBC Administrator program in your Applications/Utilities/ directory. Open it up and add a System DSN just as you would on a Windows machine.

Posted on November 10, 2005 at 2:44 pm

I bought a copy of Better Than Ezra’s latest CD on iTunes this morning. It’s a great album and is much closer in style to their first album Closer, than to their last couple. I’ve always loved Better Than Ezra and I still remember singing along at the top of my lungs to Rosalia when they played at the Salem Amphitheater. Good music makes me happy.

Posted on November 7, 2005 at 3:56 pm

I cobbled together a “what I’m listening toâ€? page in about 20 minutes over lunch. It shows the 10 most recent songs I’ve listened to in iTunes. It’s “mostlyâ€? live data. It refreshes every 15 minutes or so.

Posted on November 3, 2005 at 4:28 pm

Want to churn through Microsoft Exchange logs for some statistics? Here’s a few short programs you can use.

Count of inbound SMTP messages:

puts File.open('20051103.log').grep(/^([^\t]+\t){8}1019/).size

Count of outbound SMTP messages:

puts File.open('20051103.log').grep(/^([^\t]+\t){8}1031/).size

Count of locally delivered messages:

puts File.open('20051103.log').grep(/^([^\t]+\t){8}1023/).size

Count of inbound SMTP messages from a bunch of log files:

counts = Array.new
Dir.glob('*.log')  do |f|
  counts < < File.open(f).grep(/^([^\t]+\t){8}1019/).size
end
puts counts.inject {|count,n| count + n}

Try my full Exchange log parser if you want something more robust. And don’t laugh. It was my very first Ruby program.