Skip to content

Instantly share code, notes, and snippets.

View jballanc's full-sized avatar

Joshua Ballanco jballanc

View GitHub Profile
@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 MyGroupedListController < UIViewController
attr_accessor :posts
attr_accessor :sections
class TableViewSection
attr_accessor :title
attr_accessor :items
def initialize(params={})
@title = params[:title]
@jballanc
jballanc / a.rb
Created August 19, 2012 21:07 — forked from ahoward/a.rb
threads are so dang awesome
strategy =
String(ARGV.shift || 'thread')
n =
Integer(ARGV.shift || 4)
mb =
@jballanc
jballanc / ifs.rb
Last active December 16, 2015 19:00 — forked from jeffkreeftmeijer/ifs.rb
def process(input)
commands = {
'q' => -> { puts 'Goodbye' },
'tweet' => -> { puts 'tweeting' },
'dm' => -> { puts 'direct messaging' },
'help' => -> { puts 'helping' }
}
commands.fetch(input, -> {}).call()
end
@jballanc
jballanc / gist:7354050
Last active December 27, 2015 16:19 — forked from smiler/gist:7353931
(let [dt (elapsed-time t)
balls (->> balls
(map #(move % dt))
(map #(keep-in-bounds dt ctx %)))]
;; Do stuff with balls
)
class SampleController < UIViewController
def viewDidLoad
super
self.view.backgroundColor = UIColor.whiteColor
frame = UIScreen.mainScreen.applicationFrame
origin = frame.origin
size = frame.size
text_view = UITextView.alloc.initWithFrame([[origin.x, origin.y],