Skip to content

Instantly share code, notes, and snippets.

@xaviershay
xaviershay / vegan-month.md
Created November 19, 2011 17:45
Vegan Month Curriculum

Vegan Month Logo

Back in Melbourne circa 2010/11, Jodie, Jared and I used to run a [monthly vegan mentoring group][vegan-month]. I have gone back through the mailing lists and collected much of the curriculum and information from the program into this single document, so that I can distribute it more widely. The program was designed not just to get you through the first month nutritionally, but to expose you to a variety of foods and ideas that may be new to you. It emphasises that veganism is a shift sideways, not a sacrifice.

@mperham
mperham / gist:1379464
Created November 19, 2011 22:33
Flexibility without Dependency Injection
class TaxCode
GENERATORS = {
:us => lambda { |id| "US-#{id}" },
:br => lambda { |id| "#{id + 9}-BRA" },
}
def self.generate(code, id)
gen = GENERATORS[code] || raise ArgumentError, "No generator for country #{code}"
gen.call(id)
end
@chadmyers
chadmyers / bod.coffee
Created November 23, 2011 21:20
BOD Hubot Coffee
# Allows Hubot to give a look of disapproval.
#
# bod <name> - gives back the character for the look of disapproval.
module.exports = (robot) ->
robot.respond /bod\s?(.*)/i, (msg) ->
user_msg = msg.match[1].trim()
response = 'ಠ_ಠ - ' + user_msg + '\n' +
@shinzui
shinzui / finders.rb
Created December 26, 2011 19:28 — forked from samullen/finders.rb
User defined finders for Capybara
Capybara.add_selector(:link) do
xpath {|rel| ".//a[contains(@rel, '#{rel}')]"}
end
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@Dishwasha
Dishwasha / gist:1602521
Created January 12, 2012 19:27
Add jasmine to default rake task
require 'rspec/core'
require 'rspec/core/rake_task'
require 'jasmine-headless-webkit'
# Run Jasmine headless via webkit
Jasmine::Headless::Task.new('jasmine:headless')
# Add to default rake task
if default = Rake.application.instance_variable_get('@tasks')['default']
default.prerequisites.unshift('jasmine:headless')
@pjb3
pjb3 / hash_deep_stringify_keys.rb
Created January 26, 2012 14:14
Shouldn't this just be in ActiveSupport?
class Hash
def deep_stringify_keys
stringify_keys.inject({}) do |h, (k,v)|
h[k] = v.is_a?(Hash) ? v.deep_stringify_keys : v
h
end
end
end
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@csquared
csquared / serializes_json.rb
Created February 2, 2012 20:27
Serializes JSON
# serialize :field, Hash
# got you down?
# serializes_json :field
# to the rescue!
class ActiveRecord::Base
def self.serializes_json *args
args.each do |field_name|
eval <<-RUBY
def #{field_name}=(other)
@josevalim
josevalim / lint_test.rb
Created February 7, 2012 21:16
Custom AMo model for forms
class LintTest < ActiveSupport::TestCase
include ActiveModel::Lint::Tests
class Model
# model.to_model
include ActiveModel::Conversion
# Implements Model.model_name
extend ActiveModel::Naming