- mkdir cvr-stuff
- cd cvr-stuff
- mkdir node_modules
- npm install mongojs
- touch index.js
- add the code
View loop-time.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
View monty-hall.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const a = require('a') | |
const b = [] | |
b.forEacH(foo => bar(foo)) |
View README.md
View db.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server.js | |
var app = express(); | |
var user = require('user'); | |
var static = require('static'); | |
app.route('/user/*', user); | |
app.route('/s/*', static); | |
View test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
og noget emre |