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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Capybara.add_selector(:link) do | |
xpath {|rel| ".//a[contains(@rel, '#{rel}')]"} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def output name=((default=true); "caius") | |
puts "name: #{name.inspect}" | |
puts "default: #{default.inspect}" | |
end | |
output | |
# >> name: "caius" | |
# >> default: true | |
output "avdi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LintTest < ActiveSupport::TestCase | |
include ActiveModel::Lint::Tests | |
class Model | |
# model.to_model | |
include ActiveModel::Conversion | |
# Implements Model.model_name | |
extend ActiveModel::Naming |