Skip to content

Instantly share code, notes, and snippets.

View boukeversteegh's full-sized avatar

Bouke Versteegh boukeversteegh

View GitHub Profile
sites:
apidoc:
scheme: http
host: apidoctest.elephone.vb
api:
scheme: http
host: api.elephone.vb
nginx_sites:
<<<<<<< HEAD
@boukeversteegh
boukeversteegh / haar.py
Last active October 23, 2017 16:19
Haar Filter, Reversible Discrete Wavelet Transform
import math
import sys
'''
python haar.py
python haar.py 1 5 3 1
'''
def wrap(value, ubound):
/* TRIANGLE */
.triangle {
width: 0;
height: 0;
border-width: 10px;
border-style: solid;
border-color: transparent;
font-size: 0;
}
@boukeversteegh
boukeversteegh / BADPS.md
Last active November 7, 2015 16:53
[DRAFT] Bitcoin Address Discovery Protocol over SMS

Bitcoin Address Discovery Protocol over SMS


Title:   Bitcoin Address Discovery Protocol over SMS
Author:  Bouke Versteegh <[email protected]>
Status:  Draft
Created: 2014-03-14
<?php
abstract class DefaultController {
public function read($id) {
if( empty($id) ) {
throw Exception("No ID specified!");
}
$this->_read($id);
}
public abstract function _read($id);
@boukeversteegh
boukeversteegh / gist:5849167
Created June 24, 2013 10:29
Bookmarklet to switch EN/NL on wikipedia
javascript:document.location = $('[href^="//' + ['nl', 'en'][0+(document.location.host.substr(0,2)=="nl")] + '.wikipedia.org"]').attr('href');
@boukeversteegh
boukeversteegh / functionalprogramming.py
Last active December 17, 2015 02:09
How to do functional programming in Python
import inspect
# Callable class to wrap functions
class F:
def __init__(self, func, *args):
self.func = func
self.args = args
# Currying
class Gate {
protected:
Out outputs[];
public:
virtual void propagate();
};
void Gate::propagate() {
int noutputs = sizeof(this->outputs)/sizeof(*(this->outputs));
cout << noutputs << " outputs.";
import multiprocessing
# Define a function
square = lambda x: x**2
if __name__ == "__main__":
mylist = [1, 2, 3, 4, 9, 2, 5, 2, 7, 0, 5, 4, 1, 3, 5, 7]
# Create a pool with 8 multicore threads
# Apply the function to all arguments in the list
# Given a position (x,y), returns next position in a grid spiral.
def next(pos):
x, y = pos
top = False
right = False
bottom = False
left = False
horizontal = abs(x) <= abs(y)
vertical = abs(y) <= abs(x)