Skip to content

Instantly share code, notes, and snippets.

View ariejan's full-sized avatar

Ariejan de Vroom ariejan

View GitHub Profile
@ariejan
ariejan / mail.txt
Created October 17, 2011 07:12
Birthday mail
We could have sent you a birthday card. We could have sent you some flowers or a cake.
But we didn't.
We could have even sent you one of those automatically generated messages to wish you happy birthday where we don't even have to replace INSERT NAME.
But we didn't
We wrote this birthday greeting just for you.
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'rack', '1.3.3'
group :assets do
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-rails', "~> 3.1.0.rc"
gem 'uglifier', "1.0.0"
gem 'compass', '~> 0.12.alpha'
@ariejan
ariejan / .janus.rake
Created October 19, 2011 13:08
Place in ~/.janus.rake
skip_vim_plugin "color-sampler"
skip_vim_plugin "conque"
skip_vim_plugin "fugitive"
skip_vim_plugin "git"
skip_vim_plugin "taglist"
skip_vim_plugin "unimpaired"
skip_vim_plugin "pep8"
def sort(elements)
return elements if elements.size <= 1
return elements if elements[0] < elements[1]
[elements[1], elements[0]]
end
describe "sort" do
example "empty array => empty array" do
sort([]).should == []
Running Jasmine specs...
.
PASS: 1 test, 0 failures, 0.005 secs.
@ariejan
ariejan / con.rb
Created December 1, 2011 16:00
EM::Connection specs?
module MyApp
class Con < EM::Connection
def post_init
@queue = EM::Queue.new
end
def receive_data(data)
@queue.push(data)
end
end
@ariejan
ariejan / redis-benchmark-10000.txt
Created January 11, 2012 15:18
Redis Benchmark -
$ redis-benchmark ‹ruby-1.9.2›
====== PING (inline) ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1
100.00% <= 0 milliseconds
109890.11 requests per second
1) Partnership as a relation between two people connects a person with a partner
Failure/Error: person = create(:person_parent, partner: partner)
ActiveRecord::RecordInvalid:
Validation failed: Person partnership cannot assign partner to a partner
# ./spec/models/partnership_spec.rb:13:in `block (3 levels) in <top (required)>'
2) Partnership as a relation between two people connects a partner with a customer_partner
Failure/Error: person = create(:person_parent, partner: partner)
ActiveRecord::RecordInvalid:
Validation failed: Person partnership cannot assign partner to a partner
@ariejan
ariejan / idea.rb
Created February 2, 2012 15:50
Idea of new Invoicing design.
class Batch
end
class Invoice < ActiveRecord::Base
belongs_to :invoicable, polymorphic: true
belongs_to :invoicer, polymorphic: true
has_many :invoice_lines
def amount
@ariejan
ariejan / seed_file.rb
Created March 13, 2012 12:31 — forked from eventualbuddha/seed_file.rb
SeedFile, a helper for doing database setup in a Rails 3 app
# Helper class for importing files with records to the database.
class SeedFile
def self.import(path)
new(path).import
end
attr_reader :path
def initialize(path)
@path = Pathname(path)