Skip to content

Instantly share code, notes, and snippets.

View whiteley's full-sized avatar

Matt Whiteley whiteley

View GitHub Profile
@whiteley
whiteley / region.zsh
Created October 4, 2012 16:07
ZSH function for switching ec2 regions
region () {
local _uri
if [[ ! -f ~/.ec2-regions || =ec2-describe-regions -nt ~/.ec2-regions ]]; then
ec2-describe-regions > ~/.ec2-regions
fi
_uri=$(awk -v region="${1}" '$0 ~ region { print $NF }' ~/.ec2-regions)
if [[ -n "${_uri}" ]]; then
eval "export EC2_URL=https://${_uri}"
else
echo "region \"${1}\" not found" >&2
@whiteley
whiteley / ng_ec2.sh
Created May 26, 2012 17:59
Nailgun wrapper for ec2-api-tools
$ brew install ec2-api-tools nailgun repl
$ ng-server 1>/dev/null &
[1] 69512
$ ng ng-cp $(brew --prefix)/Library/LinkedKegs/ec2-api-tools/jars/lib/*.jar
$ repl ./ng_ec2.sh
./ng_ec2.sh>> ec2-describe-regions
REGION eu-west-1 ec2.eu-west-1.amazonaws.com
@whiteley
whiteley / spaceutil.c
Created May 3, 2012 23:22 — forked from camillol/spaceutil.c
Two ways of messing with spaces
#include <unistd.h>
#include <CoreServices/CoreServices.h>
#include <ApplicationServices/ApplicationServices.h>
typedef int CGSConnection;
extern OSStatus CGSGetWorkspace(const CGSConnection cid, int *workspace);
extern OSStatus CGSSetWorkspace(const CGSConnection cid, int workspace);
extern CGSConnection _CGSDefaultConnection(void);
int get_space_id(void);
#!/bin/bash
set -o errexit
set -o nounset
url='http://web.cecs.pdx.edu/~zeshan/ece341.htm'
filename='ece341'
extension='flv'
year='12'
> You can bring a machine to its knees with
>
> : ${var=foo}
>
> if $var is for instance /*/*/*/../../../*/*/*/../../../*/*/*
>
> So, you should either use instead:
>
> var=${var-foo}
> or
@whiteley
whiteley / gist:1190230
Created September 2, 2011 23:50 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: System Architect at WordStream
Favorite Python project: Fabric
Favorite Conference: WWDC
Python Experience Level: intermediate
bash -c '
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpm.aegisco.com/aegisco/rhel/aegisco-rhel.rpm
yum install -q -y rubygem-chef
ln -s /usr/lib/ruby/gems/1.8/bin/chef-client /usr/bin
(
cat <<'EOP'
#!/bin/sh
#
# This routine alters the appropriately configured
# Bacula tables for PostgreSQL, Ingres, MySQL, or SQLite.
#
if test xsqlite3 = xpostgresql ; then
echo "Altering SQLite tables"
/usr/libexec/bacula/update_postgresql_tables $*
fi
if test xmysql = xpostgresql ; then
@whiteley
whiteley / gist:665699
Created November 6, 2010 20:36
buildbot FileUpload chmod error
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/buildbot-0.8.2-py2.5.egg/buildbot/process/buildstep.py", line 728, in startStep
d.addCallback(self._startStep_2)
File "/usr/lib/python2.5/site-packages/Twisted-10.1.0-py2.5-linux-x86_64.egg/twisted/internet/defer.py", line 260, in addCallback
callbackKeywords=kw)
File "/usr/lib/python2.5/site-packages/Twisted-10.1.0-py2.5-linux-x86_64.egg/twisted/internet/defer.py", line 249, in addCallbacks
self._runCallbacks()
File "/usr/lib/python2.5/site-packages/Twisted-10.1.0-py2.5-linux-x86_64.egg/twisted/internet/defer.py", line 441, in _runCallbacks
self.result = callback(self.result, *args, **kw)
--- <exception caught here> ---
2010/11/03 15:48 +0000 [-] Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.5/threading.py", line 446, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.5/site-packages/twisted/python/threadpool.py", line 148, in _worker
context.call(ctx, function, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext
return func(*args,**kw)