Skip to content

Instantly share code, notes, and snippets.

@jfacorro
jfacorro / loop-let.clj
Last active March 6, 2017 23:24
loop macro, wrapping let
(require '[clojure.walk :as walk])
(walk/macroexpand-all '(loop [[x & xs] xs a 3]))
(let* [G__1249 xs
vec__1250 G__1249
x (clojure.core/nth vec__1250 0 nil)
xs (clojure.core/nthnext vec__1250 1)
a 3]
(loop* [G__1249 G__1249 a a]
(let* [vec__1251 G__1249
@jfacorro
jfacorro / pattern.erl
Created February 26, 2017 12:50
Pattern matching in function arguments
-module(pattern).
-export([is_equal/2]).
is_equal(X,X) -> 1;
is_equal(X,Y) -> 0.
@jfacorro
jfacorro / hoare-emperors-clothes.md
Last active September 7, 2016 15:10
The Emperor's Old Clothes - by C.A.R. Hoare - Communications of the ACM, 1981

The Emperor's Old Clothes

By C.A.R. Hoare

Communications of the ACM, 1981

My first and most pleasant duty in this lecture is to express my profound gratitude to the Association for Computing Machinery for the great honor which they have bestowed on me and for this opportunity to address you on a topic of my choice. What a difficult choice it is! My scientific achievements, so amply recognized by this award, have already been amply described in the scientific literature. Instead of repeating the abstruse technicalities of my trade, I would like to talk informally about myself, my personal experiences, my hopes and fears, my modest successes, and my rather less modest failures. I have learned more from my failures than can ever be revealed in the cold print of a scientific article and now I would like you to learn from them, too. Besides, failures are much more fun to hear about afterwards; they are not so funny at the time.

I start my story in August 1960, when I became a programmer with a small computer

@jfacorro
jfacorro / LoopingStackTrace
Last active January 2, 2016 18:29
Looping StackTrace
createClassLoader
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Unknown Source)
at user$fn__1$fn__2.invoke(NO_SOURCE_FILE:7)
at user.proxy$java.lang.SecurityManager$0.checkPermission(Unknown Source) ---- Second call to checkPermission
at java.lang.SecurityManager.checkCreateClassLoader(Unknown Source)
at user.proxy$java.lang.SecurityManager$0.checkCreateClassLoader(Unknown Source)
at java.lang.ClassLoader.checkCreateClassLoader(Unknown Source)
at java.lang.ClassLoader.<init>(Unknown Source)
at sun.reflect.DelegatingClassLoader.<init>(Unknown Source) ---- Java creates a new ClassLoader
@jfacorro
jfacorro / missing_otp_17.5.txt
Created November 25, 2015 15:04
Erldocs - OTP 17.5 - Missing .erl source files (and specs)
====== /Users/jfacorro/.kerl/builds/17.5/otp_src_17.5/erts ======
driver_entry
erl_driver
erl_nif
erl_prim_loader
erlang
erts_alloc
init
zlib
====== /Users/jfacorro/.kerl/builds/17.5/otp_src_17.5/lib/tools ======
@jfacorro
jfacorro / BPMDetect in Android.c
Created July 17, 2012 17:51
Usage of soundtouch's BPMDetect for android
#include <jni.h>
#include <android/log.h>
#include <stdlib.h>
#include <BPMDetect.h>
#include "FMODSystem.h"
#include "FMODSound.h"
#include "FMODDspBpm.h"
#include "fmod.h"
#include "fmod_dsp.h"
#include "fmod_errors.h"

Keybase proof

I hereby claim:

  • I am jfacorro on github.
  • I am facorro (https://keybase.io/facorro) on keybase.
  • I have a public key whose fingerprint is 0764 32BC 4F55 907C F9EF C768 C126 40D0 BB42 3FC6

To claim this, I am signing this object:

@jfacorro
jfacorro / mapa.erl
Created June 8, 2015 18:29
Campeones - Erlang Dojo 2105
-module(mapa).
-behaviour(gen_server).
-compile(export_all).
init (_) ->
process_flag(trap_exit, true),
{ok, []}.
terminate(R, S) ->
io:format("R = ~p, S = ~p~n", [R, S]),

Serpents

Multi-Player Game on top of HDP protocol

The Protocol

The HDP protocol consists on 5 different messages types that share a common header with some basic user information. The protocol is defined with BNFs where ALL_CAPS_IMPLY_CONSTANTS, camelCaseImplyPrimitives and the '&' is used to denote "bitwise or" (super intuitive right?) while '|' denotes that one of multiple options can be chosen.

The Client Message Header

@jfacorro
jfacorro / HTTP.md
Last active August 29, 2015 14:22
HTTP Serpents

RESTful API for Serpents

Endpoints

POST /api/games/:game_id/serpents

To create a serpent (i.e. join a game)

Parameters

All parameters are required