Skip to content

Instantly share code, notes, and snippets.

View lyleunderwood's full-sized avatar
💭
working

Lyle Underwood lyleunderwood

💭
working
  • ShowLabs Inc.
  • Sacramento, CA
View GitHub Profile
@lyleunderwood
lyleunderwood / ActiveSupport::HashWithIndifferentAccess#merge bug
Created March 23, 2011 18:21
ActiveSupport::HashWithIndifferentAccess#merge bug
Regular Hash behavior:
irb(main):023:0> a = {"one"=>"aye", "two"=>"bee"}
=> {"one"=>"aye", "two"=>"bee"}
irb(main):024:0> a.merge(a) {|k,v| 1}
=> {"one"=>1, "two"=>1}
Crazy HashWithIndifferentAccess behavior:
irb(main):025:0> b = ActiveSupport::HashWithIndifferentAccess.new("one"=>"aye", "two"=>"bee")
=> {"one"=>"aye", "two"=>"bee"}
irb(main):026:0> b.merge(b) {|k,v| 1}
module B
attr_accessor :b_config
def get_b_config
@config[:b]
end
def B.extend_object(target)
super
target.b_config = target.get_b_config
class Product
include Mongoid::Document
include Mongoid::Timestamps
include DataImporting::Importable
include Amf::Serialization
field :number
field :name
field :gender
field :region
require 'schlepp'
Schlepp::Burden.new do
# all actions performed in this directory
cd 'data/'
# do the defined actions for every subfolder
glob 'catalogs/*' do |dir|
# once we've finished up here we're going to create the catalog
dir.after do |dir|
var http = require('http'),
sys = require('sys'),
querystring = require('querystring');
// Create the listening server
http.createServer(function(request, response)
{
sys.puts('Request for ' + request.url);
switch (request.url)
config = lambda {}
Schlepp::Db.should_receive(:new) {|&block| block.should eql config }
@burden.db &config
#!/bin/bash
# this assumes you have amixer and notify-send installed:
# sudo apt-get install alsa-utils libnotify-bin
# this is guaranteed to work on MY system, which is ubuntu
# 11.04 with pulseaudio (the default). if anything is likely
# to change on your system, it's gonna be the name of the
# channel you want to affect.
@lyleunderwood
lyleunderwood / gist:975130
Created May 16, 2011 19:24
associations/collection_proxy.rb
1 module ActiveRecord
2 module Associations
3 # Association proxies in Active Record are middlemen between the object that
4 # holds the association, known as the <tt>@owner</tt>, and the actual associated
5 # object, known as the <tt>@target</tt>. The kind of association any proxy is
6 # about is available in <tt>@reflection</tt>. That's an instance of the class
7 # ActiveRecord::Reflection::AssociationReflection.
8 #
9 # For example, given
10 #
class Comment < ActiveRecord::Base
scope :in_public, joins(:post).joins(:category).where("categories.type = 'public'")
belongs_to :post
end
class Post < ActiveRecord::Base
has_many :comments
belongs_to :category
end
(02:29:18 PM) George Plendl:
emphatically i tried to git-discover your moms{snatch+ahole}+1