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
# Running on OS X | |
# JRuby + Celluloid = OK | |
# MRI + Celluloid = OK | |
# JRuby + Celluloid::IO = OK | |
# MRI + Celluloid::IO = Too many open files - pipe (Errno::EMFILE) | |
require 'celluloid/io' | |
class SimpleActor | |
# include Celluloid # Creating regular Celluloid actors works on MRI |
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 'celluloid/io' | |
require 'celluloid/redis' | |
KEY = "magic_key" | |
VALUE = {a: 1, b:2} | |
class RedisActor | |
include Celluloid::IO |
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' | |
def provider() | |
threads = [] | |
queue = Queue.new | |
1.upto(10).each do |n| | |
threads << Thread.new { | |
sleep rand(0.1..2) | |
queue << n | |
} |
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 AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@stuff = [] | |
NSTimer.scheduledTimerWithTimeInterval(3, target: self, selector: "crash", userInfo:nil, repeats: true) | |
NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: "burn", userInfo:nil, repeats: true) | |
true | |
end | |
def crash | |
puts "crash" |
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
# Nothin' special here: just Resig's pretty date function ported to Ruby | |
# http://ejohn.org/blog/javascript-pretty-date/ | |
def pretty_date(stamp) | |
now = Time.new | |
diff = now - stamp | |
day_diff = ((now - stamp) / 86400).floor | |
day_diff == 0 && ( | |
diff < 60 && "just now" || |
NewerOlder