Skip to content

Instantly share code, notes, and snippets.

class Thing
def self.say_hello
puts "Hello from ####"
end
class << self
def say_hello
puts "Hello from ####"
end
main_class = MainClass.new
main_class.extend(MixInA)
class << main_class; undef :say_hello; end
desc 'Clean up lookups, remove units form values and names'
task :remove_units_from_lookups => :environment do
types = [
:rafter_spacings, :basic_wind_speeds,
:ground_snow_loads, :average_roof_heights
]
types.each do |type|
Lookup.type_of(type).each do |lookup|
next unless lookup.name.scan(/[^\d.]/).any?
http://www.dreamr.xxx
@dreamr
dreamr / _form.ejs
Created February 22, 2012 00:53
Why is it that I end up with the ObjectId instead of unit.race -> Race() ?
<div class="clearfix">
<%- form.label("race") %>
<div class="input">
<%- form.input( 'race' ) %>
</div>
</div>
new InfoBubble({
arrowPosition: 50,
arrowSize: 10,
arrowStyle: 0,
backgroundClassName: 'property asset small bubble',
backgroundColor: '#FFF',
borderColor: '#F0F0F0',
borderRadius: 3,
borderWidth: 1,
content: $('div#marker_info_#{marker.id}').html(),
@dreamr
dreamr / pre-commit
Created February 8, 2013 08:51
run tests with a pre-commit to keep me honest
#!/bin/sh
## .git/hooks/pre-commit
bundle exec rake db:migrate
bundle exec rake db:test:prepare
bundle exec rake test
@dreamr
dreamr / gist:4963675
Created February 15, 2013 21:26
hash 1
{:docs=>[{:id=>1, :"region-tz-min-offset"=>-480, :"dispensary-name"=>"dr. greenthumb garden supply 1", :"dispensary-slug"=>"dr-greenthumb-garden-supply-1", :"title-pc"=>"Dr. Greenthumb Garden Supply 1", :"dispensary-rating-power"=>"5.0000", :"dispensary-created"=>"1970-01-01T00:00:00.000Z", :video_url=>nil, :"dispensary-region-slug"=>"lake-tahoe", :"super-region-id"=>2, :"super-region-name"=>"California", :"super-region-slug"=>"california", :"dispensary-has-videos"=>0, :"dispensary-has-gpen"=>0, :"dispensary-hits"=>0, :hits=>0, :"reviewer-count"=>1, :intro=>"Hello body text", :"dispensary-intro"=>"Hello body text", :name=>"dr. greenthumb garden supply 1", :"name-phrase"=>"dr. greenthumb garden supply 1", :phone=>"555-555-5555", :zip=>"12345", :city=>"lake tahoe", :"city-phrase"=>"Lake Tahoe", :state=>"CA", :latitude=>32.751117, :longitude=>-117.213405, :location=>"32.751117,-117.213405", :featured=>1, :type=>"dispensary", :"within-5-mi-of"=>[], :"within-25-mi-of"=>[], :"within-50-mi-of"=>[], :"within-100-mi-o
{:docs=>[{:id=>1,
:"region-tz-min-offset"=>-480,
:"dispensary-name"=>"dr. greenthumb garden supply 1",
:"dispensary-slug"=>"dr-greenthumb-garden-supply-1",
:"title-pc"=>"Dr. Greenthumb Garden Supply 1",
:"dispensary-rating-power"=>"5.0000",
:"dispensary-created"=>"1970-01-01T00:00:00.000Z", :video_url=>nil,
:"dispensary-region-slug"=>"lake-tahoe",
:"super-region-id"=>2,
:"super-region-name"=>"California",
@dreamr
dreamr / gist:5000117
Created February 20, 2013 22:08
lol'd
if 5+5 == 10#topic.save!
else #Error Saving
p "#{topic.errors.full_messages}"
pp topic.attributes
20.times { p "------------------" }
errs << ["#{topic.errors.full_messages}", topic.attributes]
# output/log why no save
end