Skip to content

Instantly share code, notes, and snippets.

View texel's full-sized avatar

Leigh Caplan texel

View GitHub Profile
var wrapper = function() {
var internalVar = 1
var internalFunction = function () {
console.log("internalVar:", internalVar);
}
return internalFunction;
}
var capturedFunction = wrapper();
var returnMeAFunction = function () {
var integer = 1;
var string = "Pancakes";
var f = function () {
console.log("integer is " + integer + " and string is " + string + ".");
}
return f;
}
class Track
ATTRIBUTES = [:name, :id, :artist, :time, :rating]
ATTRIBUTES.each do |a|
attr_accessor a
end
def initialize(hash)
ATTRIBUTES.each do |attr|
self.send("#{attr}=", (hash[attr] || ""))
RuntimeError (FLAGRANT ERROR!):
/app/controllers/hub_controller.rb:16:in `index'
/vendor/rails/actionpack/lib/action_controller/base.rb:1166:in `send'
/vendor/rails/actionpack/lib/action_controller/base.rb:1166:in `perform_action_without_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:579:in `call_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:572:in `perform_action_without_benchmark'
/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
<%
# table_for @discount_codes do |table|
# table.column :id, :label => 'ID'
# table.column :code
# table.column :max_uses, :label => 'Maximum Uses' do |discount_code|
# discount_code.max_uses || 'Unlimited'
# end
# end
# would generate something like this...
it "should send an invitation notification" do
InvitationMailer.stub!(:deliver_invitation)
InvitationMailer.should_receive(:deliver_invitation).and_return(true)
create_invitation
end
it "should send an invitation notification" do
InvitationMailer.stub!(:deliver_invitation)
InvitationMailer.should_not_receive(:deliver_invitation)
create_invitation
** [domU-12-31-39-01-8C-73 :: out] key_read: uudecode AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==[gw.onehub.com]:8022,[69.84.249.99]:8022 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA402KMw5Wz2FyGNU9Tu/PwlguHHx7i6Bp4SXZeDT+zq/oFuaBXfzlfYz899R4sjIYcKS9ggqSBEiihyPRoPcU6uckNuM5GUidTph30gsIlc/5syrTY3Ts6x6LvUbjk01qBmSPDySnZLiddYJJBqy7bM53nhYqbJ3BWKUA1BjMz6D3TqfqtPDrXfHFZ8UgTsF5kM08m5i9P10U6VNRDlBDgetIryqVQbOA6/MsrpU8FX7AhhDW8aTTw665wIWzyjo3YH86v5Y/IUAXUp7Qbd5zFFoAeakZx6vx9KpDVRXUbKvkdMVmrzJQXADmqa8I5ocIh96C2W+CjT7yt6sCExWB2w==
** failed
** key_read: uudecode AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mU
class Widget < ActiveRecord::Base
has_many :asset_maps, :as => :owner
has_many :assets, :through => :asset_maps
...
end
class AssetMap < ActiveRecord::Base
belongs_to :owner, :polymorphic => true
belongs_to :asset
class MyClass
def self.foo
'bar'
end
end
module Bazify
def foo
'baz' + super
end
module TimeAttributeExtensions
module ClassMethods
def define_attribute_methods_with_time_parsing
if define_attribute_methods_without_time_parsing
columns_hash.each do |name, column|
if [:datetime, :timestamp].include?(column.type)
unless method_defined?(:"#{name}_without_time_parsing=")