Skip to content

Instantly share code, notes, and snippets.

View grant's full-sized avatar

Grant Timmerman grant

View GitHub Profile
app.get(/^([^.]+)$/, function (req, res) { res.redirect(req.routes.path + '.html');});
@grant
grant / gist:b611edf97235b56665cf
Created May 1, 2014 19:24
Node Modules organization
/node_modules
/package.json
/src
/node_modules
/client -> ../client
/server -> ../server
/shared -> ../shared
/client
/apps
/main
@grant
grant / javascript callbacks
Created May 4, 2014 01:01
javascript callbacks
function test() {
//code
codeThatListensToEvent(function() {
// finish the code
});
}
function codeThatListensToEvent(cb) {
socket.doStuff();
@grant
grant / gist:60544ed82443ff1e678b
Created May 4, 2014 03:04
Fun with javascript
setInterval(function () {
var color = 'rgb('+Math.floor(Math.random()*255)+','+Math.floor(Math.random()*255)+','+Math.floor(Math.random()*255)+')';
console.log(color);
document.getElementsByTagName('header')[0].style['background-color'] = color;
}, 10);
@grant
grant / fonts.md
Last active August 29, 2015 14:02
Favorite fonts
@grant
grant / index.html
Created June 29, 2014 08:01
Rainbow 🌈
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
width: 40px;
height: 10px;
display: inline-block;
@grant
grant / style.css
Created July 13, 2014 23:26
Swift Flatdoc Style
.lang-swift {
color: #528186;
}
.lang-swift .symbol {
color: #000;
}
.lang-swift .keyword {
color: #b6399f;
@grant
grant / index.js
Last active August 29, 2015 14:04
Markov Chain Generator
var numNodes = 20;
var roundNum = 100;
var a = [];
for (var i = 0; i < numNodes; ++i) {
var connections = [];
var sum = 0;
for (var j = 0; j < numNodes; ++j) {
var randNum = Math.random() / numNodes;
// round the num
randNum = Math.round(randNum * roundNum) / roundNum;
@grant
grant / hashmapEquals.java
Last active August 29, 2015 14:05
Hashmap Equals
/**
* Asserts that two maps are equal.
*/
static public void assertEquals(Map<?, ?> actual, Map<?, ?> expected) {
if (actual == expected) {
return;
}
if (actual == null || expected == null) {
fail("Maps not equal: expected: " + expected + " and actual: " + actual);
@grant
grant / keybase.md
Created March 29, 2015 23:39
keybase.md

Keybase proof

I hereby claim:

  • I am grant on github.
  • I am grant (https://keybase.io/grant) on keybase.
  • I have a public key whose fingerprint is 5DC1 0500 27DD 5A2F 423C 79A1 BA41 5BFE 5C8F 61A4

To claim this, I am signing this object: