Skip to content

Instantly share code, notes, and snippets.

View theleoborges's full-sized avatar

Leonardo Borges theleoborges

View GitHub Profile
public enum Clazzes {
param1 ("java.lang.String"),
param2 ("java.util.ArrayList");
private final String clazz;
Clazzes(String clazz) {
this.clazz = clazz;
}
public Object get() throws Exception {
return Class.forName(clazz).newInstance();
@theleoborges
theleoborges / gist:996758
Created May 28, 2011 09:58
A few useful git commands
#undo last commit
git reset HEAD^
#show files in a given commit
git show --pretty="format:" --name-only rev_number
#remove untracked files and directories
git clean -f -d
#track remote branch
@theleoborges
theleoborges / gist:1686173
Created January 27, 2012 00:42 — forked from boundvariable/gist:1685985
Chapter 5 example
//I guess I'd go with straight functions into a module you could mixin or use directly OR objects...
//On the first option, something like this:
var app = app || {};
app.server = app.server || {};
app.server.http = function() {...};
app.server.get = function() {...};
app.server.post = function() {...};
//And for the second option:
@theleoborges
theleoborges / DepthJS setup
Created April 29, 2012 11:41 — forked from gabriel/DepthJS setup
xcode jpeg tiff dylib fix
# Install ZeroMQ
sudo brew install zmq
easy_install pyzmq
[0] http://www.zeromq.org/bindings:python
# Install OpenCV
sudo brew install opencv
# Install libusb
@theleoborges
theleoborges / robot.js
Created December 3, 2012 03:28
MassiveDestructionMachine
//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.rotateCannon(90);
@theleoborges
theleoborges / func_fizzbuzz.rb
Last active December 17, 2015 20:28
Functional Fizz Buzz in Ruby 2.0
threes = ["", "", "fizz"].cycle.lazy
fives = ["", "", "", "", "buzz"].cycle.lazy
(1..Float::INFINITY).lazy.zip(threes, fives).map{|n,f,b|
if f.empty? && b.empty?
return n
elsif f.empty?
return b
else
return [f,b].join
(require '[clojure.core.async :as async :refer :all])
(defn fake-search [kind]
(fn [query]
(Thread/sleep (int (* (java.lang.Math/random) 1000)))
(str kind " result for " query)))
(def web (fake-search "Web"))
(def image (fake-search "Image"))
(def video (fake-search "Video"))
;; This is short but in case of a failure, it's harder to pinpoint which bit is wrong.
(is (= (balance tree)
[:red
[:black
[:black nil "a" nil]
"x"
[:black nil "b" nil]]
"y"
[:black
@theleoborges
theleoborges / monads.clj
Last active August 29, 2015 13:56
Monads in Clojure talk
;; Slides at: http://www.slideshare.net/borgesleonardo/monads-in-clojure
;; The list Monad
(def list-m {
:return (fn [v] (list v))
:bind (fn [mv f]
(mapcat f mv))
})
(defn combinations []

Keybase proof

I hereby claim:

  • I am leonardoborges on github.
  • I am leonardoborges (https://keybase.io/leonardoborges) on keybase.
  • I have a public key whose fingerprint is CD7B F319 99AE 74FF 4D3B 86CD B71B 49D1 0F1B F2EE

To claim this, I am signing this object: