Skip to content

Instantly share code, notes, and snippets.

View byronhulcher's full-sized avatar

Byron Hulcher byronhulcher

View GitHub Profile
@byronhulcher
byronhulcher / index.js
Created October 7, 2014 02:56
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
@byronhulcher
byronhulcher / collatz.py
Last active August 29, 2015 14:06
Solution to to find longest Collatz Chain for values < N
// problem explanation at https://gist.github.com/outoftime/fc52bd13465d4aaaf1d9
collatz_cache = {1 : 0}
def find_maximum_collatz_chain(maximum_value):
maximum_length = 0
largest_value = 1
for num in range(2, maximum_value):
chain_length = get_collatz_chain_length(num)
if chain_length > maximum_length:
@byronhulcher
byronhulcher / node-express-app.js
Last active August 29, 2015 14:05
Example Node.JS Express app
// Much code based on http://scotch.io/tutorials/javascript/build-a-restful-api-using-node-and-express-4
var express = require('express'); // call express
var app = express(); // define our app using express
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(function (req, res, next) {