Skip to content

Instantly share code, notes, and snippets.

require 'benchmark'
arr = [*0..99999]
num = 100
Benchmark.bmbm do |x|
x.report("sym#to_proc") do
num.times do
arr.each(&:to_i)
end
end
@tal
tal / .bashrc
Created January 25, 2011 18:40
Definition of the gg alias.
function gg { freyr $@ --config-file="/web/Freyrfile" --ignore-local --namespace=gg; }
<a href="#" class="button h64" id="buy_package_1234">
<div class="left bg"></div>
<div class="right bg"></div>
<span class="text">Buy</span>
</a>
>> m = Match.first
=> #<Match _id: 4d9bce2458f68fbb67000001, user_ids: [1, 2], _id: BSON::ObjectId('4d9bce2458f68fbb67000001'), _type: nil>
>> m.players.create(:user_id => 1)
NoMethodError: undefined method `name' for nil:NilClass
var keyCodes = {
backspace: 8,
tab: 9,
enter: 13,
escape: 27,
left: 37,
up: 38,
right: 39,
down: 40,
delete: 46,
@tal
tal / _model_ext.rb
Created April 26, 2011 18:31
How to allow sequel models to be passed into filters
class Sequel::Model
def sql_literal(dataset=nil)
self.pk
end
end
@tal
tal / log.rb
Created May 10, 2011 15:13
A fast and easy way to make logs
module Log
LOGS = Hash.new {|h,k| h[k] = Logger.new("log/#{k}.log")}
extend self
def method_missing name
LOGS[name]
end
end
@tal
tal / .gitconfig
Created June 16, 2011 19:57
A few of my dotfiles.
[alias]
co = checkout
ci = commit
s = status -sb
revert-to = read-tree -u -m HEAD
sd = svn dcommit
sr = svn rebase
br = branch
df = diff
ff = rebase --stat @{upstream}
@tal
tal / 1.rb
Created June 16, 2011 20:17
DSL attempt
class Abc
def foo *args
puts 'foo', args
end
def run
load '2.rb'
end
end
_ruby_gem_path rvm_ruby_global_gems_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_load_path rvm_ruby_major_version rvm_ruby_make rvm_ruby_make_install rvm_ruby_minor_version rvm_ruby_mode rvm_ruby_name rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_patch rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_require rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_sha rvm_ruby_string rvm_ruby_strings rvm_ruby_tag rvm_ruby_url rvm_ruby_user_tag rvm_ruby_version rvm_script_name rvm_scripts_path rvm_sdk rvm_user_install_flag rvm_silent_flag rvm_src_path rvm_sticky_flag rvm_system_flag rvm_tmp_path rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_user_path rvm_usr_path rvm_verbose_flag rvm_wrapper_name rvm_wrappers_path rvm_ruby_repo_branch rvm_man_path
++ /scripts/base : 29 > case "rvm_base_except" in
++ /scripts/base : 34 > source /Users/tatlas/.rvm/scripts/selector
++ /scripts/base : 40 > scripts=(logging utility init cleanup env rvmrc install environment