Very useful
$("SELECTOR").data("events");
All bound event handlers are stored in the elements data context under the events key
This can be very useful when debugging with tools like FireBug
$("form").submit(function () { alert('submit form'); });
$("form").data("events");
> Object { submit=[1] }
Resources
House 9
Friday, December 30, 2011
Friday, December 2, 2011
Get table and column information in postgres
Use the information_schema catalog - http://www.postgresql.org/docs/9.1/static/information-schema.html
Get table and columns from the public schema
This can be useful, maybe you want to auto generate some text that creates foreign keys based on a naming convention - for instance let's say we have a ruby/rails method called make_fk_unless_exists
The 'code' column would render something like
Get table and columns from the public schema
This can be useful, maybe you want to auto generate some text that creates foreign keys based on a naming convention - for instance let's say we have a ruby/rails method called make_fk_unless_exists
The 'code' column would render something like
make_fk_unless_exists :projects, :milestone_id, :milestones
make_fk_unless_exists :tasks, :project_id, :projects
...
Labels:
postgresql
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
Resources
Labels:
rails
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
Labels:
postgresql
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...
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
There must be a gem for thatSure 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
Subscribe to:
Posts (Atom)
