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
module Jabber | |
def self.read | |
size = $stdin.read(2).unpack(">h") | |
$stdin.read(size).split(':') | |
end | |
def self.write(success) | |
answer = success ? 1 : 0 | |
token = "2#{answer}".pack(">hh") | |
$stdout.write(token) |
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
<chart> | |
<license>L1X6KZSVV27L.NS5T4Q79KLYCK07EK</license> | |
<link> | |
<area url='javascript:full(1800)'/> | |
</link> | |
<chart_data> | |
<row> |
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
thin start --threaded | |
class GeneralController < ApplicationController | |
def queue_size | |
stuff = "" | |
cur = Thread.current | |
MQ.new.queue(params[:id] || 'crawls').status do |messages, consumers| | |
stuff = "#{messages} messages and #{consumers} consumers in #{params[:id] || 'crawls'}" | |
cur.wakeup | |
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
def run() | |
EM.run do | |
connect_subscribe | |
end | |
ensure | |
AsyncObserver::Queue.queue.connection.close { EM.stop_event_loop } | |
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
popper = Proc.new do |headers, msg| | |
if msg == "empty!" | |
sleep 5 | |
else | |
job = OpenStruct.new(:ybody => YAML.load(msg), :body => msg, :stats => [], :job_id => headers.properties[:delivery_tag]) | |
safe_dispatch(job) | |
end | |
AsyncObserver::Queue.queue.pop &popper | |
end | |
AsyncObserver::Queue.queue.pop &popper |
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
Starting all nodes... | |
Starting node rabbit@fame... | |
{error_logger,{{2008,11,18},{22,40,8}},"Protocol: ~p: register/listen error: ~p~n",["inet_tcp",einval]}^M | |
{error_logger,{{2008,11,18},{22,40,8}},crash_report,[[{pid,<0.22.0>},{registered_name,net_kernel},{error_info,{error,badarg}},{initial_call,{gen,init_it,[gen_server,<0.19.0>,<0.19.0>,{local,net_kernel},net_kernel,{rabbit,shortnames,15000},[]]}},{ancestors,[net_sup,kernel_sup,<0.9.0>]},{messages,[]},{links,[<0.19.0>]},{dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,377},{stack_size,21},{reductions,309}],[]]}^M | |
{error_logger,{{2008,11,18},{22,40,8}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[[rabbit,shortnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}^M | |
{error_logger,{{2008,11,18},{22,40,8}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,star |
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
BEGIN; | |
CREATE TEMP TABLE judged AS | |
SELECT images.id AS id, images.url AS url, images.created_at AS created_at, | |
units.#{:norm_ if job.norm}bad_count / units.#{:norm_ if job.norm}judgments_count::decimal AS rating | |
FROM images LEFT OUTER JOIN units ON units.id = images.unit_id | |
WHERE (images.job_id = #{job.id} AND (images.grouped IS NOT true AND images.inappropriate)) | |
ORDER BY rating DESC, id; | |
COPY judged TO STDOUT WITH CSV HEADER; | |
ROLLBACK; |
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
#!/bin/bash | |
# very helpful is: https://help.ubuntu.com/community/IptablesHowTo -brendan | |
# | |
# type: sudo iptables -L to see the current rules | |
# | |
set -eu | |
UPLINK="eth0" | |
# Change this next line so it lists all your network interfaces, including lo |
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
fragments = [ | |
["The %s %s %s", | |
proc do |*args| | |
raise ArgumentError unless args.all{|a| a.respond_to?(:name) && a.respond_to?(:score)} | |
[args[0].name, args[0].score > args[1].score ? "beat the" : "won against", args[1].name] | |
end] | |
] | |
class Team | |
attr_reader :name, :score |
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
{ | |
fields: {awesome:'all', neat:'avg'}, | |
data: { | |
awesome: 1, | |
other: 2, | |
neat: 3 | |
}, | |
worker_id: 123, | |
created_at: some_time, | |
type: 'Judgment', |
OlderNewer