Skip to content

Instantly share code, notes, and snippets.

@jonocole
jonocole / r
Created May 26, 2009 09:49
A useful script for running a binary on OSX where dylibs are in the binary's path
#!/bin/bash
BIN=${*:1}
cd `dirname $BIN`
DYLD=`pwd`
cd -
export DYLD_LIBRARY_PATH=$DYLD
$BIN
#!/bin/bash
if [[ $# == 0 ]]; then
echo $0 [mp3 filename] [header filename]
exit
fi
echo -n 'static char audiodata[] = {' > $2
sox "$1" -t raw -r 8000 -c1 -s -2 - trim 0 10|xxd -i >> $2
echo -n '}; char* fun(){ return audiodata; }' >> $2
@jonocole
jonocole / gist:1471645
Created December 13, 2011 10:46
PS1 git branch
function gitbranch {
BRANCH=$(git branch 2> /dev/null |grep \\\*.\*$|sed 's:^. \(.*\):\1:g')
if [ "$BRANCH" ]; then
echo -n "($BRANCH)"
fi
}
if [ "$color_prompt" = yes ]; then
PS1='\n${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n\[\033[01;35m\]$(gitbranch)\[\033[00m\]\$ '
else
@jonocole
jonocole / Spotify Silencer.applescript
Created March 27, 2012 15:44
Silence spotify ads
-- This isn't pretty but it works.
tell application "Spotify"
set old_volume to sound volume
repeat
if player state is playing then set current_album to album of current track
if player state is playing and (current_album starts with "http://" or current_album starts with "https://" or current_album starts with "spotify:") then
set sound volume to 0
play
else
@jonocole
jonocole / lastfm_skip.bash
Created February 11, 2013 16:13
Remove skip limit from last.fm client. (Needs last.fm version > 2.1.33)
patch -d /Applications/Last.fm.app/Contents <<EOF
--- Info.plist
+++ Info.plist
@@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>LSEnvironment</key>
+ <dict>
+ <key>LASTFM_SKIP_LIMIT</key>

Keybase proof

I hereby claim:

  • I am jonocole on github.
  • I am jonocole (https://keybase.io/jonocole) on keybase.
  • I have a public key ASAExrC71aaT3I0ek4ztxvffSfTqC0w4J3CEHQaHYeINAwo

To claim this, I am signing this object:

package main
import (
"reflect"
)
func WrapMethod(method, target interface{}) interface{} {
// 1. Inspect the method signature so that a
// replica can be returned
methodType := reflect.TypeOf(method)