Skip to content

Instantly share code, notes, and snippets.

View davedash's full-sized avatar
🏠
Working from home

Dave Dash davedash

🏠
Working from home
View GitHub Profile
@davedash
davedash / -
Created July 30, 2013 22:54 — forked from anonymous/-
Analyzing performance of various loggers.
import logging
import logging.handlers
log_file = logging.getLogger('f')
log_watch = logging.getLogger('w')
log_rotate_bytes = logging.getLogger('r')
log_time = logging.getLogger('t')
fh = logging.FileHandler('f.log')
wh = logging.handlers.WatchedFileHandler('w.log')
@davedash
davedash / canonical.py
Created June 10, 2013 22:35
Middleware that appends slashes as to not break our url routes.
from logger import statsd
import settings
class CanonicalMiddleware(object):
"""Adjust incoming URLs to have a / so our routing still works.
Additionally this saves the canonical version of the url at
`request.canonical`.
UnboundLocalError: local variable 'key_list' referenced before assignment
Stacktrace (most recent call last):
File "django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "sentry/web/decorators.py", line 110, in _wrapped
return func(request, *args, **kwargs)
File "sentry/web/frontend/docs.py", line 83, in client_guide
context.update(get_key_context(request.user, project))
dsh20 () {
usage="$0 group cmd"
[ -z "$1" ] && echo $usage && return 1
[ -z "$2" ] && echo $usage && return 1
dsh -r ssh -o "-o ConnectTimeout=10" -o "-o CheckHostIP=no" -o "-o StrictHostKeyChecking=no" -F 20 -M -c -g "$1" "$2"
}
@davedash
davedash / pkill.py
Last active February 15, 2018 20:40
This errors out and says the exit code of pkill was the SIGTERM sent.
# run grep asdf &
subprocess.call("pkill -f grep", shell=True)
# Returns -15
subprocess.call("pkill -9 -f grep", shell=True)
# Returns -9, and grep is killed.
app.config.from_pyfile('../settings.cfg')
app.config.from_envvar('ASANA_SETTINGS', silent=True)
@davedash
davedash / mac-homebrew-pyexiv2.sh
Created September 5, 2012 00:14 — forked from jpwatts/mac-homebrew-pyexiv2.sh
In which I finally get pyexiv2 working on my Mac using Homebrew and a series of disgusting hacks
#!/bin/sh
brew install python boost exiv2
curl -O http://launchpadlibrarian.net/61465005/pyexiv2-0.3.0.tar.bz2
tar xjvf pyexiv2-0.3.0.tar.bz2
cd pyexiv2-0.3.0
# https://answers.launchpad.net/pyexiv2/+question/140742
echo "env['FRAMEWORKS'] += ['Python']" >> src/SConscript
TemplateSyntaxError: Caught KeyError while rendering: u'link'
Stacktrace (most recent call last):
File "django/core/handlers/base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "sentry/web/decorators.py", line 118, in wrapped
evelopment server is running at http://127.0.0.1:8000/
Using the Werkzeug debugger (http://werkzeug.pocoo.org/)
Quit the server with CONTROL-C.
/usr/local/lib/python2.7/dist-packages/babel/__init__.py:33: UserWarning: Module pystatsd was already imported from /mnt/pinboard/libs/pystatsd/__init__.pyc, but /usr/local/lib/python2.7/dist-packages is being added to sys.path
from pkg_resources import get_distribution, ResolutionError
/usr/local/lib/python2.7/dist-packages/babel/__init__.py:33: UserWarning: Module traceback was already imported from /usr/lib/python2.7/traceback.pyc, but /usr/local/lib/python2.7/dist-packages is being added to sys.path
from pkg_resources import get_distribution, ResolutionError