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
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.
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
tables.table_name, | |
columns.column_name | |
from information_schema.tables | |
inner join information_schema.columns | |
on information_schema.columns.table_name = information_schema.tables.table_name | |
where tables.table_schema = 'public' | |
and tables.table_type = 'BASE TABLE' | |
order by tables.table_name, columns.column_name; |
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
tables.table_name, | |
columns.column_name, | |
('make_fk_unless_exists :' || tables.table_name || ', :' || columns.column_name || ', :' || REPLACE(columns.column_name, '_id', 's')) as code | |
from information_schema.tables | |
inner join information_schema.columns | |
on information_schema.columns.table_name = information_schema.tables.table_name | |
where tables.table_schema = 'public' | |
and columns.column_name LIKE '%id' | |
and columns.column_name <> 'id' | |
and tables.table_type = 'BASE TABLE' | |
order by tables.table_name, columns.column_name; |
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
Subscribe to:
Posts (Atom)