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 sample_controller.rb
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],
View gist:7354050
(let [dt (elapsed-time t)
balls (->> balls
(map #(move % dt))
(map #(keep-in-bounds dt ctx %)))]
;; Do stuff with balls
)
View 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 / a.rb
Created Aug 19, 2012 — forked from ahoward/a.rb
threads are so dang awesome
View a.rb
strategy =
String(ARGV.shift || 'thread')
n =
Integer(ARGV.shift || 4)
mb =
View ui_view_controller_example.rb
class MyGroupedListController < UIViewController
attr_accessor :posts
attr_accessor :sections
class TableViewSection
attr_accessor :title
attr_accessor :items
def initialize(params={})
@title = params[:title]
View gist:141748
require 'thread'
require 'timeout'
class ObjectPool
attr_reader :max
attr_accessor :timeout
attr_accessor :create
attr_accessor :objects
attr_accessor :used
@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
You can’t perform that action at this time.