Skip to content

Instantly share code, notes, and snippets.

View x0bandeira's full-sized avatar

Rafael Bandeira x0bandeira

View GitHub Profile
@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);
@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 / 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]))
[
["1298302885", "1100"],
["1298907685"],
["1299512485", "1100"],
["1300117285", "1000"],
["1300722085", "1100"],
["1301326885", "1100"],
["1301931685"],
["1302536485", "1100"],
["1303141285", "1000"],
<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>
##
# odd difference between Ruby's AND comparison operators: '&&' and 'and'
##
# with '&&' it will throw an error expecting 'end' after params.include?
if request.post? && request.params.include? 'post_param' then
end
# with 'and' it will work fine and you'll call the day for a beer
if request.post? and request.params.include? 'post_param' then
$ sudo ln -s /usr/lib/ruby/gems/1.9.1/gems/rack-test-0.5.4/ /var/lib/gems/1.9.1/gems/
$ gem which rack
/var/lib/gems/1.9.1/gems/rack-1.2.1/lib/rack.rb
$ gem which rack/test
/usr/lib/ruby/gems/1.9.1/gems/rack-test-0.5.4/lib/rack/test.rb
$ touch test.rb
$ echo "require 'rack/test'" >> test.rb
$ ruby test.rb
$ sudo gem install rack-test