Skip to content

Instantly share code, notes, and snippets.

Loading development environment (Rails 3.0.7)
irb(main):001:0> This.find(2).some_those
=> []
irb(main):002:0> This.reflect_on_all_associations.map(&:name)
=> ["some_those", "other_those"]
irb(main):003:0> This.find(2, :include => :some_those)
ActiveRecord::ConfigurationError: Association named 'some_those' was not found; perhaps you misspelled it?
from /var/lib/gems/1.8/gems/activerecord-3.0.7/lib/active_record/association_preload.rb:116:in `preload_one_association'
from /var/lib/gems/1.8/gems/activesupport-3.0.7/lib/active_support/ordered_hash.rb:126:in `each'
from /var/lib/gems/1.8/gems/activesupport-3.0.7/lib/active_support/ordered_hash.rb:126:in `each'
syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gim]\{0,3\}\s*$+ end=+/[gim]\{0,3\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
data = data.replace(/(\r\n|\n|\r)/gm, "").replace(/'/g, "\\'");
@graywh
graywh / gist:862786
Created March 9, 2011 19:23
which is faster?
# given array 'arr' and object 'x' the responds to 'a' and 'b',
# which is faster?
arr << x.a
arr << x.b
arr
# or
arr = arr + [x.a, x.b]
@graywh
graywh / pathogen#runtime_append_all_bundles
Created February 21, 2011 14:54
the 2 different ways to use pathogen
~/.vim
~/.vim/bundles/brew
~/.vim/bundles/colorchart
~/.vim/bundles/colorindent
~/.vim/bundles/csapprox
~/.vim/bundles/cucumber
~/.vim/bundles/fugitive
~/.vim/bundles/git
~/.vim/bundles/haml
~/.vim/bundles/indent-guides
class Calendar < ActiveRecord::Base
has_many :reservations
end
class Reservation < ActiveRecord::Base
belongs_to :calendar
def self.search(search_fields)
results = self #this is where I'd like to access the collection search was called on
@graywh
graywh / divisions.csv
Created December 20, 2010 16:43
Fantasy Football League Stats
Team 1 Team 2 Team 3 Team 4 Team 5 Team 6 Team 7 Team 8 Team 9 Team 10 Team 11 Team 12 Team 13 Team 14 Team 15 Team 16
2 2 2 1 1 1 2 2 1 1 2 2 2 1 1 1
@graywh
graywh / 99bindings.patch
Created November 16, 2010 18:10
fix irssi's key bindings
Remove hack for binding ^ that prevents binding ctrl-^
--- irssi-0.8.15.orig/src/fe-text/gui-readline.c
+++ irssi-0.8.15/src/fe-text/gui-readline.c
@@ -392,12 +392,6 @@
str[g_unichar_to_utf8(key, str)] = '\0';
}
- if (strcmp(str, "^") == 0) {
- /* change it as ^^ */
- str[1] = '^';
@graywh
graywh / mario_bloop.rb
Created August 18, 2010 21:11
some bloopsaphone tunes
require 'rubygems'
require 'bloops'
b = Bloops.new
b.tempo = 100
sound = b.sound Bloops::SQUARE
sound.volume = 0.5
sound.sustain = 0.3
sound.attack = 0.1
sound.decay = 0.3
@graywh
graywh / common.scss
Created June 25, 2010 15:27
some basic styles i use in every rails project
div.p {
/* div's as p's
*
* this is a work-around for how rails
* displays error messages on a form
*/
margin-bottom: 1em;
}
.small {
% gvim
Xlib: extension "RANDR" missing on display ":0.0".
(gvim:19111): atk-bridge-WARNING **: AT_SPI_REGISTRY was not started at session startup.
(gvim:19111): atk-bridge-WARNING **: IOR not set.
(gvim:19111): atk-bridge-WARNING **: Could not locate registry