Skip to content

Instantly share code, notes, and snippets.

View phette23's full-sized avatar
🌹
"you're right, no human being would stack books like this"

Eric Phetteplace phette23

🌹
"you're right, no human being would stack books like this"
View GitHub Profile
@phette23
phette23 / pcap.sh
Created September 9, 2012 08:07
Using tcpdump to capture network traffic
sudo tcpdump -i en0 -n -s 0 -w traffic.pcap tcp or port 53
# see code.google.com/p/pcaphar/wiki/CaptureMobileTraffics
# NB: en0 is for ethernet connections, en1 for Airport
# see also support.apple.com/kb/HT3994
# can analyze .pcap output with pcapperf.appspot.com/
@phette23
phette23 / check-headers.php
Created October 23, 2012 20:09
PHP to Check HTTP Headers
<?
// php 5
print_r( get_headers( "http://example.com", 1 ) );
@phette23
phette23 / amazon2spreadsheet.js
Last active December 15, 2015 06:19
Bookmarklet to grab title, author, price, & URL from Amazon, ripe for pasting into a spreadsheet (e.g. Google Drive)
(function( $ ) {
var title, authors, price, url,
loc = document.location;
title = $( '#btAsinTitle' ).text().replace( /\s\[(Paperback|Hardcover|Bargain Price|Mass Market Paperback)\]/g, '' );
// authors' names, skip over role e.g. (editor)
if ( $( '.contributorNameTrigger' )[ 0 ] ) {
if ( $( '.contributorNameTrigger' ).length > 1 ) {
authors = $( '.contributorNameTrigger a' )[ 0 ].text();
@phette23
phette23 / fluid-width-youtube-vid.html
Last active December 15, 2015 15:08
Markup for making a fluid-width YouTube video embed. Better to do it in markup than use FitVids, where the markup was taken from.
<!-- just replace {{id}} with the video's ID
e.g. 9bZkp7q19f0 -->
<div style="width:100%;position:relative;padding:0;padding-top:75%">
<iframe
style="position:absolute;top:0;left:0;width:100%;height:100%;"
src="http://www.youtube-nocookie.com/embed/{{id}}?rel=0"
frameborder="0" allowfullscreen mozallowfullscreen webkitallowfullscreen>
</iframe>
</div>
@phette23
phette23 / top-10-commands.sh
Created April 14, 2013 19:59
Results of my "top 10 BASH commands used"
# Top 10 BASH commands used
# from stackoverflow.com/questions/68372/what-is-your-single-most-favorite-command-line-trick-using-bash#answer-68390
function top10() {
history | awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' | sort | uniq -c | sort -nr | head
}
1393 gs - alias for git status
1272 g - alias for git
1121 l - alias for ls -l
1003 - can't explain this...why would an empty space show up as a command? Bug in the top10 function maybe
@phette23
phette23 / footnote-at-bottom.sublime-snippet
Created April 18, 2013 22:11
Sublime Text Snippets for Footnotes in Markdown
<snippet>
<content><![CDATA[<span id="fn$1">[$1]</span><a href="#note$1">^</a> $2
$0]]></content>
<tabTrigger>fn</tabTrigger>
<scope>text.html.markdown.multimarkdown, text.html.markdown</scope>
<description>Footnote at Bottom</description>
</snippet>
@phette23
phette23 / count-edits.js
Last active December 17, 2015 07:49
Count number of edits & bytes changed on Wikipedia user's Contributions page
(function(){
// Wikipedia ships with jQuery v1.8.3 as of 5/14/13
// will only count edits on the page
// if editor has >50 edits need to up the display limit
var numEdits = $( 'ul' ).eq( 0 ).find( 'li' ).length,
bytesChanged = 0;
$( '.mw-plusminus-pos, .mw-plusminus-neg' ).each( function ( el, index ) {
// text looks like (+###) where # of digits is variable
// e.g. (+3), (-45), (+1,479)
// so remove any commas, first 2 chars, last char, & parse as int
@phette23
phette23 / unending-rainbow.py
Created June 29, 2013 14:17
Never-ending rainbow effect in Boston Python Workshop's ColorWall project https://openhatch.org/wiki/Boston_Python_Workshop_7/Friday/OSX_project_dependencies
def RainbowTest(wall):
print "RainbowTest"
rainbowColors = [ colors["red"], colors["orange"], colors["yellow"], colors["green"], colors["baby blue"], colors["blue"], colors["purple"] ]
i = 0
for y in range( wall.height ):
color = rainbowColors[ i ]
i += 1
if i == 7:
i = 0
@phette23
phette23 / sum-majors.py
Last active July 17, 2017 20:41
script to take an Informer report of degree code totals & map them into our human-friendly major terms
#!/usr/bin/env python
# usage:
# sum-majors.py "LI - Library students per term.csv" > "YEAR majors total.csv"
import csv
import fileinput
import sys
majors = csv.DictReader(fileinput.input(mode='rb'))
# mapping of degree codes to majors will change over time
# as will the "totals" dict below listing our majors
@phette23
phette23 / dedupe-syllabi.js
Last active April 26, 2018 18:44
a utility script for CCA to check for duplicate syllabi in VAULT
#!/usr/bin/env node
// a utility script for CCA to check for duplicate syllabi in VAULT
let defaults = {
uuid: '9ec74523-e018-4e01-ab4e-be4dd06cdd68',
// 50 is max length
length: 50,
term: 'Spring 2018',
}
// .equellarc file with credentials for API use
let options = require('rc')('equella', defaults)