Skip to content

Instantly share code, notes, and snippets.

View wrboyce's full-sized avatar

Will Boyce wrboyce

View GitHub Profile
@wrboyce
wrboyce / borg.py
Created July 23, 2009 11:45
Borg Design Pattern for a Shared State across Instances of a Class
class Borg(object):
""" Borg Design Pattern for a Shared State across Instances of a Class. """
__hivemind = {}
def __new__(cls, *args, **kwargs):
self = super(cls.__class__, cls).__new__(cls, *args, **kwargs)
self.__dict__ = cls.__hivemind[cls.__name__] = {}
return self
@beddari
beddari / install_vagrant_sudoers.sh
Created December 13, 2011 12:47
Allow Vagrant sudo-access without password for NFS-setup
#!/bin/bash
# Script for placing sudoers.d files with syntax-checking
if [ -z "$1" ]; then
# Making a temporary file to contain the sudoers-changes to be pre-checked
TMP=$(mktemp)
cat > $TMP <<EOF
Cmnd_Alias VAGRANT_EXPORTS_ADD = /bin/su root -c echo '*' >> /etc/exports
Cmnd_Alias VAGRANT_NFSD = /etc/init.d/nfs-kernel-server restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -e /*/ d -ibak /etc/exports