Skip to content

Instantly share code, notes, and snippets.

View grant's full-sized avatar

Grant Timmerman grant

View GitHub Profile
@grant
grant / circle.js
Created July 29, 2014 20:09
Markov Chain circle
// Circle
var numNodes = 10;
var a = [];
for (var i = 0; i < numNodes; ++i) {
var b = [];
for (var j = 0; j < numNodes; ++j) {
b[j] = (i === (j + numNodes - 1) % numNodes) ? 1 : 0;
}
a[i] = b;
}
@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 / ello.js
Created October 1, 2014 04:13
Ello friender
setInterval(function () {
$('li:not(.friend--active) button[data-capture="friendClicked"]').click();
function doClick (el, time) {
setTimeout(function () {
el.click();
}, time);
}
$('li:not(.friend--active) button[data-capture="friendClicked"]').each(function(i){ doClick($(this), i * 500);});
@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:

@grant
grant / languages
Last active December 2, 2015 19:23
Language timeline
--- 2007 ---
gamemaker
--- 2009 ---
actionscript
--- 2010 ---
html
css
javascript
--- 2011 ---
java
@grant
grant / algoDBSearch.js
Created January 1, 2016 00:27
Search ranking for AlgoDB
/**
* Searches the elastic search db.
* @param {String} query The raw text query
* @param {Callback} cb The response callback
* @return {Object} hits The hits from elasticsearch
*/
var search = function(query, cb) {
var url = ELASTIC_SEARCH_URL + 'algorithm/_search';
var body = {
query: {
@grant
grant / MusicXML.xml
Last active March 25, 2016 20:37
An example of MusicXML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise
PUBLIC '-//Recordare//DTD MusicXML 2.0 Partwise//EN'
'http://www.musicxml.org/dtds/partwise.dtd'>
<score-partwise>
<work>
<work-number>BWV 784</work-number>
<work-title>Invention 13</work-title>
</work>
<identification>
@grant
grant / quickstart.go
Last active December 6, 2017 06:10
Sheets Quickstart – Go alternative (developers.google.com/sheets/api/quickstart/go)
package main
import (
"fmt"
"log"
)
// https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
var SpreadsheetId = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
@grant
grant / TestGoogleAPIs.go
Created December 21, 2017 00:49
Produces a list of Google APIs
package snippets
import (
"testing"
"github.com/stretchr/testify/assert"
"net/http"
"time"
"encoding/json"
"log"
"fmt"
@grant
grant / cal.js
Created February 18, 2018 05:00
var fs = require('fs');
var readline = require('readline');
var google = require('googleapis');
var googleAuth = require('google-auth-library');
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-nodejs-quickstart.json
var SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
var TOKEN_PATH = 'creds.json';