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 'spec_helper' | |
require 'sidekiq' | |
require 'sidekiq/middleware/chain' | |
require 'sidekiq/fetch' | |
require 'sidekiq/processor' | |
require 'redis/namespace' | |
redis_url = 'redis://localhost/15' | |
client = Redis.connect(:url => redis_url) |
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
$ ./flora2/runflora | |
% Specialising partially instantiated calls to flora_assert_directories/1 | |
[Compiling Foreign Module /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog (Prolog compiler options are ignored)] | |
[prolog2hilog compiled, cpu time used: 0.0010 seconds] | |
[Compiling C file /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.c using gcc] | |
/Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.c:365:9: warning: comparison of 0 > unsigned expression is always false [-Wtautological-compare] | |
if (0 > length_diff) return FALSE; | |
~ ^ ~~~~~~~~~~~ | |
1 warning generated. | |
gcc -dynamiclib -undefined dynamic_lookup -fPIC -o /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.dylib /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.c -Wall -fPIC -I/Users/felix/Documents/code/flora2/flora2bundle/XSB/emu -I/Users/felix/Documents/code/flora2/flora2bundle/XSB/config/i386-apple-darwin13.2.0 -O3 -fno-strict-aliasing - |
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
server { | |
listen [::]:80; | |
listen 80; | |
server_name $NOSSL_SERVER_NAME; | |
location / { | |
proxy_pass http://$APP; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade \$http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host \$http_host; |
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" || |
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
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
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
wakeups = [] | |
wakers = [] | |
puts "Creating pipes..." | |
200.times do |n| | |
puts "[#{n}]" | |
wakeup, waker = IO.pipe | |
wakeups << wakeup | |
wakers << waker |
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 'benchmark' | |
def insert_then_sort(results, missing_items) | |
missing_items.each do |id| | |
results << {id: id, val: nil} | |
end | |
results.sort_by!{|item| item[:id] } | |
results | |
end |
OlderNewer