Skip to content

Instantly share code, notes, and snippets.

View galtenberg's full-sized avatar

Christopher Galtenberg galtenberg

View GitHub Profile
@galtenberg
galtenberg / gist:949680
Created April 30, 2011 13:46 — forked from mudge/gist:924909
Removing the jQuery Example plugin from operating on an element.
/* Let's say your element '#example' has already been bound
* with $('#example').example().
*/
/* This will get rid of the example immediately.
* Note that this will not return the original jQuery object so
* we can't chain anything onto this call.
*/
$('#example').triggerHandler('focus');
# Factory girl, relaxed.
#
# Factory.define :user do |f|
# f.login 'johndoe%d' # Sequence.
# f.email '%{login}@example.com' # Interpolate.
# f.password f.password_confirmation('foobar') # Chain.
# end
#
# Factory.define :post do |f|
# f.user { Factory :user } # Blocks, if you must.
# More "proper" than a miniskirt (http://gist.github.com/273579).
class Minidress
@@factories = {}
class << self
def define(name, &block)
@@factories[name.to_s] = block
end
def build(name, attrs = {})
new(name.to_s.classify.constantize.new, &@@factories[name.to_s]).record