Skip to content

Instantly share code, notes, and snippets.

var ouis = ["oui", "ouip", "ouaip", "yup", "yep", "yes", "ouai", "oua", "ouain"];
function LinearOuiHashTable(size, prime) {
this.content = [];
this._prime = prime;
for (var i = 0; i < size; i++)
this.content.push([]);
this.insert = (oui) => {
@Spuffynism
Spuffynism / BrainfuckCompiler.java
Created December 22, 2017 22:03
Brainfuck Java compiler
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class BrainfuckCompiler {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
sb.append("import java.util.Scanner;\n");
sb.append("public class BrainfuckProgram {\n");
@Spuffynism
Spuffynism / black-flag.js
Last active February 3, 2018 23:02
Unpostable Dwitts — https://www.dwitter.net/
// 177
c.width=1920;e=S(t)*200;a=b=>750+b*90+e;x.font="bold 80px Times"
x.fillText("BLACK",750+e,380)
x.fillText("FLAG",880+e,680)
for(i=0;i<4;)x.fillRect(a(i++),i%2==0?385:400,80,220)
// 174
c.width=1920
x.font="bold 80px Times"
a=(u,v,w)=>x.fillText(u,v,w)
@Spuffynism
Spuffynism / pomme-de-terre.py
Last active December 31, 2017 06:00
very quick and dirty pomodoro timer
import sys
import time
import datetime
from enum import Enum
class TimerType(Enum):
POMODORO = (30, )
PAUSE = (5, )
@Spuffynism
Spuffynism / do-u-no-da-wei.js
Last active January 22, 2018 22:06
do you know the way generator
// this is a do-you-know-the-way sentence generator
var words = [
["do"],
["you", "u"],
["know", "no", "kno"],
["da", "de", "the"],
["way", "wey", "wei", "wae"]],
combinations = [],
combinationNb = words.reduce((acc, v) => acc * v.length, 1);
@Spuffynism
Spuffynism / tupper-printer.js
Last active February 5, 2018 21:28
prints tupper formula's k value
<script>
// tupper formula's k value, in binary
var kbin = "0011001010100010000101010101111100001001001010000000000000000000000000000000100000000000000010100000000000001000100000000000000000000000111111111111111111000000000000000010000011110000000000000000100000000000001110000000000000000010000000000000111000000000000000000000000000000001100000000000000100100000000000001001000000000000001100000000000000000000000000000000110000000000000010010000000000000100100000000000001111110000000000000000000000000001111111000000011100000001110011000000000000011000000000000000001111111111111111010000000000000000101111101000000000000000010101100000110010100100000100011101000110001000000000000000011111111111111110000000000000000000000001100100000000000010100100000000000100101000000000001000100010000000000000000100000000000000000000000000000001111100000000000000000000000000000110010000000000000011100000000000000000000000000111111110000000001000000000000000010010100000000000000010000000000001001010000000000010000000000000000111
@Spuffynism
Spuffynism / binary-tree-roadtrip.ml
Last active February 9, 2018 03:39
binary tree visiting algorithms
type 'a binary_tree = Leaf | Node of 'a * 'a binary_tree * 'a binary_tree;;
let visit_binary_tree tree (visiting_function:'a binary_tree -> 'a list) :'a list = match tree with
| Leaf -> []
| Node (_, _, _) -> visiting_function tree;;
(*
1
/ \
2 3
@Spuffynism
Spuffynism / heap.js
Created February 19, 2018 16:39
heap
let parent = (t, i) => t[((i + 1)>>1) - 1];
let kids = (t, i) => [t[2*i + 1],t[(i+1)*2]]
@Spuffynism
Spuffynism / dummy-web-server.py
Last active July 4, 2018 22:31 — forked from bradmontgomery/dummy-web-server.py
A minimal http server in python. Responds to GET and POST requests
#!/usr/bin/env python
"""
Very simple HTTP server.
Upon a GET or POST request, returns a json object with the route of the request
and the data of the request body.
"""
import socket
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
@Spuffynism
Spuffynism / vector.js
Created April 21, 2018 16:51
Simple vector implementation in js to help with amortized analysis
function Vector() {
this.capacity = 1;
this.elements = new Array(this.capacity);
this.size = 0;
this.add = (element) => {
if (this.size > this.capacity)
console.err('this.size > this.capacity');
if (this.size === this.capacity) {