Skip to content

Instantly share code, notes, and snippets.

View nottrobin's full-sized avatar

Robin Winslow nottrobin

View GitHub Profile
nottrobin / gist:8971487
Created February 13, 2014 08:06
edit hosts batch command
View gist:8971487
runas /netonly /user:administrator "%windir%\notepad.exe %windir%\system32\drivers\etc\hosts"
nottrobin /
Last active August 29, 2015 14:01
Testing charm locally by overriding charmhelpers log and config
# Override "log" and "config" methods from charmhelpers
# so that they work outside of a juju context
# from charmhelpers.core.hookenv import config
# from import log
import yaml
def log(message):
print message
nottrobin /
Created May 20, 2014 16:16
Convert IOErrors to Flask response for HTTP errors
import errno
def error_response(error, filename):
status = 500 # Default to "server error"
if hasattr(error, 'errno'):
if error.errno in [errno.EPERM, errno.EACCES]:
status = 403 # Forbidden
if error.errno in [errno.ENOENT, errno.ENXIO]:
nottrobin /
Created August 27, 2014 10:49
Get swift container URL using swiftclient (also works with python-swiftclient <= 0.8)
# Credit to Chris Stanford for this
import os
import sys
from swiftclient import client
userName = os.getenv('OS_USERNAME')
nottrobin /
Last active August 29, 2015 14:05
Find files modified yesterday
find ~ -type f -mtime -1 -exec ls -lah {} \; | egrep -v '([.](cache|config|git|local|bash|gnome|xsession|steam|gconf|lesshst|sass-cache)|_site)'
nottrobin /
Last active August 29, 2015 14:07
git: amend-at-commit
: <<'HELP'
Amend at commit
If you stage some files to be committed with git
this script will then cycle back to a specific commit,
apply those changes to that commit.
nottrobin / getDescendantsByClassName.js
Last active August 29, 2015 14:07
View getDescendantsByClassName.js
* This is effectively an implementation of
* `element.getElementsByClassName`
* (see:
* You should probably just use the built-in method.
* This is therefore a partial replacement for the jQuery find() method
* in pure JavaScript.
nottrobin / gist:e418c5ba2f4f7dcf027a
Created January 27, 2015 16:42
Installing fastimport in Bazaar
View gist:e418c5ba2f4f7dcf027a
cd ~/.bazaar/plugins
bzr branch lp:bzr-fastimport fastimport
nottrobin / gist:264e08d726c3ecacf102
Created January 27, 2015 16:47
Convert Bazaar repository to Git
View gist:264e08d726c3ecacf102
git init # Initialise a new git repo
bzr fast-export --plain . | git fast-import # Import Bazaar history into Git
nottrobin / gist:9cc2e6b7deb60a434f67
Created January 27, 2015 16:48
check Git revision history
View gist:9cc2e6b7deb60a434f67
git log # Check your revision history is in Git