Skip to content

Instantly share code, notes, and snippets.

View futuraprime's full-sized avatar

Evan Hensleigh futuraprime

  • The Economist
  • London, UK
View GitHub Profile

Keybase proof

I hereby claim:

  • I am futuraprime on github.
  • I am futuraprime (https://keybase.io/futuraprime) on keybase.
  • I have a public key ASBSIey-m8gtkXBoT1q35NtXXrArkU5wICPR5s76GkeXbwo

To claim this, I am signing this object:

@futuraprime
futuraprime / pearson.js
Created June 9, 2015 16:24
Pearson Correlation
// "data" should be an array of x,y arrays
// e.g.: [[0,1],[1,2],[2,3]]
function pearsonCorrelation(data) {
var n = data.length;
var numerator = n *
data.reduce(function(memo, d) { return memo + d[0] * d[1]; }, 0) -
data.reduce(function(memo, d) { return memo + d[0]; }, 0) *
data.reduce(function(memo, d) { return memo + d[1]; }, 0);
@futuraprime
futuraprime / bach.png
Last active August 29, 2015 14:08
Bach face plant // source http://jsbin.com/yatigi
bach.png
@futuraprime
futuraprime / gist:9896413
Created March 31, 2014 16:36
A bookmarklet to archive the current page in the Wayback Machine
javascript:(function(){window.location.href='https://web.archive.org/save/'+window.location.href;})();
import re
import json
import numpy as np
from BeautifulSoup import BeautifulStoneSoup as Stone
f = open('new-basemap-borders-01.svg')
svg = f.read()
f.close()
soup = Stone(svg)
@futuraprime
futuraprime / index.js
Created November 21, 2013 19:06
Gist from mistakes.io
"hello, world"; // edit this to begin
<!DOCTYPE html>
<html>
<head>
<title>A Website!</title>
<script type='text/javascript' src="https://raw.github.com/mbostock/d3/master/d3.js"></script>
<style type="text/css">
.rule {
stroke-width: 1;
stroke: #999;
}
@futuraprime
futuraprime / icon.css
Created July 3, 2012 00:55
A simple function to drop icons on divs.
.icon-container {
width: 64px;
height: 64px;
text-indent: -9999px;
position: relative;
color: #cc00aa; // the icon color is determined here
}
.icon-container canvas {
position: absolute;
@futuraprime
futuraprime / viewports.html
Created June 19, 2012 19:26
Quick viewport units test
<!DOCTYPE html>
<html>
<head>
<title>A Website!</title>
<style type="text/css">
.foo {
width: 50%;
}
.bar {
width: 50vw;
@futuraprime
futuraprime / pre-commit.rb
Created June 18, 2012 15:32
Pre-commit error catcher
#!/usr/bin/env ruby
# Git pre-commit hook that prevents accidentally committing things that shouldn't be, like:
#
# * ":focus", used with RSpec/Guard
# * "show_page", used to debug request specs
# * "console.log" or "console.debug", used in JavaScript debugging
# * "DO NOT COMMIT!" comments
#
# Modify the regexps to suit your needs. The error message shows the full regexp match, or just the first capture group, if there is one.