Skip to content

Instantly share code, notes, and snippets.

View x0bandeira's full-sized avatar

Rafael Bandeira x0bandeira

View GitHub Profile
<a href="http://desconf.org/"><img alt="EU VOU na desconf!" src="http://posterous.com/getfile/files.posterous.com/desconf/3B6GXqJJ1yeidq4ctDCK2jaHfp8JICDwXLP1puzqhmTKCHl7hsy8g3IJBkmP/image001.png" width="150" height="168"></a>
[
["1298302885", "1100"],
["1298907685"],
["1299512485", "1100"],
["1300117285", "1000"],
["1300722085", "1100"],
["1301326885", "1100"],
["1301931685"],
["1302536485", "1100"],
["1303141285", "1000"],
@x0bandeira
x0bandeira / subs_sum.clj
Created May 31, 2012 14:00
Weekly Coding Challenge 2012.22 @ TW Brazil
; Weekly Coding Challenge 22 @ ThoughtWorks Brazil
;
; For a given set, find all subsets which the sum
; of its members is the closest smaller value to a
; given number
;
(ns tw.wcc
(:use [clojure.contrib.combinatorics]))
@x0bandeira
x0bandeira / db-config.js
Created October 6, 2012 18:39
Mongo config for local + heroku
var connStr = process.env.MONGOHQ_URL;
var config = {
name: 'database_name',
host: 'localhost',
port: 27017,
opts: {auto_reconnect: true}
};
if (connStr) {
var url = require('url');
@x0bandeira
x0bandeira / robot.js
Created December 8, 2012 03:57
SimpleBeatch
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
# http://redis.io/commands/rpoplpush
module Resque
def self.move_queue(source, destination)
r = Resque.redis
r.llen("queue:#{source}").times do
r.rpoplpush("queue:#{source}", "queue:#{destination}")
end
end
end
entries.each do |e|
begin
do_stuff(e)
rescue => error
$redis.lpush("failed_strip", e.id) # will create the list and/or append the value
end
# counting
puts "failed: " + $redis.llen("failed_strip")
........ ........
........ ........
........ how . big ........
........ ........
........ ----- ----- ........
........ I . |____ ........
........ I | ........
........ ----- ----- ........
........ ........
........ the conclusion...? ........