Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jonasb on github.
  • I am jonasb (https://keybase.io/jonasb) on keybase.
  • I have a public key ASDS77IKb2u5BtI5AAENNNpcCsn_FJPbznTwWr59mB-cJAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am jonasb on github.
  • I am jonasb (https://keybase.io/jonasb) on keybase.
  • I have a public key whose fingerprint is 1C77 58AE 3112 D52A 79A3 097C 66CD A93A 90AC DF84

To claim this, I am signing this object:

@jonasb
jonasb / hash_collisions.php
Created January 7, 2012 18:27
Hash collision benchmark
#!/usr/bin/env php
<?php
//
// Benchmark of adding items to associative array with hash collisions.
//
// generate all permutations of $substrings with $count number of concatenations
function do_generate_strings(array $substrings, array &$strings, $prefix, $count) {
if ($count == 1) {
@jonasb
jonasb / install
Created July 16, 2011 09:11
My dotfiles install script
#!/usr/bin/env ruby
# update git submodules
`git submodule init && git submodule update`
# update symlinks
# inspired by http://errtheblog.com/posts/89-huba-huba
home = File.expand_path('~')
@jonasb
jonasb / e-scraper.py
Created April 1, 2011 23:51
Scraping the e
import lxml.html, urllib2, re
url = "http://www.slv.se/sv/grupp1/Markning-av-mat/Tillsatser-i-mat/E-nummernyckeln---godkanda-tillsatser/"
html = urllib2.urlopen(url).read()
html = html[html.find("<!DOCTYPE"):]
root = lxml.html.fromstring(html)
def extract_text(el):
s = ""
for e in el.itertext():
@jonasb
jonasb / GameOfLife.scala
Created January 25, 2011 22:39
Conway's Game of Life
package gameoflife
object GameOfLife {
def run() {
var g = new Generation(50, 50)
// Blinker
g.set(1, 1, true)
g.set(2, 1, true)
g.set(3, 1, true)