Skip to content

Instantly share code, notes, and snippets.

View edavis's full-sized avatar
💭
I may be slow to respond.

Eric Davis edavis

💭
I may be slow to respond.
View GitHub Profile
@edavis
edavis / google-analytics.js
Created January 23, 2013 21:21
Google Analytics tracking code for NPRI.org/blog/
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6492871-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
@edavis
edavis / twitter_accounts.py
Created July 1, 2012 18:58
Collect names and twitter accounts for Congress members
import sunlight, tablib
lawmakers = sunlight.congress.legislators()
names_and_twitter = tablib.Dataset(headers=('name', 'twitter'))
for lawmaker in lawmakers:
name = lawmaker['firstname'] + " " + lawmaker['lastname']
twitter = lawmaker['twitter_id']
names_and_twitter.append([name, twitter])
@edavis
edavis / gist:2981086
Created June 24, 2012 02:13
Mock not recording headers correctly
# transmission.py
class Transmission(object):
# ... snip ...
def _make_request(self, method, **kwargs):
body = anyjson.serialize(self._format_request_body(method, **kwargs))
response = requests.post(self.url, data=body, headers=self.headers, auth=self.auth)
if response.status_code == CSRF_ERROR_CODE:
self.headers[CSRF_HEADER] = response.headers[CSRF_HEADER]
return self._make_request(method, **kwargs)
return response
@edavis
edavis / gist:1395977
Created November 26, 2011 16:59
Get memcached working with SASL
Download memcached source
./configure --enable-sasl --enable-sasl-pwdb
make
echo "user:password" > memcached-sasl-pwdb
export MEMCACHED_SASL_PWDB=memcached-sasl-pwdb
./memcached -S -vv
Don't need anything with sasl, saslpasswd2, or memcached.conf
@edavis
edavis / transparentnevada.conf
Created July 25, 2011 00:54
django + uwsgi deploy config
# nginx config
server {
server_name transparentnevada.com www.transparentnevada.com;
client_max_body_size 30m;
location /favicon.ico {
alias /srv/django-media/transparentnevada-production/images/favicon.ico;
}
location /static/ {
@edavis
edavis / gist:1047206
Created June 26, 2011 03:48
Emacs config
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "~/.emacs.d/contrib/")
(setenv "PATH"
(concat (getenv "PATH")
":/usr/local/bin:/usr/local/texlive/2010/bin/universal-darwin/"))
;; https://github.com/marktran/color-theme-chocolate-rain
(progn
(require 'color-theme)