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
bash>> irb | |
class A;>> class A; end | |
=> nil | |
>> class B; end | |
=> nil | |
>> the_class = A | |
=> A | |
>> class C < the_class | |
>> end | |
=> nil |
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
# Problem: You want to be able to load a class without also having to load all its | |
# dependencies as a prerequisite, such as in a unit test | |
# test module | |
module BucketOMethods | |
def hi | |
puts 'hi'; 'hi' | |
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
>> a=lambda{:this};b=lambda{:this};a==b | |
=> true | |
>> a=lambda{:this} | |
=> #<Proc:0x007f9d5a8c4430@(irb):24 (lambda)> | |
>> b=lambda{:this} | |
=> #<Proc:0x007f9d5a8bade0@(irb):25 (lambda)> | |
>> a==b | |
=> false |
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
Bundler could not find compatible versions for gem "bundler": | |
In Gemfile: | |
rails (= 3.0) ruby depends on | |
bundler (~> 1.0.0) ruby | |
Current Bundler version: | |
bundler (1.2.3) | |
This Gemfile requires a different version of Bundler. | |
Perhaps you need to update Bundler by running `gem install bundler`? |
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
<% | |
db_name = nil | |
if ENV['SPECIFIC_DB'] | |
db_name = ENV['SPECIFIC_DB'].strip | |
else | |
cur_branch = `source ~/bin/git-branch.bash; parse_git_branch`.strip | |
db_name = cur_branch | |
end | |
db_name = db_name.gsub(/[\/\.]/,'_') | |
test_db = db_name + '_test' + ENV['TEST_ENV_NUMBER'].to_s |
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 Enumerable | |
def recursive?(oids = {}) | |
if oids.key?(self.object_id) | |
return true | |
else | |
oids[self.object_id] = 1 | |
return any?{ |v| v.recursive?(oids) if v.respond_to?(:recursive?) } | |
end | |
return false | |
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
[2013-02-25 15:41:08] make | |
CC = /usr/local/bin/gcc-4.2 | |
LD = ld | |
LDSHARED = /usr/local/bin/gcc-4.2 -dynamic -bundle | |
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -pipe | |
XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE | |
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/Users/pmarreck/.rvm/usr/include -I/Users/pmarreck/.rvm/usr/include -I. -I.ext/include/x86_64-darwin11.4.2 -I./include -I. | |
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/Users/pmarreck/.rvm/usr/lib -L/Users/pmarreck/.rvm/usr/lib -fstack-protector -Wl,-u,_objc_msgSend -pie | |
SOLIBS = | |
compiling main.c |
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
# Search for: | |
/,\s((?:where|order|select)\(.+\))/ | |
# Replace with: | |
', lambda{ \1 }' |
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
class Array | |
def insert_every!(skip, str) | |
orig_ary_length = self.length | |
new_ary_length = orig_ary_length + ((orig_ary_length-1) / skip) | |
i = skip | |
while(i<new_ary_length) do self.insert(i,str); i+=(skip+1) end | |
self | |
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
class String | |
def to_arabic_numeral | |
if self =~ RomanNumeral::REGEXP | |
# The following is some insane magic I won't even touch, but it would work | |
# n=s=0;bytes{|c|s+=n-2*n%n=10**(205558%c%7)%9995};s+n | |
RomanNumeral.get(self) | |
else | |
raise "String is not a Roman numeral" | |
end | |
end |