Skip to content

Instantly share code, notes, and snippets.

@lancejpollard
lancejpollard / index.md
Created March 15, 2012 18:12
Math for Coders

Sets =~ Arrays

A set is basically an array of unique items.

(A,B)

Ordered set.

[1, 2] != [2, 1]
class Lisp
def initialize
@env = {
:label => lambda { |(name,val), _| @env[name] = val },
:quote => lambda { |sexpr, _| sexpr[0] },
:car => lambda { |(list), _| list[0] },
:cdr => lambda { |(list), _| list.drop 1 },
:cons => lambda { |(e,cell), _| [e] + cell },
:eq => lambda { |(l,r), _| l == r },
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) },
@panicsteve
panicsteve / gist:1641705
Created January 19, 2012 18:26
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
@antirez
antirez / README
Created October 2, 2011 21:08
antirez hashing function #1
Description of AHF1 algorithm:
Initialize the four bytes H[0], H[1], H[2], H[3] to respectively 8D CA 2E 35
Initialize IDX to 0
For each byte B in the string to hash:
TARGET = (B XOR H[IDX]) MOD 4
H[TARGET] = H[TARGET] XOR B
@dchest
dchest / meet.c
Created July 3, 2011 18:10
Example of meet-in-the-middle attack (in C)
/* Written by Dmitry Chestnykh. Public domain. */
#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <openssl/blowfish.h>
#include <openssl/lhash.h>
/* Encryption and decryption */