Skip to content

Instantly share code, notes, and snippets.

@borgar
borgar / .block
Last active April 3, 2024 16:47
PRS B1919+21
license: cc-by-nc-sa-4.0
height: 500
border: no
@borgar
borgar / Tiny JavaScript tokenizer.js
Created June 24, 2010 12:33
A compact tokenizer written in JavaScript.
/*
* Tiny tokenizer
*
* - Accepts a subject string and an object of regular expressions for parsing
* - Returns an array of token objects
*
* tokenize('this is text.', { word:/\w+/, whitespace:/\s+/, punctuation:/[^\w\s]/ }, 'invalid');
* result => [{ token="this", type="word" },{ token=" ", type="whitespace" }, Object { token="is", type="word" }, ... ]
*
*/
@borgar
borgar / uniroot.js
Last active December 28, 2022 02:08
JavaScript port of Brent's method
/**
* Searches the interval from <tt>lowerLimit</tt> to <tt>upperLimit</tt>
* for a root (i.e., zero) of the function <tt>func</tt> with respect to
* its first argument using Brent's method root-finding algorithm.
*
* Translated from zeroin.c in http://www.netlib.org/c/brent.shar.
*
* Copyright (c) 2012 Borgar Thorsteinsson <borgar@borgar.net>
* MIT License, http://www.opensource.org/licenses/mit-license.php
*
@borgar
borgar / .block
Last active June 27, 2022 21:03
Octopus
license: MIT
height: 578
border: no
@borgar
borgar / .block
Last active March 28, 2020 11:57
Population pyramid
license: mit
height: 500
@borgar
borgar / .block
Created October 5, 2016 19:12
Reykjavík Wind Map
license: MIT
height: 600
@borgar
borgar / .block
Last active January 1, 2020 09:18
Possible majority coalitions 2017
license: mit
height: 507
border: no
scrolling: yes
@borgar
borgar / .block
Last active January 1, 2020 09:18
Constituency bias
license: mit
height: 507
border: no
scrolling: yes
@borgar
borgar / .block
Last active January 1, 2020 09:17
Dreifing frambjóðenda á pólitíska rófinu
license: mit
height: 550
border: no
scrolling: no
@borgar
borgar / .block
Last active January 1, 2020 09:16
Election turnout pyramid
license: mit
height: 500
border: no