Teh Social Netswork!
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(10) NOT NULL
);
INSERT into users VALUES
# 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" || |
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" |
require 'thread' | |
def provider() | |
threads = [] | |
queue = Queue.new | |
1.upto(10).each do |n| | |
threads << Thread.new { | |
sleep rand(0.1..2) | |
queue << n | |
} |
require 'thread' | |
require 'celluloid/io' | |
require 'celluloid/redis' | |
KEY = "magic_key" | |
VALUE = {a: 1, b:2} | |
class RedisActor | |
include Celluloid::IO |
# 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 |
wakeups = [] | |
wakers = [] | |
puts "Creating pipes..." | |
200.times do |n| | |
puts "[#{n}]" | |
wakeup, waker = IO.pipe | |
wakeups << wakeup | |
wakers << waker |
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 |
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) |
Teh Social Netswork!
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(10) NOT NULL
);
INSERT into users VALUES
$ ./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 - |