Skip to content

Instantly share code, notes, and snippets.

View spudtrooper's full-sized avatar

Jeff Palm spudtrooper

View GitHub Profile
@spudtrooper
spudtrooper / pandoradio
Created February 13, 2011 01:38
Prints out rd.io links of artists you listen to on pandora.com
#!/bin/sh
tshark=/Applications/Wireshark.app/Contents/Resources/bin/tshark
$tshark -i "en1" -x -f "ip src pandora.com" | awk -F" " '/^$/ {print} /^[0-9a-f]{4}/ {printf("%s",$2)}' | perl -n -e 'm/".name"\s*\:\s*"([^"]+)"/ && ($n=$1) || ($n=~s/\s+/%20/g) && print "http://www.rdio.com/#/search/$n/artists/\n"'
@spudtrooper
spudtrooper / .applications.sh
Created February 27, 2011 17:45
Creates aliases for all your mac applications without name clashes. e.g. 'preview' would open '/Applications/Preview.app'. To use, add this to your .bashrc.
#
# Creates aliases for all your mac applications in $PATHS (defined
# below) without name clashes. e.g. 'preview' would open
# '/Applications/Preview.app'. To use, add this to your .bashrc.
#
# if [ -f ~/.applications.sh ]; then
# . ~/.applications.sh
# fi
#
PATHS="/Applications /Developer/Applications"
@spudtrooper
spudtrooper / alert
Created March 1, 2011 21:21
Pops up a little window programmatically.
#!/usr/bin/env jruby
#
# Pops up a little alert window.
#
require 'java'
JFrame = javax.swing.JFrame
JPanel = javax.swing.JPanel
JLabel = javax.swing.JLabel
@spudtrooper
spudtrooper / githubrepl
Created March 8, 2011 04:51
Repl for exploring github.com
#!/usr/bin/env ruby
# -*- ruby -*-
#
# Repl for exploring git. More here:
#
# http://www.jeffpalm.com/blog/archives/002194.html
#
require 'rubygems'
require 'hubruby'
@spudtrooper
spudtrooper / undotar
Created April 8, 2011 15:36
If you ever untar a tarball that doesn't contain a directory of files, instead a bunch of files, and you want them all in one directory, this will remove the files extracted from that tarball that were extracted.
#!/bin/sh
#
# Removes the files that were extracted locally from a tar file. This
# can be used when a tarball doesn't contain a directory of files and
# extracts a bunch of files into the pwd.
#
# Example:
#
# % undotar file.tar
# % undotar file.tar.gz
@spudtrooper
spudtrooper / chromeHistoryImages.html
Created April 15, 2011 13:36
inline images in chrome history
<a href='javascript:(function() {function main() {var width=300;var as=document.getElementsByTagName("A");for (var i=0; i<as.length; i++) {var a=as[i];var src=a.href;var el=document.createElement("DIV");var img=document.createElement("IMG");img.src=src;img.setAttribute("src",src);img.width=width;img.setAttribute("width",width);el.appendChild(img);a.parentNode.appendChild(el);}}main();})();'>chrome history images</a>
@spudtrooper
spudtrooper / gmailtitle.user.js
Created April 24, 2011 18:21
Puts your gmail inbox count to the front of the window, rather than towards the back.
// ==UserScript==
// @name Gmail Title
// @namespace http://jeffpalm.com/gmailtitle
// @description Makes the gmail title somewhat useful
// @include https://mail.google.com/mail/*
// ==/UserScript==
(function() {
var ignoreNextChange = false;
@spudtrooper
spudtrooper / njtransit_alerts.rb
Created April 26, 2011 14:13
Send email alerts for NJ transit
#!/usr/bin/env ruby
#
# Sends an email about alerts for NJ transit trains.
#
# Usage:
#
# njtransit email? city?
#
# Examples:
#
@spudtrooper
spudtrooper / gist:986932
Created May 23, 2011 15:56
maketargets
#!/bin/sh
#
# Prints out the targets available to make.
#
# Usage: maketargets file?
#
# On windows probably pipe into sort and uniq, e.g.
#
# maketargets | sort | uniq
#
@spudtrooper
spudtrooper / self_ref_cowsay
Created May 23, 2011 20:03
Self-referencial cowsay
#!/bin/sh
n=`which cowsay` && $n "`cat $n`"