Created from the plain text reference card on orgmode.org Download this file, and open it in Emacs org-mode!
# In reply to http://www.ultrasaurus.com/sarahblog/2009/08/ruby-unit-test-frameworks/ | |
# Put this in test_helper.rb to compare two arbitrarily nested structures. | |
# Usage: compare_objects(o1, o2). Raises an exception if it finds any differences. | |
# recursivly compare two objects. raise if a difference was found, return if not. | |
def compare_objects(wanted, actual, path=[]) | |
if wanted.kind_of?(Hash) | |
raise "Objects differ at #{path.join(".")}: extra keys in wanted: #{(wanted.keys - actual.keys).inspect}" if (wanted.keys - actual.keys).length > 0 | |
raise "Objects differ at #{path.join(".")}: extra keys in actual: #{(actual.keys - wanted.keys).inspect}" if (actual.keys - wanted.keys).length > 0 | |
wanted.keys.sort.each do |key| |
describe "routes to the articles controller" do | |
extend RouteSpecHelpers | |
scope_options controller: 'articles', blog: 'my_blog' | |
get '/blogs/my_blog/articles/new' => { action: 'new' } | |
post '/blogs/my_blog/articles' => { action: 'create' } | |
get '/blogs/my_blog/articles/1' => {action: 'show', id: '1' } | |
describe "routes to the articles controller" do | |
extend RouteSpecHelpers | |
scope_options controller: 'articles', blog: 'my_blog' do | |
get '/blogs/my_blog/articles/new' => { action: 'new' } | |
post '/blogs/my_blog/articles' => { action: 'create' } | |
get '/blogs/my_blog/articles/1' => {action: 'show', id: '1' } | |
end | |
end |
# http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html#method-c-load | |
# http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html#method-c-dump | |
# https://github.com/JEG2/faster_csv/blob/master/test/tc_serialization.rb | |
require 'csv' | |
class Person | |
attr_accessor :id, :name, :email | |
def self.csv_load(meta, headers, row) | |
person = Person.new |
This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.
I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial
(it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.
def local_cache(basebox_name)
cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
partial_dir = cache_dir.join('partial')
partial_dir.mkdir unless partial_dir.exist?
cache_dir
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Updated: Just use qutebrowser (and disable javascript). The web is done for.
Bevry Draft Code of Conduct
TLDR: Be a productive member of civilised society, no more, no less.
Results > Character > Identity.
We care only about your character and your results. We discriminate at the individual level, not the group identity level. You can be whatever identity you want, your identity is your thing not ours, identity is meaningless to us.
Libertarian Values.