This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given eye color distribution from: | |
# http://www.statisticbrain.com/eye-color-distribution-percentages/ | |
# ignoring the yellow specs, basically: | |
# blue 32%, green 12%, brown 41% = 85% | |
# thus.. | |
# blue 38%, green 14%, brown 48% = 100% | |
# | |
# also given the image from here.. | |
# https://twitter.com/scienceporn/status/322099933484314624 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class ARFactory | |
def self.new(table_name) | |
Class.new(ActiveRecord::Base) do | |
self.table_name = table_name | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# insert at the top of boot.rb for FUN! | |
require 'benchmark' | |
$level ||= 0 | |
$file ||= File.open('require_tree.log', 'w') | |
$pending_writes = [] | |
Object.class_eval do | |
def __trace_requires(arg, &block) | |
val = nil | |
time = nil | |
$pending_writes << [$level, arg] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export RUBY_HEAP_MIN_SLOTS=800000 | |
export RUBY_HEAP_FREE_MIN=100000 | |
export RUBY_HEAP_SLOTS_INCREMENT=300000 | |
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 | |
export RUBY_GC_MALLOC_LIMIT=79000000 | |
alias flow='ps vx | grep -iE "\b(adium|messages|mail|skype|twitter|propane|flint|sparrow)\b" | grep -v grep | cut -f1 -d" " | xargs kill; osascript -e "tell Application \"iTunes\" to play" 2&> /dev/null; echo "FLOW MODE ENABLED: Distractions closed; tunes playing"' | |
alias flowish='ps vx | grep -iE "\b(mail|skype|twitter|propane|flint|sparrow)\b" | grep -v grep | cut -f1 -d" " | xargs kill; osascript -e "tell Application \"iTunes\" to play" 2&> /dev/null; echo "FLOW MODE ENABLED: Distractions closed; tunes playing"' | |
export HISTFILESIZE=100000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'objectdb' | |
db = ObjectDB.new | |
user = {:name => 'steve', :domain => 'go_fish.com', :customer_since => Time.now.to_s} | |
db.set('[email protected]', user) | |
db.get('[email protected]') | |
=> {"name"=>"steve", "domain"=>"go_fish.com", "customer_since"=>"Sun Jul 31 02:19:51 -0500 2011"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# ONE-LINE INSTALL INSTRUCTIONS: | |
# wget --no-check-certificate https://raw.github.com/gist/1065081/git-compare; chmod u+x git-compare; mv git-compare `which git-status | ruby -e "puts STDIN.read.split(/\//)[0..-2].join('/')"`/ | |
$remote = 'origin' | |
def usage | |
puts %( | |
opens commits in github's compare feature. Commits must be pushed (remote "origin" is default) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class SQLCounter | |
IGNORED_SQL = [/^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/] | |
# FIXME: this needs to be refactored so specific database can add their own | |
# ignored SQL. This ignored SQL is for Oracle. | |
IGNORED_SQL.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im] | |
def initialize | |
$queries_executed = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use feature, background, and scenario blocks to write acceptance tests in test/unit | |
# which are really just integration tests. include capybara or webrat or something and voila. | |
# test/acceptance_helper.rb | |
require 'test_helper' | |
module ActionDispatch | |
class AcceptanceTest < ActionDispatch::IntegrationTest | |
class << self | |
alias :background :setup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rubinius Crash Report #rbxcrashreport | |
Error: signal SIGSEGV | |
[[Backtrace]] | |
0 rbx 0x00000001000212e0 _ZN8rubiniusL12segv_handlerEi + 160 | |
1 libSystem.B.dylib 0x00007fff8044866a _sigtramp + 26 | |
2 ??? 0x00007fff5fbf3490 0x0 + 140734799754384 | |
3 rbx 0x00000001001c8d93 _ZN8rubinius12ObjectWalker4nextEv + 51 | |
4 rbx 0x00000001001276f6 _ZN8rubinius6System14vm_find_objectEPNS_2VMEPNS_5ArrayEPNS_6ObjectEPNS_9CallFrameE + 422 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$:<< '../lib' << 'lib' | |
require 'rubygems' | |
require 'eventmachine' | |
require 'em-synchrony' | |
EM.run { | |
EM.synchrony { | |
loop do | |
begin |