Skip to content

Instantly share code, notes, and snippets.

STDOUT.sync = true
require 'queue'
start_time = Time.now.to_i
msg = 0
queue = Queue.new("testing")
queue.subscribe do |obj|
msg += 1
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <ilya@igvita.com>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
app/models/widget.rb | 2 ++
config.ru | 1 +
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World\n");
response.close();
});
var http = require('http');
var google = http.createClient(80, 'www.google.com');
var request = google.request('GET', '/',
{'host': 'www.google.com'});
request.end();
request.on('response', function (response) {
console.log('STATUS: ' + response.statusCode);
console.log('HEADERS: ' + JSON.stringify(response.headers));
response.setEncoding('utf8');
response.on('data', function (chunk) {
Twitter: { user: { name: { formatted: 'Jim Van Fleet' } , photo: 'http://a0.twimg.com/profile_images/1096124084/Jim-Avatar_punchout_normal.gif' , displayName: 'Jim Van Fleet' , preferredUsername: 'bigfleet' , url: 'http://twitter.com/bigfleet' , providerName: 'Twitter' , identifier: 'http://twitter.com/account/profile?user_id=3123671'
Facebook: { user: { verifiedEmail: 'jim@jimvanfleet.com' , name: { givenName: 'Jim' , familyName: 'Fleet' , formatted: 'Jim Van Fleet' } , photo: 'http://graph.facebook.com/578726210/picture?type=large' , displayName: 'Jim Van Fleet' , preferredUsername: 'JimVanFleet' , url: 'http://www.facebook.com/bigfleet' , gender: 'male' , utcOffset: '-04:00' , providerName: 'Facebook' , identifier: 'http://www.facebook.com/profile.php?id=578726210' , email: 'jim@jimvanfleet.com
Google: { user: { googleUserId: '116388720626466295225' , verifiedEmail: 'jim.van.fleet@gmail.com' , name: { givenName: 'Jim' , familyName: 'Van Fleet' , formatted: 'Jim Van Fleet' } , displayName: 'jim.van.fleet' ,
When /^the mail queue is processed$/ do
mcount = Resque.size("mailer")
mcount.times do |m|
Resque::Worker.new("mailer").process
end
end
@bigfleet
bigfleet / union-find.md
Created April 5, 2012 18:03
Union find pseudocode instruction

Consider a 10x10 array that represents the coordinate system for a maze. I'll call each individual space in the array a cell.

To generate a maze, consider each cell as having "walls" up in each direction, indicating no ability to pass into it or from it. Assign each cell a unique number. In this scheme, when two cells have the same number, it indicates that you may pass from one cell to the other, either directly or through other cells. The success condition is when every cell has the same number-- at this point, you will have a perfectly traversable coordinate system. You can pick two random "edges" of the coordinates and relax the wall to the outside world to have entry and exit.

To apply the algorithm, begin with the fully partitioned system. Pick a cell. Check its neighbors to see if one of them has a different set number. If it's only one, lower the wall, and change all cells that are represented by one of the numbers to the other number. If there is more than one, choose between the choices rando

@bigfleet
bigfleet / order.txt
Created June 12, 2012 15:07
Jimmy John's order
http://www.jimmyjohns.com/menu/menu.aspx
Tim Berglund: #11 Unwich
Thomas Lattimore:
Scott Deeter: #5, no tomato
Mark Shropshire: JJBLT
Denny Abraham: #9 with hot peppers
Kevin Mussleman: #9 no onions, cut in half
Glenn Goodrich: #12 without tomato
Duncan Mapes: #14
@bigfleet
bigfleet / querying.citrus
Last active October 12, 2018 06:15
My citrus effort
grammar Querying
rule statement
(compound_predicate | predicate)
end
rule compound_predicate
(predicate space* operator_and_predicate){
Wither::CompoundPredicate.new(predicate.value,
operator_and_predicate.group_operator.value,
mike@rbci:~$ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1