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.
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
var FORMAT_ONELINE = 'One-line'; | |
var FORMAT_MULTILINE = 'Multi-line'; | |
var FORMAT_PRETTY = 'Pretty'; | |
var LANGUAGE_JS = 'JavaScript'; | |
var LANGUAGE_PYTHON = 'Python'; |
class Router | |
attr_accessor :routes | |
WILDCARD_PATTERN = /\/\*/ | |
NAMED_SEGMENTS_PATTERN = /\/:([^$\/]+)/ | |
NAMED_SEGMENTS_REPLACEMENT_PATTERN = /\/:([^$\/]+)/ | |
def initialize(routes) | |
@routes = routes | |
end |
require 'spec_helper' | |
require 'parslet/rig/rspec' | |
require 'tv_show_parslet' | |
describe TvShowParslet do | |
let(:parser) { described_class.new } | |
def p(string) | |
parse(string, :trace => true) |
class ExampleMigration < ActiveRecord::Migration | |
class MyModel < ActiveRecord::Base | |
def some_method_i_need | |
# ... | |
end | |
end | |
def self.up | |
add_column :my_models, :whatever, :string |
# Task: Implement the rcat utility and get these tests to pass on a system | |
# which has the UNIX cat command present | |
# To see Gregory Brown's solution, see http://github.com/elm-city-craftworks/rcat | |
# Feel free to publicly share your own solutions | |
rrequire "open3" | |
working_dir = File.dirname(__FILE__) | |
gettysburg_file = "#{working_dir}/data/gettysburg.txt" |
Performance is often ignored in Rails development until it becomes a problem. If ignored too long, though, it can get very tricky to improve. It's valuable to regularly audit performance and look for hotspots or design choices that are slowing things down.
Inspecting the log will help identify the source of several performance issues the application may have.
The Rails application log outputs the time spent processing each request. It breakdowns the time spent at the database level as well processing the view code. In development mode, the logs are displayed on STDOUT where the server is being run. In a production setting the logs will be in log/production.log
within the application's root directory.
# 0 is too far from ` ;) | |
set -g base-index 1 | |
# Automatically set window title | |
set-window-option -g automatic-rename on | |
set-option -g set-titles on | |
#set -g default-terminal screen-256color | |
set -g status-keys vi | |
set -g history-limit 10000 |
Integration testing is awesome. Years ago, running integration tests was painful, slow, and they were so brittle that every change to the codebase broke the test suite.
Today it's a different story. We have amazing tools that make a tough job much easier. Let's check them out.
Integration tests are critically important because they exercise your application just like a real user. They therefore depend on the full stack from your models up through your controllers, helpers, view templates, web server, database, and middleware.
# Add this to your spec_helper.rb | |
RSpec.configure do |config| | |
config.treat_symbols_as_metadata_keys_with_true_values = true | |
config.around(:each, :vcr) do |example| | |
name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/") | |
VCR.use_cassette(name, :record => :new_episodes) do | |
example.call | |
end | |
end | |
end |