Skip to content

Instantly share code, notes, and snippets.

View owenversteeg's full-sized avatar

Owen Versteeg owenversteeg

View GitHub Profile
@owenversteeg
owenversteeg / googleDocsContribs.js
Last active January 3, 2016 01:59
Bookmarklet for collecting Google Docs contributor data into .tsv format. In order to use it, you must first expand the contributor list (and then run this in the console.) You can modify the call to console.log if you want the data to be alerted. (Of course, you can't copy the data unless it's console.logged.)
javascript:function getCollaboratorDetails() { var collaboratorsElements = document.getElementsByClassName('docs-revisions-tile-collaborator'); var collaborators = []; var returnText = "Name\tContributions\n";for (var i=0; i<collaboratorsElements.length; i++) { collaborators[collaboratorsElements[i].innerText] = (collaborators[collaboratorsElements[i].innerText]+1 || 1); } console.log(Object.keys(collaborators)); for (var i=0; i<Object.keys(collaborators).length; i++) { returnText += Object.keys(collaborators)[i] + "\t" + collaborators[Object.keys(collaborators)[i]] + "\n" } return returnText; } console.log(getCollaboratorDetails());
@owenversteeg
owenversteeg / eulerphi
Last active August 29, 2015 14:17
eulerphi
// Copyright (c) 2011 Alexei Kourbatov, www.JavaScripter.net
// function leastFactor(n) returns:
// * the smallest prime that divides n
// * NaN if n is NaN or Infinity
// * 0 if n is 0
// * 1 if n=1, n=-1, or n is not an integer
leastFactor = function(n) {
if (isNaN(n) || !isFinite(n)) return NaN;
@owenversteeg
owenversteeg / keybase.md
Created September 24, 2014 01:20
Keybase Github verification

Keybase proof

I hereby claim:

  • I am owenversteeg on github.
  • I am owenversteeg (https://keybase.io/owenversteeg) on keybase.
  • I have a public key whose fingerprint is 456F 08CB 9ECF E879 8EAA 6B55 E325 1AE6 F9E2 D3F5

To claim this, I am signing this object:

@owenversteeg
owenversteeg / gzipfilesize.js
Created February 19, 2014 08:20
gzipfilesize.js
var http = new XMLHttpRequest();var url = "http://8b51d1abd8.test-url.ws/gzipsize.php";var params = "encode="+prompt('Enter the text to find the gzipped size of');http.open("POST", url, true);http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");http.onreadystatechange = function() {if (http.readyState == 4 && http.status == 200) {alert(http.responseText);}};http.send(params);
@owenversteeg
owenversteeg / makeunprefixed.js
Created February 7, 2014 02:22
Turn SI prefixes into multipliers
function makeUnprefixed(siUnitWithPrefix) {
console.log(siUnitWithPrefix);
var fullPrefixes = ['yotta', 'zeta', 'exa', 'peta', 'tera', 'giga', 'mega', 'kilo', 'hecto', 'deca', 'deci', 'centi', 'milli', 'micro', 'nano', 'pico', 'femto', 'atto', 'zepto', 'yocto']
var prefixes = ['Y', 'Z', 'E', 'P', 'T', 'G', 'M', 'k', 'h', 'da', 'd', 'c', 'm', 'u', 'n', 'p', 'f', 'a', 'z', 'y'];
var factors = [24, 21, 18, 15, 12, 9, 6, 3, 2, 1, -1, -2, -3, -6, -9, -12, -15, -18, -21, -24];
siUnitWithPrefix = siUnitWithPrefix.toLowerCase();
var multiplier = 1;