How To Export A MySQL Database to JSON, CSV and XML with Ruby and the ActiveRecord Gem
It's trivial to export data from a mysql database with Ruby and ActiveRecord. All you have to do is establish a connection and define a class that represents the table.
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_con...
Written by Sean Behan on 06/23/2012
PHP Headers for Sending CSV File Downloads
If you would like to force a file download prompt to the user, instead of just outputting the text to the browser, use the following headers.
...
Written by Sean Behan on 11/25/2017
Very Simple Breadcrumb Navigation in Rails with Before_filter
This may not be the ideal solution. This just manages request.referers in a session variable, then looping over each unique path prints a link to the screen. It's more of a "history" than a hierarchy for resources in an application. It is however, pretty ...
Written by Sean Behan on 06/17/2012
Hacking Rails Plugins
Using the Acts as Taggable On plugin to add categories to a model class, I wanted to override the to_param method and place the name attribute in the url. The plugin, installed as a gem, source shouldn't need to be hacked in order to accomplish this. The ...
Written by Sean Behan on 06/17/2012
Python String Format Precision of Float
You can use string interpolation in combination with a dictionary for simple formatting.
print "My name is %(name)s and I have $%(change)0.2f in change in my pocket!" % { 'name': 'Sean', 'change': 00.23 }
# My name is Sean and I have $0.23 in chang...
Written by Sean Behan on 11/20/2013