Skip to content

Instantly share code, notes, and snippets.

require 'test_helper'
module CallbackModelTemplate
def self.included(model)
model.class_eval do
key :name, String
has_many :sons, :class_name => 'CallbacksTest::Son'
[ :before_validation_on_create, :before_validation_on_update,
:before_validation, :after_validation,
context "new?" do
setup do
@document.class_eval do
key :foo, Address
end
end
should "be new until document is saved" do
address = Address.new(:city => 'South Bend', :state => 'IN')
doc = @document.new(:foo => address)
# This is an incomplete implementation.
module MongoMapper
module NestedAttributes
def self.included(base)
base.extend(ClassMethods)
base.send :include, InstanceMethods
end
module ClassMethods
def accepts_nested_attributes_for(*attr_names)
/*
* jQuery UI CSS Framework
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
*/
/* Layout helpers
----------------------------------*/
.ui-helper-hidden { display: none; }
.ui-helper-hidden-accessible { position: absolute; left: -99999999px; }
@zef
zef / gist:631585
Created October 18, 2010 02:01
Example of chord chart formatting
G D/F# Em
She said I don't know if I've ever been good enough
C2 G D/F# Em C2
I'm a little bit rusty, and I think my head is caving in
G D/F# Em
And I don't know if I've ever been really loved
C2 G D/F# Em
By a hand that's touched me, and I feel like somethings gonna give
C2
And I'm a little bit angry
@zef
zef / address_book_phone_updater.rb
Created December 3, 2010 21:58
Iterates through Address Book phone numbers so you can change the format programatically.
# Zef Houssney
# http://madebykiwi.com
#
# rb-appscript documentation:
# http://appscript.sourceforge.net/rb-appscript/index.html
#
# Install rb-appscript with:
# sudo gem install rb-appscript
# Make sure to backup your address book before doing this!!!
tell application "System Events"
set app_name to name of the first process whose frontmost is true
set visible of process app_name to false
end tell
tell application "Finder"
activate
end tell
@zef
zef / coordinates.js
Created September 5, 2011 21:22
Added coordinates for Dvorak for the keyboard heatmap demo here: http://www.patrick-wied.at/projects/heatmap-keyboard/
app.QWERTY_COORDINATES = {
"~": [35, 120],
"`": [35, 120],
"1": [90, 120],
"!": [90, 120],
"2": [144, 120],
"@": [144, 120],
"3": [198, 120],
"#": [198, 120],
"4": [253, 120],
@zef
zef / jquery.spin.coffee
Created June 26, 2012 20:33 — forked from innotekservices/jquery.spin.js
jQuery Plugin for Spin.js (Coffescript)
# A jQuery Wrapper around spin.js
# Has sane defaults and uses the color attribute of the target selector
#
# http://fgnass.github.com/spin.js/
#
# preset_name - size of spinner: 'small' or 'large'
# customizations - any option from spin.js
#
# Examples:
#
class CellView < UIView
SIZE = 20
def initWithCell(cell)
if init
self.backgroundColor = UIColor.blackColor
# self.layer.cornerRadius = 4.0
# self.layer.cornerRadius = SIZE/2
self.frame = [[cell.x * SIZE, cell.y * SIZE], [SIZE, SIZE]]
emojify!