Skip to content

Instantly share code, notes, and snippets.

public class StringTemplate
* Mimics the python template string format, eg:
* "blah blah %(varname)s blah blah"
* then you pass in a 'dict' of varnames which get
anentropic / ElementTree cloning factory
Created October 28, 2010 17:04
Code for better cloning of ElementTree (XML) objects in Python
import xml.etree.cElementTree as ET
ripped off from:
apparently this is faster than using copy.deepcopy on an ElementTree
anentropic / chef-pip-error
Created August 28, 2012 11:07
Vagrant crashes after some kind of timeout(?) installing python packages via pip, from a Chef recipe
[default] Forcing shutdown of VM...
[default] Destroying VM and associated drives...
/usr/lib/ruby/vendor_ruby/net/ssh/ruby_compat.rb:33:in `select': closed stream (IOError)
from /usr/lib/ruby/vendor_ruby/net/ssh/ruby_compat.rb:33:in `io_select'
from /usr/lib/ruby/vendor_ruby/net/ssh/ruby_compat.rb:32:in `synchronize'
from /usr/lib/ruby/vendor_ruby/net/ssh/ruby_compat.rb:32:in `io_select'
from /usr/lib/ruby/vendor_ruby/net/ssh/transport/packet_stream.rb:73:in `available_for_read?'
from /usr/lib/ruby/vendor_ruby/net/ssh/transport/packet_stream.rb:85:in `next_packet'
from /usr/lib/ruby/vendor_ruby/net/ssh/transport/session.rb:170:in `poll_message'
from /usr/lib/ruby/vendor_ruby/net/ssh/transport/session.rb:165:in `loop'
anentropic / gist:3812986
Created October 1, 2012 16:53
Chef traceback
[2012-10-01T16:43:39+00:00] INFO: Processing application_python_django[xxx] action before_deploy (wsgi_apps::xxx line 109)
Error executing action `before_deploy` on resource 'application_python_django[xxx]'
anentropic / gist:3828763
Created October 3, 2012 18:20
recipe compile error [2012-10-03T17:38:48+00:00] INFO: *** Chef 10.14.2 *** [2012-10-03T17:38:50+00:00] INFO: Setting the run_list to ["role[base]", "role[apache_wsgi]", "role[db_server]", "role[rbx_web]", "role[encoder]"] from JSON [2012-10-03T17:38:51+00:00] INFO: Run List is [role[base], role[apache_wsgi], role[db_server], role[rbx_web], role[encoder]] [2012-10-03T17:38:51+00:00] INFO: Run List expands to [apt, git, mercurial, hosts, python, apache2, apache2::mod_wsgi, mysql::server, hacks, wsgi_apps::rbx, rabbitmq, rabbitmq::mgmt_console, celery, ffmpeg, ffmpeg2theora, wsgi_apps::enc] [2012-10-03T17:38:51+00:00] INFO: Starting Chef Run for rbxdev-chef [2012-10-03T17:38:51+00:00] INFO: Running start handlers [2012-10-03T17:38:51+00:00] INFO: Start handlers complete. [2012-10-03T17:38:52+00:00] INFO: Loading cookbooks [apache2, application, application_python, apt, aws, build-essential, celery, database, dmg,
anentropic / gist:5090049
Last active August 25, 2016 16:30
Solved vagrant mount -t vboxsf problem ...nothing to do with guest additions
[redis] Mounting shared folders...
[redis] -- v-root: /vagrant
[redis] -- v-csr-3: /tmp/vagrant-chef-1/chef-solo-3/roles
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` v-csr-3 /tmp/vagrant-chef-1/chef-solo-3/roles
and if you ssh in to the vm:
anentropic /
Created July 29, 2014 10:24
reload Django urlconf
def reload_urlconf(urlconf=None, urls_attr='urlpatterns'):
if urlconf is None:
urlconf = settings.ROOT_URLCONF
if urlconf in sys.modules:
reloaded = import_module(urlconf)
reloaded_urls = getattr(reloaded, urls_attr)
anentropic / configure.log
Created July 31, 2014 23:58
Result of ./configure for libcdio
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libcdio configure 0.93git, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --enable-maintainer-mode
## --------- ##
## Platform. ##
anentropic /
Last active August 29, 2015 14:18
retry context manager
import time
from logging import getLogger
class RetryContextInvalidResult(Exception):
class RetryContext(object):
if [ -z "$1" ]; then
echo "Usage: git getpull <SHA>"
exit 1
elif [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then
echo "Not in a git directory"
exit 1
repo_details=( \