Skip to content

Instantly share code, notes, and snippets.

Joshua Ballanco jballanc

Block or report user

Report or block jballanc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:26070
#!/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
View list
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
View a.rb
if $0 == __FILE__
puts "I'm running as an executable"
end
class Test
def say
puts "I'm from a library"
end
end
View a.rb
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
View gist:104272
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
View ack.rb
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 — forked from jballanc/ack.rb
Fun with Ackermann
View ack.rb
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
View gist:141748
require 'thread'
require 'timeout'
class ObjectPool
attr_reader :max
attr_accessor :timeout
attr_accessor :create
attr_accessor :objects
attr_accessor :used
View testclass.rb
class Test
def say
puts "hello, world"
end
end
View gist:212757
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!"
You can’t perform that action at this time.