Skip to content

Instantly share code, notes, and snippets.

Avatar

Tobias Baunbæk Christensen freeall

View GitHub Profile
View loop-time.js
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 Mar 6, 2020
Super naive way of testing out the Monty Hall problem
View monty-hall.js
/*
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
*/
View test.js
const a = require('a')
const b = []
b.forEacH(foo => bar(foo))
@freeall
freeall / README.md
Last active Aug 29, 2015
How to query the CVR database
View README.md
  1. mkdir cvr-stuff
  2. cd cvr-stuff
  3. mkdir node_modules
  4. npm install mongojs
  5. touch index.js
  6. add the code
View db.js
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
View db.js
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
View db.js
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
View db.js
/* globals done */
var pg = require('pg');
var conString = 'postgres://pg_logvent:Bow3CuU7foVHbr@localhost/db_logvent';
module.exports = function(options) {
'use strict';
options = options || {};
View auth.js
// server.js
var app = express();
var user = require('user');
var static = require('static');
app.route('/user/*', user);
app.route('/s/*', static);
You can’t perform that action at this time.