Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit. ported from svn without history.

  • Loading branch information...
commit 5a4812dafc53519d849e4cc6822371651969f1f3 0 parents
@rmm5t authored
71 git-publish-branch
@@ -0,0 +1,71 @@
+#!/usr/bin/env ruby
+
+## git-publish-branch: a simple script to ease the unnecessarily complex
+## task of "publishing" a branch, i.e., taking a local branch, creating a
+## reference to it on a remote repo, and setting up the local branch to
+## track the remote one, all in one go. you can even delete that remote
+## reference.
+##
+## Usage: git publish-branch [-d] <branch> [repository]
+##
+## '-d' signifies deletion. <branch> is the branch to publish, and
+## [repository] defaults to "origin". The remote branch name will be the
+## same as the local branch name. Don't make life unnecessarily complex
+## for yourself.
+##
+## Note that unpublishing a branch doesn't delete the local branch.
+## Safety first!
+##
+## git-publish-branch Copyright 2008 William Morgan <wmorgan-git-wt-add@masanjin.net>.
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or (at
+## your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You can find the GNU General Public License at:
+## http://www.gnu.org/licenses/
+
+def exec cmd
+ puts cmd
+ system cmd or die
+end
+
+def die s=nil
+ $stderr.puts s if s
+ exit(-1)
+end
+
+die "Need at least one argument: the branch to (un)publish." if ARGV.empty?
+
+delete = ARGV.delete "-d"
+branch = ARGV.shift.gsub(/refs\/heads\//, "")
+remote = ARGV.shift || "origin"
+head = `git-symbolic-ref HEAD`.chomp.gsub(/refs\/heads\//, "")
+local_ref = `git show-ref heads/#{branch}`
+remote_ref = `git show-ref remotes/#{remote}/#{branch}`
+remote_config = `git config branch.#{branch}.merge`
+
+if delete
+ ## we don't do any checking here because the remote branch might actually
+ ## exist, whether we actually know about it or not.
+ exec "git push #{remote} :refs/heads/#{branch}"
+
+ unless local_ref.empty?
+ exec "git config --unset branch.#{branch}.remote"
+ exec "git config --unset branch.#{branch}.merge"
+ end
+else
+ die "No local branch #{branch} exists!" if local_ref.empty?
+ die "A remote branch #{branch} on #{remote} already exists!" unless remote_ref.empty?
+ die "Local branch #{branch} is already a tracking branch!" unless remote_config.empty?
+
+ exec "git push #{remote} #{branch}:refs/heads/#{branch}"
+ exec "git config branch.#{branch}.remote #{remote}"
+ exec "git config branch.#{branch}.merge refs/heads/#{branch}"
+end
+
47 git-pull-branch
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+
+## git-pull-branch: a simple script to ease the unnecessarily complex
+## task of pulling a published branch
+##
+## Usage: git-pull-branch <branch> [repository]
+##
+## This was based off of William Morgan's git-publish-branch script
+##
+## git-pull-branch Copyright 2008 Jim Garvin, Pat George, Ryan McGeary
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or (at
+## your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You can find the GNU General Public License at:
+## http://www.gnu.org/licenses/
+
+def exec(cmd)
+ puts cmd
+ system cmd or die
+end
+
+def die(s=nil)
+ $stderr.puts s if s
+ exit(-1)
+end
+
+die "Need at least one argument: the branch to pull." if ARGV.empty?
+
+branch = ARGV.shift.gsub(/refs\/heads\//, "")
+remote = ARGV.shift || "origin"
+local_ref = `git show-ref heads/#{branch}`
+remote_ref = `git show-ref remotes/#{remote}/#{branch}`
+
+die "Local branch #{branch} already exists!" unless local_ref.empty?
+die "A remote branch #{branch} on #{remote} doesn't exist!" if remote_ref.empty?
+
+exec "git checkout -b #{branch}"
+exec "git config branch.#{branch}.remote #{remote}"
+exec "git config branch.#{branch}.merge refs/heads/#{branch}"
+exec "git pull"
28 growlexec
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+#
+# Orginal idea from:
+# Command-line Growl Notifications - O'Reilly ONLamp Blog
+# http://www.oreillynet.com/onlamp/blog/2005/06/commandline_growl_notification.html
+#
+# Usage: specify "growlexec" before any command-line command and receive a
+# success or failure growl notification upon exit.
+#
+# Install: Requires growlnotify extra, available in the growl package (dmg).
+# In growl, I use the "music video" display for the growlnotifer.
+#
+
+tmpfile=`mktemp /tmp/tmp.XXXXXXXXXX`
+
+$* 2>&1| tee ${tmpfile}
+r=${PIPESTATUS[0]}
+
+lines=`tail -3 $tmpfile`
+
+if [ $r -eq 0 ]; then
+ growlnotify -n growlexec -m "$lines" "SUCCESS: $*"
+else
+ growlnotify -n growlexec -p2 -s -m "$lines" "FAILED: $*"
+fi
+
+rm ${tmpfile}
25 myip
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+# From:
+# http://www.cs.cmu.edu/~benhdj/Mac/unix.html#getIP
+
+import urllib, re, sys, os
+
+# if this changes we need to revise the code to get the external IP
+ip_telling_url = 'http://www.dyndns.org/cgi-bin/check_ip.cgi'
+
+if len(sys.argv) == 1:
+ # get the external IP
+ mo = re.search(r'\d+\.\d+\.\d+\.\d+', urllib.urlopen(ip_telling_url).read())
+ if mo:
+ print mo.group()
+ else:
+ print 'Cannot get the external IP!'
+else:
+ # get the internal IP of an interface
+ targetInt = sys.argv[1]
+ output = os.popen('ipconfig getifaddr %s 2>&1' % targetInt).read().strip()
+ if re.match(r'\d+\.\d+\.\d+\.\d+', output):
+ print output
+ else:
+ print 'Cannot get the internal IP for interface \'%s\'' % targetInt
43 rake_completion
@@ -0,0 +1,43 @@
+#!/usr/bin/env ruby
+
+# Complete rake tasks script for bash
+# Save it somewhere and then add
+# complete -C path/to/script -o default rake
+# to your ~/.bashrc
+# Nicholas Seckar <nseckar@gmail.com>
+# Saimon Moore <saimon@webtypes.com>
+# http://www.webtypes.com/2006/03/31/rake-completion-script-that-handles-namespaces
+# http://errtheblog.com/post/33
+
+exit 0 unless File.file?(File.join(Dir.pwd, 'Rakefile'))
+
+require 'rubygems'
+require 'rake'
+DOTCACHE = File.join(File.expand_path('~'), ".rake_task_cache" , Dir.pwd.hash.to_s)
+RAKE_FILES = FileList[ __FILE__, 'Rakefile', 'lib/tasks/**/*.rake', 'vendor/plugins/*/tasks/**/*.rake']
+file DOTCACHE => RAKE_FILES do
+ tasks = `rake --silent --tasks`.split("\n").map { |line| line.split[1] }
+ require 'fileutils'
+ dirname = File.dirname(DOTCACHE)
+ FileUtils.mkdir_p(dirname) unless File.exists?(dirname)
+ File.open(DOTCACHE, 'w') { |f| f.puts tasks }
+end
+
+Rake::Task[DOTCACHE].invoke
+tasks = File.read(DOTCACHE)
+
+exit 0 unless /\brake\b/ =~ ENV["COMP_LINE"]
+
+after_match = $'
+task_match = (after_match.empty? || after_match =~ /\s$/) ? nil : after_match.split.last
+tasks = tasks.select { |t| /^#{Regexp.escape task_match}/ =~ t } if task_match
+
+# handle namespaces
+if task_match =~ /^([-\w:]+:)/
+ upto_last_colon = $1
+ after_match = $'
+ tasks = tasks.map { |t| (t =~ /^#{Regexp.escape upto_last_colon}([-\w:]+)$/) ? "#{$1}" : t }
+end
+
+puts tasks
+exit 0
131 ssh-init
@@ -0,0 +1,131 @@
+#!/bin/bash
+
+#
+# Copyright (c) 2006-2008 Ryan McGeary
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+
+# --------------------------------------------------
+
+#
+# USAGE: ssh-init <ssh-args>
+#
+# Example: ssh-init bob@server.domain.com
+# Example: ssh-init -l bob -p 2222 server.domain.com
+#
+
+# --------------------------------------------------
+
+#
+# Initial config options
+#
+
+# The key_type is either rsa or dsa (rsa recommended)
+key_type=rsa
+
+# You probably want to leave this alone. Keep single quotes as well unless
+# you want premature expansion (anything premature must be bad).
+remote_ssh_dir='~/.ssh'
+
+# This depends on the remote version of OpenSSH, but all the latest versions
+# are back to supporting good old 'authrorized_keys'. Some older
+# implementations require 'authorized_keys2'. Some really old implementations
+# only work with 'authorized_keys'.
+remote_auth_file=${remote_ssh_dir}/authorized_keys
+
+# --------------------------------------------------
+
+#
+# Test to see if an ssh key already exists. If not, generate one now.
+#
+
+key_file=~/.ssh/id_${key_type}
+pub_key_file=${key_file}.pub
+
+if [ ! -f $key_file ]; then
+ echo "Local ssh key NOT found (${key_file}). Generating now ..."
+ ssh-keygen -t $key_type -f $key_file
+else
+ echo "Local ssh key found (${key_file})."
+fi
+echo
+
+# --------------------------------------------------
+
+#
+# Push your public key to the remote server and append it to the
+# authorized_keys file if it's not already there.
+#
+
+ssh_args=$*
+pub_key=`cat ${pub_key_file}`
+
+init_script="
+mkdir -p ${remote_ssh_dir}; chmod 700 ${remote_ssh_dir};
+if grep -q '${pub_key}' ${remote_auth_file} &> /dev/null ; then
+ echo 'Public key already found in remote auth file (${remote_auth_file}).';
+else
+ echo 'Appending your public key to remote auth file (${remote_auth_file}) ...';
+ echo '${pub_key}' >> ${remote_auth_file};
+ chmod 600 ${remote_auth_file};
+fi;
+"
+
+if [ $# -gt 0 ]; then
+ ssh ${ssh_args} "${init_script}"
+else
+ echo 'Remote server not specified. Quitting.'
+ exit 1
+fi
+echo
+
+# --------------------------------------------------
+
+#
+# Sync your .bashrc and .bash_profile file to the remote server, but only if
+# they differ. Backups are created if necessary.
+#
+
+while [ $# -gt 1 ]; do
+ rsync_ssh_args="$rsync_ssh_args $1"
+ shift
+done
+rsync_ssh_host=$*
+
+echo 'Syncing ~/bin ...'
+rsync -arbL --exclude '*~' -e "ssh ${rsync_ssh_args}" ~/bin ${rsync_ssh_host}:~/
+
+echo 'Syncing ~/.bashrc ...'
+rsync -abL -e "ssh ${rsync_ssh_args}" ~/.bashrc ${rsync_ssh_host}:~/
+
+echo 'Syncing ~/.bash_profile ...'
+rsync -abL -e "ssh ${rsync_ssh_args}" ~/.bash_profile ${rsync_ssh_host}:~/
+
+echo 'Syncing ~/.bash_aliases ...'
+rsync -abL -e "ssh ${rsync_ssh_args}" ~/.bash_aliases ${rsync_ssh_host}:~/
+
+echo
+
+# --------------------------------------------------
+
+echo 'Done.'
+exit 0
+
+# --------------------------------------------------
11 ssh-tunnel
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+: ${user:=${1:-$USER}}
+: ${host:=${2}}
+: ${sshport:=${3:-22}}
+: ${localport:=${4}}
+: ${remoteport:=${5}}
+: ${remotehost:=${6:-localhost}}
+
+echo "Tunneling to ${remotehost} via ${user}@${host}:${sshport} : ${localport} --> ${remoteport}"
+ssh -p${sshport} -N -L *:${localport}:${remotehost}:${remoteport} ${user}@${host}
27 stripprefix
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if tty -s ; then
+ echo
+ echo This will rename files in your current directory.
+ echo The prefix \'$1\' will be stripped from every filename
+ echo \(e.g. \'$1sample.txt\' would become \'sample.txt\'\).
+ echo
+ echo -n "OK to procede? (y or n) "; read ans
+ case "$ans" in y*|Y*)
+ ;;
+ *)
+ echo Quiting...
+ exit 0
+ ;;
+ esac
+else
+ exit 1
+fi
+
+echo
+
+for f in $1?*
+do
+ echo mv $f `echo $f | sed "s/$1//g" -`
+ mv $f `echo $f | sed "s/$1//g" -`
+done
21 svgzip
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+echo
+
+for f in $*
+do
+
+ basefilename=`basename $f .svg`
+ newfilename=$basefilename.svgz
+ echo -n ' ' $f '->' $newfilename
+ gzip -c $f > $newfilename
+
+ oldsize=`ls -lh $f | awk '{ print $5; }'`
+ newsize=`ls -lh $newfilename | awk '{ print $5; }'`
+ echo ' (' $oldsize '->' $newsize ')'
+
+done
+
+echo
+
+
3  whotunes
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+lsof -r 2 -n -P -F n -c iTunes -a -i TCP@`hostname`:3689
Please sign in to comment.
Something went wrong with that request. Please try again.