Skip to content

Instantly share code, notes, and snippets.

View siwells's full-sized avatar

Simon Wells siwells

View GitHub Profile
@siwells
siwells / big-git-files.sh
Created June 12, 2014 18:03
An excellent shell script I found here: http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ that I wanted to keep for whenever an asshole commits huge files to our git repo.
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
@siwells
siwells / gist:ffb8885cc62c8a7572d6
Created September 25, 2014 14:32
Shellshock fix for Bash & sh on OS X
System Binaries
OS X 10.9.5 (the latest stable release at the moment) ships with Bash v3.2.51:
$ bash --version
GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.
You can obtain and recompile Bash as follows, providing that you have Xcode installed:
@siwells
siwells / wikify.sh
Created February 27, 2010 15:17
wikify a list of papers for embedding into a wiki
#!/bin/bash
usage()
{
echo "usage: `basename $0` inputfile"
}
IN=$1
ENDING=".pdf"
OPEN="[["
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
ifconfig eth0 | grep 'inet ' | awk '{print $2}' | sed 's/addr://'
@siwells
siwells / is-net-up.sh
Created August 1, 2011 11:09
A Bash script to check whether the network for a given VM is up and running. It will look for the VirtualBox reserved NAT IP (10.0.2.15). If found the VM is up & running, otherwise inform the user then sleep for 10 seconds before trying again.
#!/bin/bash
function checknet {
UP=$(VBoxManage guestproperty enumerate omero-vm | grep "10.0.2.15")
}
checknet
echo "UP :: " $UP
@siwells
siwells / whatos.sh
Created August 4, 2011 16:27
Determine the kernel that the host is running & output an appropriate message
#!/bin/bash
OS=`uname -s`
if [ "$OS" == "Darwin" ]; then
echo "Mac OS X with Darwin Kernel"
elif [ "$OS" == "Linux" ]; then
echo "GNU/Linux OS with Linux Kernel"
else
echo "Not Mac or Linux"
@siwells
siwells / cmd_test.py
Created August 16, 2011 09:03
A simple example of using cmd to build a simple REPL within a python CLI tool.
import cmd
class CmdProcessor(cmd.Cmd):
"""A Simple Command Processor."""
def do_greeting(self, line):
print "Hello World!"
def do_EOF(self, line):
return True
@siwells
siwells / cli_test.py
Created August 16, 2011 08:58
Example of using optparse to work with command line arguments to build a *nix style CLI tool
import optparse
def main():
p = optparse.OptionParser()
p.add_option('--person', '-p', default="world")
options, arguments = p.parse_args()
print 'Hello %s' % options.person
if __name__ == '__main__':
main()
@siwells
siwells / bracket_matching.py
Created August 17, 2011 10:30
Playing with a bracket matching function for use in a new code generation tool.
def Evaluate(str):
stack = []
pushChars, popChars = "<({[", ">)}]"
for c in str :
if c in pushChars :
stack.append(c)
elif c in popChars :
if not len(stack) :
return False
else :