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

Saturday, November 12, 2011

Sample Routes and Links with Rails 3 in the console

The content for this post is all from a gist, hopefully someone finds it useful




Resources


Wednesday, November 9, 2011

Postgres: get the number of days in an interval

-- seconds / 60 = minutes / 60 = hours / 24 = days
select (((EXTRACT(EPOCH FROM INTERVAL '2 years') / 60) / 60) / 24)::integer as number_of_days 

good resource - http://stackoverflow.com/questions/952493/how-do-i-convert-an-interval-into-a-number-of-hours-with-postgres

Saturday, October 15, 2011

Generating barcodes with ruby and rails

Recently I had to convert some functionality from an old MS Access system to a Ruby on Rails application. The Access system generated a report that included a barcode; they were using a barcode font installed on the machine running access. I figured generating the barcode server side in the web app was going to be much nicer than installing barcode fonts on the client browsers. And since this is Ruby, I figured...
There must be a gem for that 
Sure enough, the barby gem. It allows you to output your barcode as png, gif, svg, pdf, etc...

In my case I generated png barcodes and included image references to those in my view files.

Sample code




There is no pixel setting, it uses some other type of unit to determine size; using the xdim, margin and height options you can tweak the size, but I found that it was not very precise - for my use case it was good enough.

The generated barcode does not include the value, it is just the image which can be scanned using a barcode scanner, but it would be nice if there was an option to include the value below that. This is somewhat trivial to add in your view using html.

Overall I was really pleased with this gem!

Resources

Sunday, September 18, 2011

Monday, August 22, 2011

CoffeeScript with Rails 2.3 and Rails 3.0

I just uploaded a sample application that uses guard, coffee-script and a rake task to enable use of coffee-script with a rails 2.3 or 3.0 application. Check out the README file on github for details.

https://github.com/house9/with_coffee


Friday, July 8, 2011

Grow vegetables go to jail?

Oak Park resident Julie Bass now faces serious charges for setting up a vegetable garden in her front yard.

Help her out sign the petition here: http://www.thepetitionsite.com/1/oak-park-hates-veggies/


We are requesting that the City of Oak Park, MI cease its prosecution against its resident Julie Bass for the supposed crime of growing vegetables in her front yard. The bylaw they are pursuing criminal charges under is poorly written and does not explicitly state that you cannot grow vegetables. The prosecutor representing the city wants to take this case to trial, and the associated charge carries a maximum sentence of 93 days in jail. It would be a travesty for this mother of six to be sentenced to 93 days in jail for the simple act of growing tomatoes in her front yard.

Details about the case can be found at http://oakparkhatesveggies.wordpress.com/