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 XOR B | |
(A * ~B) + (~A * B) | |
F + (A * ~B) + (~A * B) + F | |
(A * ~A) + (A * ~B) + (~A * B) + (B * ~B) | |
(A * (~A + ~B)) + ((~A + ~B) * B) |
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 SomeAPI | |
def self.get_var mod, meth | |
vars_for(mod)[meth] | |
end | |
def self.set_var mod, meth, val | |
vars_for(mod)[meth] = val | |
end | |
def self.vars_for mod |
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 Message | |
class << self | |
def some_meth; "Hello from Message"; end | |
end | |
end | |
class Version < Message | |
class << self | |
def some_meth; "Hello from Version"; 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
irb(main):001:0> hsh = { :a => "A", :b => "B" } | |
=> {:a=>"A", :b=>"B"} | |
irb(main):002:0> a_key = "a" | |
=> "a" | |
irb(main):003:0> a_val = "a" | |
=> "a" | |
irb(main):004:0> key = "#{a_val}.to_sym" | |
=> "a.to_sym" | |
irb(main):005:0> hsh[key] | |
=> 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
export PATH="/Users/chaos/.rvm/gems/ruby-1.9.2-p180@global/bin:/bin:/bin:/Users/chaos/.rvm/bin:$PATH" | |
rvm_path='/Users/chaos/.rvm' ; export rvm_path | |
RUBY_VERSION='ruby-1.9.2-p180' ; export RUBY_VERSION | |
GEM_HOME='/Users/chaos/.rvm/gems/ruby-1.9.2-p180@global' ; export GEM_HOME | |
GEM_PATH='/Users/chaos/.rvm/gems/ruby-1.9.2-p180@global:' ; export GEM_PATH | |
unset MY_RUBY_HOME | |
unset IRBRC | |
rvm_ruby_string='ruby-1.9.2-p180' ; export rvm_ruby_string | |
unset rvm_gemset_name | |
unset MAGLEV_HOME |
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 | |
if [[ -s "/Users/chaos/.rvm/environments/ruby-1.9.2-p180@global" ]] | |
then | |
source "/Users/chaos/.rvm/environments/ruby-1.9.2-p180@global" | |
exec ruby "$@" | |
else | |
echo "ERROR: Missing RVM environment file: '/Users/chaos/.rvm/environments/ruby-1.9.2-p180@global'" >&2 | |
exit 1 | |
fi |
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 MyMod | |
class << self | |
attr_reader :my_reader | |
end | |
attr_reader :my_other_reader | |
module_function :my_other_reader | |
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
def self.make_year(year, bias) | |
# Check for year > 2 digits, etc | |
# ... | |
start_year = Chronic.time_class.now.year - bias | |
century = (start_year / 100) * 100 | |
full_year = century + year | |
if full_year < start_year | |
full_year + 100 | |
else | |
full_year |
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
rvm use ruby-1.9.2 | |
gem install open_gem | |
gem sandbox install flog |
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 levenshtein other | |
# .. left as exercise for the reader | |
end | |
class Object | |
def method_missing meth, *args, &block | |
meth_str = meth.to_s | |
new_meth = self.methods.map do |m| | |
[meth_str.levenshtein(m.to_s), m] |