Skip to content

Instantly share code, notes, and snippets.

@dustinlarimer
dustinlarimer / Git-Beacon.md
Last active August 29, 2015 13:57
Sample redirect badge and image beacon for tracking Github repo visits

Badge (redirect)

Example: DO NOT USE :)

[![RepoStats](https://api.keen.io/3.0/projects/<your_project_id>/events/visit?api_key=<your_write_key>&data=<base64_encoded_data>&redirect=http://img.shields.io/badge/Stats-Keen%20IO-blue.svg)](https://github.com/<your_repo_slug>)

Beacon (pixel)

@dustinlarimer
dustinlarimer / index.html
Last active August 12, 2019 04:45
JS Error Reporting with Keen IO
<!DOCTYPE html>
<html>
<head>
<script src="keen-3.0.0.track.min.js"></script>
<script src="keen-reporter.js"></script>
<script>
!function(){
var keen = new Keen({
projectId: "",
writeKey: "",
@dustinlarimer
dustinlarimer / README.md
Last active September 11, 2018 01:38
Keen IO Geo Coordinates in a Google Map
<!DOCTYPE html>
<html>
<head>
<title>Gist for Keen IO JS Library</title>
<script src="http://d26b395fwzu5fz.cloudfront.net/3.0.0/keen.min.js"></script>
<script>
var client = new Keen({
projectId: "5368fa5436bf5a5623000000",
readKey: "3f324dcb5636316d6865ab0ebbbbc725224c7f8f3e8899c7733439965d6d4a2c7f13bf7765458790bd50ec76b4361687f51cf626314585dc246bb51aeb455c0a1dd6ce77a993d9c953c5fc554d1d3530ca5d17bdc6d1333ef3d8146a990c79435bb2c7d936f259a22647a75407921056"
@dustinlarimer
dustinlarimer / google-apps-script.js
Last active August 29, 2015 14:02
Set up an IFTTT Gmail recipe that appends messages to Google Spreadsheet. Next, paste this script into that spreadsheet's Script Editor, and set a new trigger to fire when the document is changed.
/*
Spreadsheet Rows:
-----------------------------
A: timestamp (not used here)
B: from
C: subject
D: label
E: attachment name
F: attachment url
*/
@dustinlarimer
dustinlarimer / README.md
Last active October 20, 2017 05:40
Ant Colony Optimization in D3.js

Crude implementation of ACO in D3js, based on the awesome work of Joel Wenzel et al.

@dustinlarimer
dustinlarimer / keen-custom-funnels.js
Created August 7, 2014 21:18
Add percentage values to funnel steps
// var client = new Keen({...})
// var funnel = new Keen.Query("funnel", {...});
client.run(funnel, function(res){
var data = res;
var labelMap = {
// Keys = eventCollection for each step
// Values = what you want them to say instead..
// Percentage will be appended to values
"pageview" : "Visit",
@dustinlarimer
dustinlarimer / histogram.html
Last active June 7, 2017 16:22
Make histograms with keen-js v3
<!DOCTYPE html>
<html>
<head>
<title>Keen IO &#9829; Histograms!</title>
</head>
<body>
<div id="histogram"></div>
<script src="http://d26b395fwzu5fz.cloudfront.net/latest/keen.min.js"></script>
<script>
!function(){
@dustinlarimer
dustinlarimer / README.md
Last active October 8, 2015 16:45
API Read Key for NYTimes' data dump of Military Surplus Gear flowing to local police departments

Military Surplus Gear, published here

API credentials for read-access:

Project ID: 53f3eca97d8cb91b75000000

API Key (read-only): df6ff0ff414bc286b91e2661db4c691c45b6aea8d2c8cf2393169e9b9ef36a3d77e59c57b540febc8f328bf1f605782d9035c4a7072dc86c4f96ddbcce7dfe0b088ae51dd2ea36ad022290d1f3580e2d1ea202845ae7f79e7db6634ee627a26197dadf7eb2e5a46b16f04a4cae55955e

Sample dashboard here, JS source here

@dustinlarimer
dustinlarimer / loader.js
Last active August 29, 2015 14:06
Refactored the keen-js async paste-in script, to make the namespace and version number more accessible :)
!function(i,o){i("Keen","/3.1.0/keen.min.js",o)}(function(a,b,c){var d,e,f;c["_"+a]={},c[a]=function(b){c["_"+a].clients=c["_"+a].clients||{},c["_"+a].clients[b.projectId]=this,this._config=b},c[a].ready=function(b){c["_"+a].ready=c["_"+a].ready||[],c["_"+a].ready.push(b)},d=["addEvent","setGlobalProperties","trackExternalLink","on"];for(var g=0;g<d.length;g++){var h=d[g],i=function(a){return function(){return this["_"+a]=this["_"+a]||[],this["_"+a].push(arguments),this}};c[a].prototype[h]=i(h)}e=document.createElement("script"),e.async=!0,e.src=b,f=document.getElementsByTagName("script")[0],f.parentNode.insertBefore(e,f)},this);
(function(i,o){i("Keen","/3.1.0/keen.min.js",o);}(function(t,h,x){
// t = context
// h = file
// x = context
// console.log(t,h,x===window);
var methods, script, tag;
// _Keen cache