Skip to content

Instantly share code, notes, and snippets.

View banterability's full-sized avatar

Jeff Long banterability

View GitHub Profile
@banterability
banterability / intcomma.js
Created August 31, 2010 21:07
Add commas to integers (2000000 -> 2,000,000) in javascript
var intcomma = function(value) {
// inspired by django.contrib.humanize.intcomma
var origValue = String(value);
var newValue = origValue.replace(/^(-?\d+)(\d{3})/, '$1,$2');
if (origValue == newValue){
return newValue;
} else {
return intcomma(newValue);
}
};
@banterability
banterability / eml_parser.py
Created October 7, 2010 22:22
Rough sketch of a parser for California election data feeds
import os
import shutil
import urllib2
import zipfile
from lxml import etree # requires lxml & friends
# TODO:
# - Total vote counts
# - County-level results
@banterability
banterability / score.py
Created December 1, 2010 23:25
Time-based ranking algorithm influenced by Hacker News
# based on http://amix.dk/blog/post/19574
from datetime import datetime, timedelta
GRAVITY = 0.5 # HN default: 1.8
WINDOW = 36 # max age in hours
now = datetime.now()
def hours_from_dt(dt):
@banterability
banterability / code2doc.coffee
Created January 11, 2011 21:03
Bookmarklet to switch between GitHub code & documentation in GitHub pages
h = location.href
docStr = /^http:\/\/(\w*).github.com\/(\w*)(?:\/.*)?/
codeStr = /^https?:\/\/github.com\/(\w*)\/(\w*)(?:\/.*)?/
docTmp = "http://$user.github.com/$proj"
codeTmp = "https://github.com/$user/$proj"
isDoc = h.match(docStr)
isCode = h.match(codeStr)
redirect = (loc) ->
<script src="http://media.scpr.org/assets/scripts/webtrends.v2.js"></script>
<script>
//<![CDATA[
var _tag=new WebTrends();
_tag.dcsGetId();
//]]>
</script>
<script>
//<![CDATA[
_tag.dcsCustom=function(){
@banterability
banterability / ctaIcons.js
Created August 14, 2013 23:16
Generate images from groups of CTA L lines and generate data URLs for use as iOS home screen icons.
var ctaColors = {
blue: '#00A1DE',
brown: '#62361B',
green: '#009B3A',
orange: '#F9461C',
pink: '#E27EA6',
purple: '#522398',
red: '#C60C30',
yellow: '#F9E300'
}
@banterability
banterability / battery.coffee
Last active January 14, 2016 00:37
Get iPhone battery life over time from Reporter App's (http://www.reporter-app.com/) logs in Dropbox
async = require 'async'
fs = require 'fs'
{filter, flatten} = require 'underscore'
OBJ_C_EPOCH = 978307200
DROPBOX_DIR = #"<path to your dropbox folder >/Dropbox/Apps/Reporter-App/"
fs.readdir DROPBOX_DIR, (err, files) ->
throw new err if err?
dataFiles = filter files, (filename) -> /.json/.test filename

Keybase proof

I hereby claim:

  • I am banterability on github.
  • I am banterability (https://keybase.io/banterability) on keybase.
  • I have a public key whose fingerprint is E5D9 0808 D4C9 EAD6 6749 DADD 1E96 B62F D7C6 52F4

To claim this, I am signing this object:

@banterability
banterability / gist:0ac52fdde9deb9c41282
Last active August 29, 2015 14:13
A terrible js loop to run in console to delete all your tweets
// Run from twitter.com/<yourusername>
// this will (duh) delete all your tweets. don't be dumb.
var deleteLoop;
deleteLoop = setInterval(function(){
var deleteButton = $('.js-actionDelete button');
if(deleteButton.length < 1){
clearInterval(deleteLoop);
alert('No more things to delete');
} else {
deleteButton[0].click();
function flashSupported(){
if (window.ActiveXObject){
try {
new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
return true;
} catch (e) {
return false;
}
} else {
return Array.from(navigator.plugins).some(function(plugin){