The blog has moved to ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Wednesday, December 9, 2009

imeem acquired by myspace - bummer

nothing else to say really, imeem was a great service

I've never liked myspace

Thursday, November 12, 2009

Heroku - HTTP 502 Error

This might be helpful to someone?

I was receiving 'App Failed To Respond (HTTP 502) Bad Gateway' errors when deploying my application on Heroku. Reading the error codes page did not help me solve the problem, it took awhile but I was finally able to track it down.

The error was being generated in the browser but checking the rails logs, the requests were returning HTTP 200 success codes, so the problem was being generated at the web server level on the Heroku stack.

Turns out the problem was caused by setting response.header for no browser caching. I was using code similar to this post. Everything worked fine after I removed this line

  • response.headers["Expires"] = 0

Heroku - sending email with Gmail

I have been working on deploying a Rails application to Heroku. A couple of gotchas I ran into when following this post "Sending email with Gmail"

  • Don't use a dollar sign ($) in your password 
  • this can work locally if you put single quotes around the value, but on the heroku server it saved the entire string but at runtime would truncate it at the dollar sign
  • for example using the password 'left-side$right-side'
  • heroku config:add GMAIL_SMTP_PASSWORD=left-side$right-side
  • heroku config returns > GMAIL_SMTP_PASSWORD=left-side$right-side
  • heroku console 
  • type ENV['GMAIL_SMTP_PASSWORD'] returns > left-side

Heroku is running Ruby 1.8.6, locally I am running Ruby 1.8.7, I made a small hack to the plugin to avoid errors in development mode

changed the first line to
require 'smtp_tls' if RUBY_VERSION < "1.8.7" 

tls is already handled in 1.8.7 and this code must have been creating some type of conflict

Sunday, October 25, 2009

imeem on 64-bit ubuntu

Getting flash to work correctly on 64-bit Ubuntu can be challenging. By following various blog and forum posts I was able to get it to work, but never the flash player for imeem. Every now and again I would try to re-install flash and see if it would work for imeem but until last night I was never successful. 

It turns out that imeem will only work with the 32-bit flash player. After so much work to get the 64-bit player working in Firefox 3.0 and 3.5 I did not want to remove it so I downloaded Opera and installed the 32-bit player under its plugin directory and imeem works great!

  • Download and install Opera
  • verify that you cannot play music in imeem
  • Close Opera
  • download the 32-bit flash player in '.tar.gz' format
  • extract the file from the archive
  • then you will need to put this in the directory /usr/lib/opera/plugins/
  • you won't have permissions to write to that directory unless you are in sudo mode
  • open a terminal and type 'sudo nautilus'
  • copy the file into the directory (you could do this from the terminal window also probably 'sudo mv /usr/lib/opera/plugins/'
  • Open Opera
  • check the plugins - type opera:plugins in the address bar
  • you should see Shockwave Flash and it should be pointing to the file under opera plugins, by default my opera installation was pointing to /usr/lib/mozilla/plugins/ for the flash plugin, my guess is opera looks for plugins in its own directory and if not found then looks in mozilla directory
  • you should now be able to play music with imeem!

I am running Ubuntu 9.04 Jaunty Jackalope by the way. Here are some links that might work to get the 64-bit player working for Firefox

Saturday, October 24, 2009

Factory Girl makes rails testing so much easier

Factory Girl makes rails testing so much easier. I watched a Railscasts on Factory Girl recently but had been putting off trying it out until last week. Glad I gave it a try - now I can say good-bye to fixtures and just write my tests!

Factory Girl is developed by thoughbot; they have some great open source projects, check out Shoulda to make your rails testing even easier.

Saturday, October 17, 2009

convert mkv files to dvd with ubuntu

Turns out there is a great program for this - my guess is it works well with other formats such as avi, mpeg, etc...

DeVeDe, if you are running 9.04 (jaunty) or higher it is in the repositories

System -> Administration -> Synaptic Package Manager

enter 'devede' in the search and then install

Friday, September 25, 2009

Attribute "target" exists, but can not be used for this element.

These days I am all about valid xhtml and was surprised to receive this validation error when using the target attribute on an anchor tag.
Attribute "target" exists, but can not be used for this element.

I found a nice work around that does not involve, using jquery we can hack the attribute on 'after' the dom has loaded.

Now instead of target='_blank' you can just use class='target-blank', if the browser does not support javascript it will not open in a new window but the link will still work - and we have our valid xhtml.


Wednesday, September 2, 2009

Procedure sp_droplogin, Line 93 Login is aliased or mapped to a user in one or more database(s)

Trying to remove a MSSQL login from a database server, recieve the following eror

Msg 15175, Level 16, State 1, Procedure sp_droplogin, Line 93
Login 'qa' is aliased or mapped to a user in one or more database(s). Drop the user or alias before dropping the login.

Solution: run this command to determine what alias or groups the login is associated with and then remove those; might be nice if they just added this to the error message?

sp_helpuser 'qa'

Sunday, August 23, 2009

scrolling screen shot on ubuntu

I've been using ubuntu for the last 6 months, really like it! But also really missing SnagIt :(

so far I have come across these screen shot tools

  • built in 'save screen' program - read this post for info about that and others
  • Shutter

but none that I came across would do scrolling screen shots; currently I only needed scrolling screen shots of web pages and I just came across a great tool for that - a firefox add-on called Abduction, it is really easy to use.

For full page screen shots (including all scrollable regions) or for cropped sections of a page. Just right click on the page and select 'Save Page as Image', if you are over an 'element' it will auto select that as the cropped area, you can then adjust the crop and save, if you want the entire page the easiest seems to be right clicking where there are no elements below the mouse and then adjust the fully selected page as needed

The saved png can then be opened in Shutter for applying arrows, boxes, etc...

Friday, August 21, 2009

Ajax error handling with ruby on rails and jquery

This sample is just a slight modification of this post 'Handling AJAX errors and displaying friendly error messages to users'. Basically I wanted to maintain the existing rails error handling for non-ajax pages and then have good handling for errors in both development and production mode; i.e. get errors in the browser when in development mode and show a nice message when in production mode.

Modify /app/controllers/application.rb; add the rescue_from macro and the handler_exception method

Then add a global javascript method for presenting the errors; most likely in application.js

Then a sample usage, jquery making an ajax post to a rails controller action

in development mode the error message is returned in an easier to read view in the firebug console and an alert message is presented that has a truncated version of the error

dev mode

in production mode just a friendly error message.

production mode


Tuesday, August 4, 2009

Get list of MSSQL jobs that are currently running

The following sql statement will return information about the currently executing MSSQL jobs.
Run it against the msdb database

Saturday, July 18, 2009

replace keyboard on Sony Vaio laptop PCG-K23 (PCG-9RLF)

just replaced the keyboard on my sisters Sony Vaio laptop - on the bottom is says it is a PCG-9RLF, but then it also says it is a PCG-K23? anyhow I had a hard time finding anything on the web, then I finally stumbled on this page which helped alot
  • You don't need to loosen any screws on the bottom - I thought this would be needed and ended up wasting a bit of time going in the wrong direction.
  • At the top of the keyboard is a plate that you need to pry up, there are 4 slots you can stick a flat screw driver under (you can't see them unless you press the keys down), this plate is also part of the screen hinge and the power cord that goes to the screen is attached so be CAREFUL!
  • Then there are 3 screws that hold the keyboard in place, loosen those
  • The keyboard will hinge up from the bottom
  • Then you need to disconnect the cable that goes to the motherboard
  • I ended up pulling this out without much effort
  • but then it was really hard to get the new one back in
  • turns out the slot has an open / closed 'mode', using a small screw driver I was able to get it to open up
  • Then just put everything back, turned out to be relatively easy in the end, I am definitely not an expert when it comes to computer hardware but so far this has been a success!

Saturday, June 27, 2009

Frontair Congress, Barcelona Spain

Alberedes 16
Sant Boi de Llobregat, Barcelona 08830

We ended up staying here our last night because it was 'close' to the airport and included a free shuttle to the airport. But since we were traveling by train and bus it was not so easy to get here the night before. If I was going to do it again I would stay somewhere closer to a metro stop near 'downtown'; there are trains running direct to the airport all the time.

They did have an indoor pool.

View Larger Map

Husa Imperial Tarraco, Tarragona Spain

Paseo De Las Palmeras, S/n
Tarragona, TA 43003

Great hotel. if you stay here I recommend spending extra for a room with a sea view!

View Larger Map

Hotel Costabella (Sercotel), Girona Spain

Avinguda De Franca 61 Sant Ponc
Girona, GI 17007

View Larger Map

The hotel is right across the street from the hospital - north of the old town. They have a great pool.

Medplaya Aparthotel Esmeraldas, Tossa de Mar Spain

Calle Vilafranca del Pened├ęs s/n,
Costa Brava
Tossa de Mar, Girona 17320

Great town! and this was a perfect place to stay, very inexpensive, functional not fancy

View Larger Map

The hotel is not near the beach but the walk is very enjoyable, probably 10 minutes or so.

Hotel Front Maritim, Barcelona Spain

Paseo Garcia Faria 69
Barcelona 08019

View Larger Map

This was a really nice hotel. It is a bit far from the 'downtown' areas but really close to a really nice beach!

It is 4 blocks from the 'Selva de Mar' metro stop. If you are coming from the airport take a metro to 'Passeig de Gracia' and then get on the line to 'La Pau', the Selva stop is 4th to the last stop.



There is also a stop near the hotel on the red tourist bus route; a nice day out to grab the bus and see the sights of town and then get dropped off right out side the hotel.

There is an awesome place to eat two blocks from the hotel Els Peixaters de la Mediterrania. They have great tapas and we ate dinner there one night - one of the best I have ever had!

The beach was crowded on a very warm Sunday - there were not too many people on the weekdays.



We just returned from 2 weeks in Spain (Catalonia really). One of the best vacations ever! Great food, great beaches and great history and culture!

below are some links to hotels we stayed at, might be of use to someone?

Saturday, May 30, 2009

Secure your Gmail

yeah - you DO want to run gmail over https; I am surprised this is not the default and I am surprised I did not already have this setting turned on.

In gmail click the settings link in the upper right hand corner

Then scroll to the bottom and select 'Always use https' in the Browser connection section
This came up while I was watching a great screen cast 'Security - What rails will and won't do for you', it was from 'Scotland On Rails Presentations', there are 27 different presentations and all downloadable

Saturday, May 9, 2009

PGError: ERROR: duplicate key value violates unique constraint "tablename_pkey"

Using Postgresql I ran into the following error when trying to create a new record through my rails application

  • PGError: ERROR: duplicate key value violates unique constraint "tablename_pkey"

Found this link which had the needed fix;

Dealing with 'duplicate key violates unique constraint' on the primary key

apparently with Postgresql after bulk loading records where the auto incrementing id is specified you then need to update the sequence value

Sunday, May 3, 2009

bash scirpt to launch rails development environment

here is a bash script I put together to launch my rails development environment, i got tired of opening multiple terminal windows and cd to the project dir, this script
  • launches script/server in a terminal window
  • launches a new terminal and cd to the trunk
  • launches firefox at http://localhost:3000 with a specific firefox profile
  • and launches Komodo Edit - go ahead and pick the editor of your choice
this works on Ubuntu, probably on other Linux distro's that use Gnome

I saved this in a file ~/scripts/
to execute this open a terminal and type ~$ bash ./scripts/
or create a symlink in your home directory

then execute using ~$ bash launch_YOUR_PROJECT

NOTE: in theory you should not need to even specify bash at the command prompt, when I did not I received the following error "bash: launch_YOUR_PROJECT: command not found"
running 'which bash' returns '/bin/bash' which is specified in the shell script?, something to look into later.

Saturday, April 25, 2009

Strange behavior with Rails find_or_initialize_by_id and Postgresql

The following code sample worked as I would expect when using MySql database - when the :widget_id is 0 it creates a new record with an id of 1; but after switching to Postgresql it was inserting a record into the database with an id of 0 (zero)?

Note: params[:widget_id] does have a value of 0 (zero) when I want to generate a new record vs an actual value when doing an edit. This is a non-standard rails form, I did not experience any issues with a standard new/create view/action scenario.

Thursday, April 23, 2009

PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xa7 (ActiveRecord::StatementInvalid)

Now that Oracle is buying Sun I am switching from MySql to Postgresql

Ran into the following error with my rails application after switching over

PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xa7 (ActiveRecord::StatementInvalid)
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".
Found a work-around, check it out here

PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xa7 (ActiveRecord::StatementInvalid)

Working on a rails application and have decided to make the switch from MySql to Postgresql; ran into a few minor issues along the way and one really annoying and unexpected issue

PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xa7 (ActiveRecord::StatementInvalid)
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

The above error was being generated when I was trying to save model objects that had their string and text attributes assigned from data that had been scrapped using http with scRUBYt. After searching on Google the only 'work-around' I found was to use base64 encode and decode when reading and writing to these model attributes / database columns

Given the following migration

Our model before and then after applying the work-around


Sunday, April 12, 2009

rails collection_select to prompt or include_blank?

Well I just wasted a bit of time but learned something in the end. When working with the rails form helper collection_select you might be interested in the difference between the prompt option and include_blank? option

include_blank will always create an option tag, prompt will only create an option tag when creating a new record - in most cases I prefer include_blank

both take either a boolean or a string, if true is passed then include_blank will create an option with no display text and prompt defaults to the display text of 'Please Select'
{:prompt => true}

{:include_blank => 'Please Select'}
both of these result in the same html, but the first one will not include the 'Please Select' option when you return to edit the previously created Product

See also

Saturday, April 11, 2009

accesskey attribute on the select tag is not valid?

Was just running some validation on a html form and it failed with the following error
"Invalid markup: line 68: Attribute "accesskey" exists, but can not be used for this element."

From w3c spec - "The following elements support the accesskey attribute: A, AREA, BUTTON, INPUT, LABEL, and LEGEND, and TEXTAREA."

I have no idea why input and textarea would be supported but not select? this seems like a mistake? At least there is an easy work around - apply the accesskey attribute to the label tag that references the select menu.

Thursday, April 9, 2009

IE8 multiple cookies for the same site

Internet Explorer 8 is here - oh joy....

As a web application developer I spend a lot of time logging into sites as different users and prefer to be able to toggle back and forth between multiple instances of a browser maintaining the separate sessions in each instance. With IE 7 this was not an issue as long as IE was launched from the toolbar. In IE 8 sessions are shared by default, once again a Google search delivers the goods!

This post explains the -no-merge switch

as easy as Start -> Run -> iexplore.exe -nomerge

FireFox has a similar issue, but the only work around I know of with FireFox is to create separate profiles, see this post - FireFox and multiple cookies for the same site

'file version' is not in the normal '' format

At work we use TFS for source control and NAnt for building our application, yesterday our NAnt build started failing with the following error message "Assembly generation The version '' specified for the 'file version' is not in the normal '' format"

After a quick Google search it turns out that each segment in a .net assembly cannot be larger then 65534. We use the TFS changeset for the revision segment but this will no longer work for us as we are now beyond changeset 65534 - doh! As a work around we are now using only the last 4 digits of the changeset, so instead of we are using the version

this required a small change to the Nant build script
  • the update is here
  • and the original is here
this version constraint is documented here

UPDATE: NAnt build with TFS changeset as revision number

this is a small revision to a previous post NAnt build with TFS changeset as revision number

apparently there is a limitation on the size of the number used in each segment of a .net assembly version so this is a slight update to the c# code that gets the latest changeset from TFS - changes start at "if(latestChangsetId > 65534)"

see also AssemblyVersion - BuildNo Limitation

Thursday, March 26, 2009

Get Filenames and Database names from MSSQL

I was doing some clean up on one of our database servers; we have many databases created with backup/restore for testing purposes I was checking for the largest ldf files and making sure those databases were in simple mode and then shirking the data files, there were a few files I could not match to the databases because the mdf and ldf file names were different from the actual database file name - found the following queries using a few google searches

Thursday, March 12, 2009


My brothers latest band - Acephalix

Track 1 - Acephalix

Monday, March 2, 2009

jqueryUI effect error with Google Chrome and Safari

Ran into a strange issue using jqueryUI highlight effect, the issue only occurred with Webkit browsers (Google Chrome and Safari) and only when I was manipulating the background property of the element that was being highlighted.

Using a slightly modified version of the demo. I tweak the background image before applying the highlight effect

$("#highlight").click(function() {
$(this).css("background", "url(some_image.png) no-repeat");
This resulted in the highlight appearing but not going away. Then checking it in the debugger the following javascript error was being generated - "Uncaught TypeError: Cannot read property '0' of undefined," Changing the background manipulation to the following fixed the issue.

$(this).css("background-image", "url(some_image.png)");
$(this).css("background-repeat", "no-repeat");

Update 2009-03-06: You also need to make sure that if there is an existing style on the element being highlighted it is using the more verbose style tags of background-image and background-repeat or the same error will be encountered

Monday, February 16, 2009

use jquery to disable a button when clicked

jquery is such a great javascript library, the more I use it the more I like it

NOTE: the above code snippets are untested - cut, pasted and modified from real code that was tested (and worked!)


CSS position:relative + position:absolute

I do alright with css positioning but I just don't do enough css to have it mastered; anyhow I needed to float an image over into the right upper corner of a form, no problem put a div at the bottom of the form with position relative and top at -xyz. this worked but was not ideal, depending on the amount of fields in the form I would have to adjust the top setting for each, also the alignment was not consistent enough across browsers, so a google search was on once again...

Came across this great post, see tab 4 "position:relative + position:absolute", using a relative div with a nested absolute div, I did not even know this was possible but it appears to work great!

Wednesday, January 21, 2009

2009 Grasshopper Adventure Series

A really fast bike ride or is it a race? you choose

The schedule for 2009 Grasshopper Adventure Series is out!
  • 2009-02-28 Old Caz
  • 2009-03-07 Chileno Valley
  • 2009-04-11 Lake Sonoma 
  • 2009-05-09 King Ridge 
this year there is actually an entry fee - times they are achanging
read more here 

Saturday, January 17, 2009

Best binoculars for birding

Well the best binoculars for birding are probably Swarovski or Zeiss, but both of these are very expensive and if you want to get really close to the same quality but for a third of the price I highly recommend Savannah Phase-Coated Waterproof Binoculars from Orion. The Savannah comes in at less then $400 vs over $1000. 

Don't get me wrong, a good friend of mine has a pair of Swarovski and they are excellent! The key difference is in low light conditions the Swarovski do out perform the Orions but for most of the birding I do the Orions do the job and do it well. I have been using the 10x50 for over 4 years now and they are great for birding from the car, a smaller pair would be more ideal for hiking or other on the move activities.
Not sure why they name those two models differently they are both Phase-Coated and waterproof - they are the exactly the same just different size. Also, looking around on Orions site I do not see the 10x50 available anymore (one pair left over at Amazon)? hopefully they have not discontinued those. There is the Savannah Porro 10x50 but I am not familiar with that model, it appears to be less expensive and might be great buy for the money?

Friday, January 16, 2009

words to live by

this quote really grabbed my attention
from the NOOP.NL blog; an article called '5 easy Questions for Ron Jeffries'

...look for the good in every moment, and love it, while avoiding the bad without hating it.
 - Ron Jeffries

easier said then done but definitely a goal worth pursuing.

Wednesday, January 7, 2009

Coding Cheat Sheets

This is for personal reference: some links to helpful Cheat Sheets for coding

'Testing is Overrated' on InfoQ

This is a good presentation

just over 22 minutes and worth the watch; I had to take a screen capture of one of the slides about doing code reviews, just too funny