Run the following in your shell:
brew install macvim --override-system-vim
brew upgrade tmux
brew install reattach-to-user-namespace
echo 'set-option -g default-command "reattach-to-user-namespace -l bash"' >> ~/.tmux.conf
require 'benchmark/ips' | |
carts = 10.times.map { Cart.create! account: Account.first } | |
carts.each { |cart| | |
items = Account.first.product_options.sample(5) | |
items.each { |item| cart.line_items.create product_option_id: item.id, quantity: 1 } | |
} | |
def all_at_once(carts, &blk) |
class Array | |
def ranked_sample(count) | |
slice_size = length / count | |
count.times.reduce([]) do |a, i| | |
i += 1 | |
to_take = i == count ? length : slice_size * i | |
v = (take(to_take) - a).sample | |
a << v if v | |
a | |
end |
Calculating ------------------------------------- | |
ruby version 369 i/100ms | |
c version 3413 i/100ms | |
------------------------------------------------- | |
ruby version 3977.2 (±4.5%) i/s - 19926 in 5.020612s | |
c version 450675.5 (±9.4%) i/s - 2221863 in 4.986029s | |
~/dev/theclymb$ ./bin/rails runner bench.rb | |
Calculating ------------------------------------- | |
ruby version 360 i/100ms | |
c version 3385 i/100ms |
# Rspec fire can only mock methods that are defined on a class. | |
# The way active record defines accessors is incompatible with rspec-fire's | |
# implementation so this works around that by defining an accessor for every | |
# attribute as soon as each model class is loaded for the first time | |
# | |
# TODO: See if this is needed with Rails 4 | |
class ActiveRecord::Base | |
class << self | |
alias :__ar_original_inherited__ :inherited |
-- Implements the algorithm described here http://www.quuxlabs.com/blog/2010/09/matrix-factorization-a-simple-tutorial-and-implementation-in-python/ | |
-- by translating http://www.quuxlabs.com/wp-content/uploads/2010/09/mf.py_.txt into the equivalent lua code (I hope) | |
-- | |
-- INPUT: | |
-- R : a matrix to be factorized, dimension N x M | |
-- P : an initial matrix of dimension N x K | |
-- Q : an initial matrix of dimension M x K | |
-- K : the number of latent features | |
-- steps : the maximum number of steps to perform the optimisation | |
-- alpha : the learning rate |
class CreateResumeDesigns < ActiveRecord::Migration | |
def up | |
change_table :resume_designs do |t| | |
t.string :purpose | |
end | |
end | |
def down | |
end | |
end |
Run the following in your shell:
brew install macvim --override-system-vim
brew upgrade tmux
brew install reattach-to-user-namespace
echo 'set-option -g default-command "reattach-to-user-namespace -l bash"' >> ~/.tmux.conf
module RSpec::Mocks::Methods | |
# Validates the method exists on the stub-ee before stubbing | |
def s_stub(message_or_hash, opts={}, &block) | |
if Hash === message_or_hash | |
message_or_hash.each {|message, value| s_stub(message).and_return value } | |
else | |
raise "#{message_or_hash} not defined on #{self.inspect}" unless self.respond_to?(message_or_hash.to_sym) | |
stub(message_or_hash.to_sym, opts, &block) | |
end | |
end |
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208 | |
# Configuration name mysql55-master generated for mike@theclymb.com at 2012-06-23 04:45:09 |
require 'tinder' | |
require 'time' | |
campfire = Tinder::Campfire.new 'subdomain', :token => 'herp' | |
VOICES = [ | |
'Agnes', | |
'Albert', | |
'Alex', | |
'Bad News', |