Skip to content

Instantly share code, notes, and snippets.

View reu's full-sized avatar

Rodrigo Navarro reu

View GitHub Profile
@reu
reu / DequeTest.java
Created February 8, 2015 16:08
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
reu / denodify.js
Last active July 11, 2017 09:41
Convert any NodeJS async function into a Promise
module.exports = function denodify(fn) {
return function() {
var self = this;
var args = Array.prototype.slice.call(arguments);
return new Promise(function(resolve, reject) {
args.push(function(error, result) {
error ? reject(error) : resolve(result);
});
@reu
reu / index.js
Created April 24, 2015 22:06
Node simple static file server.
var http = require("http");
var fs = require("fs");
var mime = require("mime-types");
var server = http.createServer(function(req, res) {
var path = "." + req.url;
fs.stat(path, function(error, stats) {
if (error) {
res.writeHead(404);
@reu
reu / fib.clj
Created June 21, 2015 04:46
Infinite Fibonacci sequence
(def fib-seq
((fn fib [a b] (cons a (lazy-seq (fib b (+ b a))))) 1 1))
@reu
reu / README.md
Last active August 29, 2015 14:27
Gulp plugin to pre-process HTML template includes.

Gulp Template

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

Example

Given the following template:

template.html

@reu
reu / README.md
Created September 8, 2015 15:55
Scala underscore in Ruby

Scala's Undersore in Ruby

Yeah, Ruby is awesome:

# Without underscore
[1, 2, 3].map { |i| i + 1 }
[{ name: "Sasha" }, { name: "Tori" }].map { |actress| actress[:name] }

# With underscore
@reu
reu / rm-codeplane-user.rb
Last active September 14, 2015 13:44
Removes an user from all repositories of a Codeplane account
#!/usr/bin/env ruby
require "rubygems"
require "codeplane"
require "optparse"
Codeplane.configure do |config|
ARGV.options do |opts|
opts.on("-u", "--user=username", String) { |val| config.username = val }
opts.on("-p", "--api-key=key", String) { |val| config.api_key = val }
@reu
reu / README.md
Created September 16, 2015 17:27
Ruby Globe

Run with while true; do clear; ruby a.rb | tee b.rb; sleep 1; mv -f b.rb a.rb; done

@reu
reu / response-to-object.js
Created September 23, 2015 14:41
Simple Angular function to convert underline case object keys to camel case
(function(angular) {
function underlineToCamelCase(string) {
return string.replace(/(\_[a-z])/g, function(match) {
return match.toUpperCase().replace("_", "");
});
}
function convertToCamelCaseObject(object) {
if (typeof object != "object") return object;
@reu
reu / load.rb
Created January 7, 2016 01:05
HTTPS load testing
require "socket"
require "openssl"
require "thread"
require "thwait"
require "benchmark"
require "optparse"
require "net/http"
require "csv"
require "uri"