Skip to content

Instantly share code, notes, and snippets.

View benjaminws's full-sized avatar

Benjamin W. Smith benjaminws

View GitHub Profile
@benjaminws
benjaminws / bottle_routes.py
Created March 28, 2011 04:02
Alternate way to dispatch routes with bottle.py
from bottle import route
routes = (
# path, function, http_method, name
('/', index_get, 'GET', 'index_get'),
('/', index_post, 'POST', 'index_post'),
)
setup_routes(routes)
15:40.09 Fri Apr 15 2011! ~/Work/geeves
bsmith@the-smiths-macbook!1042 E:2 S:1
-> bin/geeves -V
Fabric 1.0.1
@benjaminws
benjaminws / convert_args.py
Created April 18, 2011 20:20
Convert unicode dict keys from json load to string. This way the dict can be used as kwargs.
kwargs = dict(((str(key), val) for key, val in args['keyword_args'].items()))
@benjaminws
benjaminws / sa_or_ia.txt
Created April 21, 2011 00:12
Systems Administrator, or Infrastructure Architect?
Taken from http://www.infrastructures.org/papers/bootstrap/bootstrap.html "Bootstrapping an Infrastructure"
Lots of important lessons in that paper. Many of them still relevant today. This one is important to remember when hiring a "devop". The context switch is pretty hardcore between the two people outlined below. Remember that.
Systems Administrator, or Infrastructure Architect?
There's a career slant to all of this.
Infrastructure architects typically develop themselves via a systems administration career track. That creates a dilemma. A systems administration background is crucial for the development of a good infrastructure architect, but we have found that the skillset, project time horizon, and coding habits needed by an infrastructure architect are often orthogonal to those of a systems administrator -- an architect is not the same animal as a senior sysadmin.
@benjaminws
benjaminws / gist:945787
Created April 28, 2011 04:13
WAT - uwsgi not installed, or is it?
-bash-3.2# pip -q install uwsgi
Could not find .egg-info directory in install record for uwsgi
-bash-3.2# pip freeze | grep uwsgi
-bash-3.2# pip freeze
gunicorn==0.12.1
meld3==0.6.7
paster==0.6
supervisor==3.0a10
virtualenv==1.6
wsgiref==0.1.2
@benjaminws
benjaminws / line66
Created April 28, 2011 20:26
Current status
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 666, in require
@benjaminws
benjaminws / response_with_orig_req.diff
Created May 22, 2011 22:48
Response object with original Request object as attr
diff --git a/requests/models.py b/requests/models.py
index 2c3241d..689e7db 100644
--- a/requests/models.py
+++ b/requests/models.py
@@ -135,13 +135,14 @@ class Request(object):
return opener.open
- def _build_response(self, resp):
+ def _build_response(self, resp, req):
@benjaminws
benjaminws / gist:991930
Created May 25, 2011 20:49
compile uwsgi on solaris
[admin@ffcgx6an ~/uwsgi-0.9.7.2]$ make -f Makefile.Py27
python2.7 uwsgiconfig.py --build
using profile: buildconf/default.ini
*** uWSGI compiling server core ***
gcc -c utils.c -o utils.o -O2 -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -DUWSGI_BUILD_DATE="\"25 May 2011 20:48:59\"" -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_PORT -DUWSGI_EVENT_TIMER_USE_PORT -DUWSGI_EVENT_FILEMONITOR_USE_PORT -DUWSGI_EMBEDDED -DUWSGI_UDP -DUWSGI_ASYNC -DUWSGI_MULTICAST -DUWSGI_MINTERPRETERS -DUWSGI_INI -DUWSGI_YAML -DUWSGI_LDAP -DUWSGI_SNMP -DUWSGI_THREADING -DUWSGI_SENDFILE -I/opt/local/include/libxml2 -I/opt/local/include -DUWSGI_XML -DUWSGI_XML_LIBXML2 -DUWSGI_PLUGIN_DIR=\".\" -DUWSGI_SPOOLER -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(ping);UDEP(nagios);UDEP(rpc);UDEP(fastrouter);UDEP(http);UDEP(ugreen);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(ping);ULEP(nagios);ULEP(rpc);ULEP(fastrouter);ULEP(http);ULEP(ugreen);"
In file included from utils.c:1:
uwsgi.h:91:21: ifaddrs.h: N
@benjaminws
benjaminws / gist:1015727
Created June 8, 2011 23:38
Some progress with chef.
[Wed, 08 Jun 2011 23:34:31 +0000] INFO: Run List expands to [shootq_app]
[Wed, 08 Jun 2011 23:34:31 +0000] INFO: Starting Chef Run for ffcgx6as.joyent.us
[Wed, 08 Jun 2011 23:34:32 +0000] INFO: Loading cookbooks [build-essential, pkgsrc, python, shootq_app]
[Wed, 08 Jun 2011 23:34:33 +0000] INFO: Storing updated cookbooks/shootq_app/recipes/default.rb in the cache.
[Wed, 08 Jun 2011 23:34:33 +0000] INFO: Processing remote_file[/var/chef/cache/distribute_setup.py] action create (python::pip line 25)
[Wed, 08 Jun 2011 23:34:33 +0000] INFO: Processing bash[install-pip] action run (python::pip line 31)
[Wed, 08 Jun 2011 23:34:33 +0000] INFO: Processing python_pip[virtualenv] action install (python::virtualenv line 23)
[Wed, 08 Jun 2011 23:34:33 +0000] INFO: Processing package[git] action install (shootq_app::default line 8)
[Wed, 08 Jun 2011 23:34:33 +0000] INFO: package[git] installed version
[Wed, 08 Jun 2011 23:34:33 +0000] INFO: Processing directory[/opt/shootq/bin] action create (shootq_app::default line 15
@benjaminws
benjaminws / refactoring_like_a_boss.rb
Created June 9, 2011 16:24
Refactoring like a Boss
# Before
%w{PIL tg.devtools}.each do |pkg|
python_pip "#{pkg}" do
virtualenv "/opt/shootq/shootq/"
action :install
end
end
python_pip "git+https://github.com/pecan/pecan.git" do
virtualenv "/opt/shootq/shootq/"