Skip to content

Instantly share code, notes, and snippets.

View stephenmathieson's full-sized avatar

Stephen Mathieson stephenmathieson

View GitHub Profile
@stephenmathieson
stephenmathieson / rock-paper-scissors.html
Created February 8, 2013 14:53
harris' rock paper scissors
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Rock, Paper, Scissors</title>
<script>
var options = [ 'rock', 'paper', 'scissors' ],
userChoice = null,
computerChoice = null,
'use strict';
var fs = require('fs')
, file = './foo'
function write() {
fs.writeFile(file, Math.random() + '!')
}
for (var i = 0; i < 5000; i++) {
@stephenmathieson
stephenmathieson / master.js
Created June 26, 2013 14:58
cluster management concept
'use strict';
var cluster = require('cluster'),
cpus = require('os').cpus().length;
function single() {
require('./worker');
}
for b in `git branch --merged | grep -v \*`; do git delete-branch $b; done
@stephenmathieson
stephenmathieson / ie8-tables-and-colons.js
Created December 11, 2013 19:12
IE8 incorrectly reports `Object#hasOwnProperty(<table>, ':')` as true
// Element#hasOwnPropery doesn't exist in IE8
var has = Object.prototype.hasOwnProperty;
var table = document.createElement('table');
alert('this browser sucks: ' + has.call(table, ':'));
@stephenmathieson
stephenmathieson / app.js
Last active January 1, 2016 03:29
extremely primitive node version benchmarks
var http = require('http');
http
.createServer(function (req, res) {
// some trivial computation
var message = 'Hello world!';
res.writeHead(200, {
'content-type': 'text/plain'
});
var fs = require('fs');
var read = fs.readFileSync;
var write = fs.writeFileSync;
var jade = require('jade');
var people = require('./people.json');
var template = jade.compile(read('./person.jade', 'utf8'));
people.forEach(function (person) {
$ gyp --depth=. --generator-output=output -f make -D "library=shared_library"
$ make -C output
CC(target) out/Release/obj.target/str-ends-with/deps/str-ends-with/str-ends-with.o
LIBTOOL-STATIC out/Release/libstr-ends-with.a
CC(target) out/Release/obj.target/sphia/src/clear.o
CC(target) out/Release/obj.target/sphia/src/count.o
CC(target) out/Release/obj.target/sphia/src/error.o
CC(target) out/Release/obj.target/sphia/src/free.o
CC(target) out/Release/obj.target/sphia/src/get.o
CC(target) out/Release/obj.target/sphia/src/new.o
@stephenmathieson
stephenmathieson / install-with-threads.c
Created March 4, 2014 19:55
Simple threaded concept for clib-install(1)
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
/**
* Work structure.
*/

hilton-csv

Convert Hilton's stupid CSV thing to JSON.

API

convertFile(file, fn)

Convert the given CSV file to JSON, invoking fn(err, obj).