Skip to content

Instantly share code, notes, and snippets.

Rodrigo Navarro reu

View GitHub Profile
View future.rb
# This class implements async evaluation by transparently executing the block on a different thread.
class Future < Lazy
def initialize(&block)
@attribute =
@thread = { @attribute.__send__(:__call__) }
def __call__
reu / array-unique.js
Last active Aug 29, 2015
View array-unique.js
Array.prototype.unique = function() {
return this.filter(function(value, index, array) {
return array.indexOf(value) === index;
reu / functional.js
Last active Aug 29, 2015
Some building blocks for functional programming in Javascript
View functional.js
function curry(fn) {
var arity = fn.length,
args =, 1);
function accumulator() {
var leftArgs = args.concat(, 0));
if (leftArgs.length >= arity) {
return fn.apply(this, leftArgs);
} else {
View cgiup.rb
#!/usr/bin/env ruby
require "webrick"
unless ARGV[0]
STDERR.puts "Usage: cgiup [PATH TO CGI SCRIPT]"
exit 1
cgi_script = File.expand_path(ARGV[0])
View luminance.rb
def luminance(color = "FFFFFF")
r, g, b = color.chars.each_slice(2).map(&:join).map(&:hex)
r * 0.299 + g * 0.587 + b * 0.114
reu /
Created Feb 8, 2015
Princenton University Algorithms Cousera course unit tests
import static org.junit.Assert.*;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.junit.Before;
import org.junit.Test;
public class DequeTest {
private Deque<String> deque;
reu / fib.clj
Created Jun 21, 2015
Infinite Fibonacci sequence
View fib.clj
(def fib-seq
((fn fib [a b] (cons a (lazy-seq (fib b (+ b a))))) 1 1))
reu /
Last active Aug 29, 2015
Gulp plugin to pre-process HTML template includes.

Gulp Template

This plugin allows you to directly include HTML templates into a Javascript file.


Given the following template:


<h1 class="title">
View authentication.rb
require "rubygems"
require "ldap"
require "net/ldap"
email = ""
password = "secret"
host = ""
treebase = "ou=bluepages,"
filter = "(&(objectClass=person)(mail=#{email}))"
View inject_example.rb
# Classic approach
def check_for_truth
has_at_least_one_true = false # ewwww temp var
[false, false, true].each do |option|
has_at_least_one_true = option
You can’t perform that action at this time.