Skip to content

Instantly share code, notes, and snippets.

View freeall's full-sized avatar

Tobias Baunbæk Christensen freeall

View GitHub Profile
const testLength = Number(process.argv[2] || 10000000)
console.log('Loop speed test')
console.log(`Initiating array with ${testLength} items`)
const arr = new Array(testLength).fill(1)
time(loopSimple)
time(loopForIn)
time(loopForOf)
@freeall
freeall / monty-hall.js
Last active March 6, 2020 08:08
Super naive way of testing out the Monty Hall problem
/*
A quick stab at writing the Monty Hall problem, and testing out if it does indeed
give a 1/3 chance if you don't change the doors, but a 2/3 chance if you do.
https://en.wikipedia.org/wiki/Monty_Hall_problem
Running this, unsurprisingly, gives something like:
No change: 100000 runs. 33229 correct guesses. 33.23% correct
Change: 100000 runs. 66631 correct guesses. 66.63% correct
*/
const a = require('a')
const b = []
b.forEacH(foo => bar(foo))
@freeall
freeall / db.js
Last active January 4, 2016 16:28
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
@freeall
freeall / db.js
Last active January 4, 2016 16:19
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
@freeall
freeall / db.js
Last active January 4, 2016 16:19
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
@freeall
freeall / auth.js
Last active December 14, 2015 12:58 — forked from mafintosh/auth.js
// server.js
var app = express();
var user = require('user');
var static = require('static');
app.route('/user/*', user);
app.route('/s/*', static);
@freeall
freeall / test.js
Created December 4, 2012 16:49
some test
og noget emre
@freeall
freeall / README.md
Last active August 29, 2015 14:13
How to query the CVR database
  1. mkdir cvr-stuff
  2. cd cvr-stuff
  3. mkdir node_modules
  4. npm install mongojs
  5. touch index.js
  6. add the code