Skip to content

Instantly share code, notes, and snippets.

View x's full-sized avatar
🐦

Devon Peticolas x

🐦
View GitHub Profile
@x
x / Add jQuery Bookmarklet
Created April 23, 2013 22:42
Add jQuery bookmarklet. Use this to get jQuery on any webpage to use in your browser's JavaScript console.
javascript:(function(){var jq = document.createElement('script');jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(jq);jQuery.noConflict();})()
@x
x / gist:5448287
Created April 23, 2013 23:23
Bookmarklet to check the number of credits you have from Rutgers Degree Navigator because there's no damn total on this site (https://dn.rutgers.edu/Default.aspx?pageid=transcript)
javascript:(function(){var jq = document.createElement('script');jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(jq); setTimeout(function(){jQuery.noConflict(); var i=0; jQuery(".DeAcDataGridItemB td:nth-child(3)").each(function(){i += parseInt(jQuery(this).html())}); alert("Your total credit count is " + i);})})()
@x
x / csv_to_histogram.py
Last active August 29, 2015 13:57
Generate a Histogram from a CSV
#! /usr/bin/python
from matplotlib import pyplot as plt
import sys
if len(sys.argv) != 5:
print 'Usage: ./csv_to_histogram.py [INPUT CSV] [OUTPUT PNG] [TARGET COL] [NUM BINS]'
sys.exit(1)
in_fname = sys.argv[1]
@x
x / gist:9696718
Created March 21, 2014 21:19
Drop All Databases Mongo
db.getMongo().getDBNames().forEach(function(i){db.getMongo().getDB(i).dropDatabase()})
@x
x / ping logs to csv
Last active August 29, 2015 13:57
ping logs to csv
#! /usr/bin/python
import sys
from urlparse import parse_qs
from operator import itemgetter
try:
# first argument is input ping log
in_file = open(sys.argv[1])
@x
x / gist:10685685
Created April 14, 2014 21:59
dump contents of mongo collection to file
mongo HOST --eval "printjson(db.getSiblingDB('DB')['COLLECTION'].find().toArray())" >> output.json
@x
x / gist:10686387
Last active August 29, 2015 13:59
a dirty list diff function for mongo console
db.COL1.find().toArray().filter(function(doc){return !db.COL2.find(IDENTIFIER).count()})
[ [43/1951]
{
"_id" : {
"t" : ISODate("2014-04-14T13:48:07Z"),
"vh" : BinData(0,"SK9o5qTZfIsFvOsRRPMrvA=="),
"ph" : BinData(0,"HC+s0NvoJhAjtxUDTpI9bQ==")
},
"vaup" : {
"auto" : 0,
"unkn" : 1,
@x
x / gist:11225232
Created April 23, 2014 17:30
getting csv of paths without xys
def main():
"""
[debug-only]
"""
define("domain", default="theverge.com")
define("path", default=None)
define("console", default=True, type=bool)
define("debug", default=True, type=bool)
define("click_through_host", default="localhost")
define("minutes", default=5)
@x
x / namechecker
Created May 16, 2014 13:33
Chartbeat About Page Name Checker Bookmarklet
javascript:(function()%7Bvar name%3Dprompt(%27Enter a name%27)%3B%24(%27%23team-grid li h3%27).each(function()%7Bif(!%24(this).html().match(new RegExp(name,%27i%27)))%7B%24(this).parent().parent().parent().toggleClass(%27dim%27)%7D%7D)%7D)()%3B