Tuesday, March 28, 2006

Rails 1.1 and MS SQL Server

This patch is an update for Rails 1.1 to these changes that force lowercase the column names in MS SQL databases: Patch with:

patch /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/sqlserver_adapter.rb 
patchfile contents:
246c246
< sql = "SELECT LOWER(COLUMN_NAME) as colname, COLUMN_DEFAULT as defaultvalue, DATA_TYPE as coltype, IS_NULLABLE As isnullable, COL_LENGTH('#{table_name}', COLUMN_NAME) as length, COLUMNPROPERTY(OBJECT_ID('#{table_name}'), COLUMN_NAME, 'IsIdentity') as isidentity, NUMERIC_SCALE as scale FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '#{table_name}'">         sql = "SELECT COLUMN_NAME as ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType, IS_NULLABLE As IsNullable, COL_LENGTH('#{table_name}', COLUMN_NAME) as Length, COLUMNPROPERTY(OBJECT_ID('#{table_name}'), COLUMN_NAME, 'IsIdentity') as IsIdentity, NUMERIC_SCALE as Scale FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '#{table_name}'"
254,258c254,258
< default =" field[:defaultvalue].to_s.gsub!(/[()\']/," type = "#{field[:coltype]}(#{field[:length]})" is_identity =" field[:isidentity]" is_nullable =" field[:isnullable]">           default = field[:DefaultValue].to_s.gsub!(/[()\']/,"") =~ /null/ ? nil : field[:DefaultValue]
>           type = "#{field[:ColType]}(#{field[:Length]})"
>           is_identity = field[:IsIdentity] == 1
>           is_nullable = field[:IsNullable] == 'YES'
>           columns <<>             id_value || select_one("SELECT @@IDENTITY AS Ident")["Ident"]
300c300
< retval =" select_one(">             retVal = select_one("SELECT @@ROWCOUNT AS AffectedRows")["AffectedRows"]
366c366
< total_rows =" @connection.select_all(">           total_rows = @connection.select_all("SELECT count(*) as TotalRows from (#{sql.gsub(/\bSELECT\b/i, "SELECT TOP 1000000000")}) tally")[0][:TotalRows].to_i
489,490c489,490
<>                 record[col] = row[col]
>                 record[col] = record[col].to_time if record[col].is_a? DBI::Timestamp

Thursday, March 23, 2006

More Rails 'Premature end of script headers: dispatch.fcgi' errors...

This is a real killer that has bitten me now two times. The first time I wrote about earlier was caused by Firefox's inaccurate session handling. The second time was just as confusing. The presentation was identical--no log messages except for: ==> /home/deploy/logs/access_log <== XX.X.XX.XX - - [24/Mar/2006:01:23:07 -0500] "GET / HTTP/1.1" 500 68 ==> /home/deploy/logs/error_log <== [Fri Mar 24 01:23:07 2006] [error] [client XX.X.XX.XX] Premature end of script headers: dispatch.cgi The system ran fine in WEBrick and in console mode (in both development and production modes); however, dispatch.fcgi continued to err. I also switched to dispatch.cgi (non FastCGI process) and saw the same errors. What was the problem?
Well--I deploy my projects through Switchtower (which is now Capstrano). I had diligently updated my local and staging servers to Capistrano, but on the deployment server I was still running the Switchtower gem. I remembered to check this--saw it was out of date--and after a 'gem install capistrano' all was well.

Sunday, March 12, 2006

TextMate + TextMate Rails Bundle is a must-have

Before my MacBook Pro arrived, I was most productive in console/vi development. Seeing the Ruby on Rails screencasts shot using TextMate encouraged me to try it out. I've been using it occasionally, but ran into this Rails Bundle over the weekend. I just edited a view with 3 partials, and the ctrl+shift+quote option (which expands all partials for inline editing)--faster than I could have in vi. This is a must-have for any Mac Rails developers. By the way--the SwitchTower->Capistrano change last week went seamless. Just followed the directions.

Wednesday, March 08, 2006

Can FrontRow remote be disabled? -- Yes it can... see my comment post.

In the big picture I shouldn't be complaining about this, but since purchasing both a MacBook Pro and a mac mini, I have an annoying problem of my FrontRow remote controlling both machines simultaneously. That is, both the mac mini and the MacBook Pro came with those killer 6 button FrontRow remotes, but either remote works on either system. That means when I am trying to work on my MacBook and my wife hits the FrontRow menu to watch Harry Potter--my MacBook goes FrontRow mode as well (the IR sensors are very sensitive--so this is a problem even when not in direct line-of-sight). Being a Mac neophyte, I am not entirely sure where to look for a "disable remote" control panel--I checked the system preferences with no luck, and could only find this cryptic (to me) post on modifying a bundle file. Anyone have a suggestion on how to do this? By the way--I know that my intel Mac Mini/MacBook Pro adoption is bleeding edge and there are things that are not quite ideal (like this remote issue and others which if they continue to bother me will show up in my blog too)--but I am 100% convinced that Apple's approach will lead to success. Just getting into my living room and making things like sharing media (and printers for that matter) so simple that all of my family can use it is something that no other computer manufacturer has been able to do.

Sunday, March 05, 2006

Darwine Running Notepad...

I downloaded the official Darwine release, but it won't run out of the box. I found this build from CVS that did the trick. My goal is to run Microsoft Project, Microsoft Money, and a few choice apps, but in the meantime check out my MacBook Pro running Notepad:

Mac OS X Intel Firefox...

I just found the OS X Intel build of FireFox and it is a stellar speed increase on my MacBo ok Pro.

Saturday, March 04, 2006

Mac Mini Dual Core

I couldn't resist--I'm replacing my amazingly-slow-to-change-discs Sony 5-disc DVD player with an Intel Mac Mini. My video setup is now:

  • Sony KDL-V40XBR1 -- A terrific 40" 1366x768 LCD screen
  • Mac Mini -- For DVDs, iTunes programs, and Front Row use in general
  • TBD -- a 5.1 surround system...
We've been cable-free--thanks more to my inability to stop watching than to avoid commercials--for about 10 years. Lately we've been buying DVDs of programming like Sex in the City (my wife's favorite) and Curb Your Enthusiasm (my favorite). But thanks to Apple we are now Platinum members of the iTunes store and especially their TV shows for purchase. I am hoping that Steve J completes my new A/V setup by rolling out HD movies soon.

Vonage not ready to support UT Starcom

I've been a Vonage subscriber since early 2004. They provide a great technology and their suite of features (call forwarding, simultaneous ring, and softphone) cover my needs well. That said, a week ago I purchased an additional Vonage line and their UT Starcom WiFi enabled wireless phone and have yet to get the device working. A little context here--I run a technology company, I am a Ph.D. fellow in computer science--if there were anyone well qualified to setup a consumer-oriented WiFi phone, it would be me. I am attempting to use the phone at home where my network is pretty simple:

  • Cox Communications -- provides my high speed data through their provided cable modem
  • Apple Airport Extreme -- directly connected to the cable modem. Configured to its default 10.0.1.1 IP address. Using WPA2-Personal security.
I followed the settings in the UT Starcom User Guide and the Installation Guide to configure my access point and security settings into the phone. This was straightforward and encouraging; however, after finishing the guide the phone's screen was stuck at "Registering Via Extreme"--the step before being ready for calls. In the manual there is mention of "Provisioning" when this occurs--but that provisioning is only needed when buying the phone from a 3rd party retailer rather than direct from Vonage (which I had). I gave Vonage support a ring to help diagnose and got put on hold for 30 minutes and then the call dropped. I called back and got through after about 10 minutes to a frontline support rep who immediately referred me to "2nd tier" support. Another 10 minutes and I had someone very helpful on the phone who knew almost nothing about the phone, or networking in general. My goals for the call were (1) to confirm that there wasn't a "provision" flag waiting to be set on my account and (2) see if I needed to forward ports to the device--since the manual was suspiciously silent in this regard. The rep said my account was ready to go and that no port forwarding was necessary. He then related an experience by a co-worker who brought the phone home and had it just start working ready for calls without any configuration. Unfortunately, this anecdote did little to help my needs. I continued to ask questions to see if I could determine any differences between my network and the "expected" configuration, but the tech was unable to offer any guidance whatsoever for my situation. Nearing 30 minutes on the phone, the line cutoff--prompting me to wonder if Vonage randomly cuts-out support calls after they reach 30 minutes. After the phone call I ran some google searches to see about anybody with similar problems and found remarkably little at all about people using the phone. I did see some suggest ports to forward, and added them to the Airport configuration. These did not affect the phone troubles. In a final effort I swapped out the Airport (TWICE!) with a LinkSYS WRT54G and an SMC base station both with no security and neither got the phone up and running. I now have reached the limit of my time/frustration with the device and it will remain a paperweight until somebody gets the device working on their network and is nice enough to post their configuration. Anybody out there have success?

Wednesday, March 01, 2006

Finalizing my Ruby on Rails install...

My Rails projects require the newest sqlite3 and sqlite3 properly setup alongside Rails. To complete this final step, I compiled the latest sqlite3:

  1. Downloaded the latest sqlite3 source.
  2. tar xvzf sqlite-3.3.4.tar.gz
  3. cd sqlite-3.3.4
  4. ./configure --prefix=/usr/local --disable-tcl
  5. make
  6. sudo make install
AND I installed the sqlite3 gem:
sudo gem install sqlite3-ruby Password: Attempting local installation of 'sqlite3-ruby' Local gem file not found: sqlite3-ruby*.gem Attempting remote installation of 'sqlite3-ruby' Select which gem to install for your platform (i686-darwin8.5.2) 1. sqlite3-ruby 1.1.0 (mswin32) 2. sqlite3-ruby 1.1.0 (ruby) 3. sqlite3-ruby 1.0.1 (ruby) 4. sqlite3-ruby 1.0.1 (mswin32) 5. sqlite3-ruby 1.0.0 (mswin32) 6. sqlite3-ruby 1.0.0 (ruby) 7. sqlite3-ruby 0.9.0 (ruby) 8. sqlite3-ruby 0.9.0 (mswin32) 9. sqlite3-ruby 0.6.0 (ruby) 10. sqlite3-ruby 0.5.0 (ruby) 11. Cancel installation > 2 Building native extensions. This could take a while... ruby extconf.rb install sqlite3-ruby checking for sqlite3.h... yes checking for sqlite3_open() in -lsqlite3... yes creating Makefile make make: Nothing to be done for `all'. make install make: Nothing to be done for `install'. Successfully installed sqlite3-ruby-1.1.0 Installing RDoc documentation for sqlite3-ruby-1.1.0... lib/sqlite3/database.rb:637:65: Skipping require of dynamic string: "sqlite3/driver/#{driver.to_s.downcase}/driver" lib/sqlite3/database.rb:642:59: Skipping require of dynamic string: "sqlite3/driver/#{d.downcase}/driver"
Thanks again to Dan Benjamin and his article on why /usr/local is the right place to install user-built apps on OS X.

MacBook Pro Arrives!

I'm happily typing away on my MacBook Pro. It has 2GB of RAM, a SATA hard disk and it flies. Since I am heavily developing on Ruby on Rails, my first real work on the machine was to follow Dan Benjamin's excellent Intel Mac Ruby on Rails Install guide. A little side-note. I was surprised to see on the FedEx tracking guide for my order that the origination location for FedEx was in Shanghai, China (then to Anchorage, Alaska; Indianapolis, IN, then LA). Apple must have one slick order fulfillment system to slate my system pre-configured straight from their factory in China. Is this what all vendors (Dell, etc) are doing now? If so, I've missed this trend completely.