Skip to content

Instantly share code, notes, and snippets.

View ReaperUnreal's full-sized avatar

Guillaume Couture-Levesque ReaperUnreal

View GitHub Profile
@ReaperUnreal
ReaperUnreal / gist:1409567
Created November 30, 2011 15:51
Fun times...
(define (product los1 los2)
(define (product-elem los e)
(if (eq? los `())
`()
(cons (list (car los) e)
(product-elem (cdr los) e))))
(if (eq? los1 `())
`()
(append (product-elem los2 (car los1))
(product (cdr los1) los2))))
@ReaperUnreal
ReaperUnreal / gist:1411625
Created November 30, 2011 22:56
Wrote a flatten function. Witness!
(define (join-list lst1 lst2) #! Wrote my own append just because I could
(define (append-item lst item)
(if (eq? lst `())
(list item)
(cons (car lst) (append-item (cdr lst) item))))
(if (eq? lst2 `())
lst1
(if (list? lst2)
(join-list (append-item lst1 (car lst2)) (cdr lst2))
(append-item lst1 lst2))))
@ReaperUnreal
ReaperUnreal / gist:1560352
Created January 4, 2012 14:50
friday the 13 calculator
#lang racket
; stream stuff
(define (make-stream proc init)
(cons proc init))
(define (eval-stream s)
(cdr s))
(define (next-stream s)
@ReaperUnreal
ReaperUnreal / gist:1602418
Created January 12, 2012 19:04
Palli Interview Rough Translation
What happened that you started to play with you jojo?
In elementary school I started to spend with me jojo I had
been give n and then I went online and saw videos of people
do disgusting fl Ott tricks. I wanted to immediately learn that trick
so I ordered me a good jojo online and started training me
in full. After two years I was a good single on it and then
way has been upward.
What do you have to be able with jojo?
You have to have ngrafi fi mi and so this is all muscle memory.
Patience is also important because some tricks are very annoying
@ReaperUnreal
ReaperUnreal / gist:2116799
Created March 19, 2012 15:46
Bunch of hash functions
unsigned int djb2(const char *text, int len)
{
unsigned int hash = 5381;
int c;
while(c = *text++)
hash = ((hash << 5) + hash) + c;
return hash;
}
var obj = {
val: 0,
double: function() {
function helper() {
this.val += this.val; //this refers to global scope
}
helper();
}
};
int mask = (1 << __popcnt(v)) - 1;
return (~n) & mask;
@ReaperUnreal
ReaperUnreal / gist:3885276
Created October 13, 2012 16:37
Compromised Tweet
HTTP/1.1 200 OK
X-Transaction:
a09713e0086a75d9
X-RateLimit-Remaining:
19997
Content-Length:
1807
X-RateLimit-Limit:
20000
@ReaperUnreal
ReaperUnreal / gist:3907218
Created October 17, 2012 18:30
fizzbuzz++
void fizzbuzz(int n)
{
static bool firstRun = true;
if(firstRun)
{
std::sort(table);
firstRun = false;
}
char buffer[MAX_CHAR];
buffer[0] = '\0';
@ReaperUnreal
ReaperUnreal / qr.cpp
Created October 26, 2012 20:49
QR Decomposition of 3x3 Matrix Using Householder Reflections
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void printMatrix3x3(float *mat)
{
printf("%0.3f\t%0.3f\t%0.3f\n", mat[0], mat[1], mat[2]);
printf("%0.3f\t%0.3f\t%0.3f\n", mat[3], mat[4], mat[5]);
printf("%0.3f\t%0.3f\t%0.3f\n", mat[6], mat[7], mat[8]);
printf("\n");