Skip to content

Instantly share code, notes, and snippets.

View jballanc's full-sized avatar

Joshua Ballanco jballanc

View GitHub Profile
#!/usr/bin/env ruby
module Example
def self.hello(arg)
puts "Hello, #{arg}! You are Object \#: #{arg.object_id}"
arg = 'different'
puts "Arg is now #{arg}; Object \#: #{arg.object_id}"
end
def self.not_local_hello
Music/iTunes/iTunes Music/Bob Seager
Music/iTunes/iTunes Music/Jethro Tull/Songs From the Wood
Music/iTunes/iTunes Music/DJ Shadow/Live! In Tune & On Time (Brilliant Box)/01 Intro.m4p
Music/iTunes/iTunes Music/Red Hot Chili Peppers/Californication (Bonus Version)/10 I Like Dirt.m4p
Music/iTunes/Album Artwork/Download/1386487F98DF33BD/02/09
Music/iTunes/iTunes Music/The Mamas and the Papas/California Dreamin'/01 California Dreamin' (Single).m4p
Music/iTunes/iTunes Music/Compilations/One Night Only_ The Greatest Hits Live/12 Candle In The Wind (Live).m4a
Music/iTunes/iTunes Music/Smashing Pumpkins/Zeitgeist/06 Starz.m4p
Music/iTunes/iTunes Music/Academy of St. Martin in the Fields & Sir Neville Marriner/The Complete Mozart Edition_ The Serenades for Orchestra, Vol. 2/1-01 March in D, K.237.m4p
Music/iTunes/iTunes Music/Red Hot Chili Peppers/Californication (Bonus Version)/04 Otherside.m4p
if $0 == __FILE__
puts "I'm running as an executable"
end
class Test
def say
puts "I'm from a library"
end
end
if $0 == __FILE__
require 'b.rb'
test = TestB.new
test.say
end
class TestA
def say
puts "I'm from library file a.rb"
end
irb(main):001:0> class A
irb(main):002:1> def foo
irb(main):003:2> puts "In class A"
irb(main):004:2> end
irb(main):005:1>
irb(main):006:1* def my_meta
irb(main):007:2> class << self
irb(main):008:3> self
irb(main):009:3> end
irb(main):010:2> end
def ack(m, n)
if m == 0
n + 1
elsif n == 0
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end
@jballanc
jballanc / ack.rb
Created May 6, 2009 07:44 — forked from jballanc/ack.rb
Fun with Ackermann
def ack(m, n)
if m == 0
n + 1
elsif n == 0
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end
require 'thread'
require 'timeout'
class ObjectPool
attr_reader :max
attr_accessor :timeout
attr_accessor :create
attr_accessor :objects
attr_accessor :used
class Test
def say
puts "hello, world"
end
end
irb(main):001:0> class A
irb(main):002:1> def test(thing)
irb(main):003:2> puts "#{thing}! from class A!"
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> class B < A
irb(main):007:1> def test(thing)
irb(main):008:2> super(thing)
irb(main):009:2> puts "...and now from class B too!"