Skip to content

Instantly share code, notes, and snippets.

Avatar

Grant Timmerman grant

View GitHub Profile
View redirect to html
app.get(/^([^.]+)$/, function (req, res) { res.redirect(req.routes.path + '.html');});
@grant
grant / gist:b611edf97235b56665cf
Created May 1, 2014
Node Modules organization
View gist:b611edf97235b56665cf
/node_modules
/package.json
/src
/node_modules
/client -> ../client
/server -> ../server
/shared -> ../shared
/client
/apps
/main
@grant
grant / javascript callbacks
Created May 4, 2014
javascript callbacks
View javascript callbacks
function test() {
//code
codeThatListensToEvent(function() {
// finish the code
});
}
function codeThatListensToEvent(cb) {
socket.doStuff();
View gist:60544ed82443ff1e678b
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 Aug 29, 2015
Favorite fonts
View index.html
<!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 Jul 13, 2014
Swift Flatdoc Style
View style.css
.lang-swift {
color: #528186;
}
.lang-swift .symbol {
color: #000;
}
.lang-swift .keyword {
color: #b6399f;
@grant
grant / index.js
Last active Aug 29, 2015
Markov Chain Generator
View index.js
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 Aug 29, 2015
Hashmap Equals
View hashmapEquals.java
/**
* 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);
View 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:

You can’t perform that action at this time.