Skip to content

Instantly share code, notes, and snippets.

View joshng's full-sized avatar

josh gruenberg joshng

View GitHub Profile

Keybase proof

I hereby claim:

  • I am joshng on github.
  • I am joshng (https://keybase.io/joshng) on keybase.
  • I have a public key whose fingerprint is AA89 58EB 0BCB E3D5 6F40 444A 9A48 B186 8918 D1AD

To claim this, I am signing this object:

#!/bin/bash
set -e
branch() {
git branch 2>/dev/null | grep -e '^*' | tr -d '\* '
}
ensure_valid_ref() {
ref=$1
@joshng
joshng / rbfunction.sh
Created June 13, 2009 08:30
rbfunction.sh: write bash functions in ruby
# rbfunction: declare shell functions in ruby!
# (obviates the need to keep short scripts in their own files)
#
# example: create a shell function 'quote' that wraps each argument in quotes:
# $ rbfunction quote <<END
# > puts ARGV.collect { |arg| '"' << arg << '"' }
# > END
#
# $ quote a b "c d"
# "a"
#!/usr/bin/env ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/opt/local/bin/ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'
TAGS_FILE = 'tags'
@joshng
joshng / open_in_new_tab_bookmarklet.js
Created February 19, 2009 06:23
my mods to the common iphone bookmarklet to open links in a new tab; adds code to reset the page after a click
javascript:(function(){function%20cu(){try{setTimeout(function(){for(var%20i=0,j=a.length;i<j;i++){var%20aa=a[i];aa.setAttribute('target',aa.realtarget);aa.onclick=aa.realonclick;}},10);for(var%20i=0,j=is.length;i<j;i++){var%20ii=is[i];ii.parentNode.removeChild(ii);}}catch(e){alert('error:'+e.message);}}var%20is=[];var%20a=document.getElementsByTagName('a');for(var%20i=0,j=a.length;i<j;i++){var%20aa=a[i];aa.realtarget=aa.getAttribute('target');aa.setAttribute('target','_blank');aa.realonclick=aa.onclick;aa.onclick=cu;var%20img=document.createElement('img');img.setAttribute('class',%20'new-window');img.setAttribute('src','data:image/gif;base64,'+'R0lGODlhEAAMALMLAL66tBISEjExMdTQyBoaGjs7OyUlJWZmZgAAAMzMzP///////wAAAAAAAAAAAAAA'+'ACH5BAEAAAsALAAAAAAQAAwAAAQ/cMlZqr2Tps13yVJBjOT4gYairqohCTDMsu4iHHgwr7UA/LqdopZS'+'DBBIpGG5lBQH0GgtU9xNJ9XZ1cnsNicRADs=');img.setAttribute('style','width:16px!important;height:12px!important;border:none!important;');a[i].appendChild(img);is.push(img);}})();