This file contains 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 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], |
This file contains 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
(let [dt (elapsed-time t) | |
balls (->> balls | |
(map #(move % dt)) | |
(map #(keep-in-bounds dt ctx %)))] | |
;; Do stuff with balls | |
) |
This file contains 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
def process(input) | |
commands = { | |
'q' => -> { puts 'Goodbye' }, | |
'tweet' => -> { puts 'tweeting' }, | |
'dm' => -> { puts 'direct messaging' }, | |
'help' => -> { puts 'helping' } | |
} | |
commands.fetch(input, -> {}).call() | |
end |
This file contains 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
strategy = | |
String(ARGV.shift || 'thread') | |
n = | |
Integer(ARGV.shift || 4) | |
mb = |
This file contains 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 MyGroupedListController < UIViewController | |
attr_accessor :posts | |
attr_accessor :sections | |
class TableViewSection | |
attr_accessor :title | |
attr_accessor :items | |
def initialize(params={}) | |
@title = params[:title] |
This file contains 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
require 'thread' | |
require 'timeout' | |
class ObjectPool | |
attr_reader :max | |
attr_accessor :timeout | |
attr_accessor :create | |
attr_accessor :objects | |
attr_accessor :used | |
This file contains 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
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 |