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
| 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
| 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
| 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
| 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
| # Note: MyFinalApproach defines a block that takes a block, | |
| # which only works with Ruby >= 1.9. To work with 1.8, you'll need | |
| # to take that bit out. | |
| # Also, I think 'eigen' contains more phonetic badassery than | |
| # 'singleton', which is the real reason I prefer it. | |
| require 'forwardable' | |
| class SomeClass | |
| def self.my_eigen_method; 42; 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
| // Line 174 of jcart v1.3 | |
| // Add an item to the cart | |
| $('.jcart').submit(function(e) { | |
| add($(this)); | |
| e.preventDefault(); | |
| }); | |
| // Try replacing or adding: |
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
| #!env ruby | |
| require 'bundler' | |
| Bundler.setup | |
| require 'ircbgb' | |
| bot = Ircbgb::Client.new do |c| | |
| c.servers = 'irc://pinkhair.gudefrends.net' | |
| c.nicks = ['iande', 'ian-2', 'ian-3'] |
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
| public class Rectangle { | |
| public static int COUNTER = 0; | |
| public int width; | |
| public int height; | |
| private int myX; | |
| private int myY; | |
| public Rectangle(int x, int y, int w, int h) { | |
| // Position and dimensions were given, so we construct a rectangle at (x,y) |
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
| public static void main() { | |
| // Java provides a "default" no-argument constructor for us. | |
| MyCoolShit coolShit = new MyCoolShit(); | |
| // But, NEVER rely on it! | |
| System.out.println("Bool: " + coolShit.aBool); | |
| System.out.println("Int: " + coolShit.anInt); | |
| System.out.println("Double: " + coolShit.aDouble); | |
| System.out.println("Char: " + coolShit.aChar); | |
| System.out.println("String: " + coolShit.aString); |