Skip to content

Instantly share code, notes, and snippets.

View DazWorrall's full-sized avatar

Darren Worrall DazWorrall

  • UK
  • 21:28 (UTC +01:00)
View GitHub Profile
@DazWorrall
DazWorrall / postactivate
Created September 6, 2012 09:43
Automatically switch to a directory with a matching name when entering a virtualenv
#!/bin/bash
# This hook is run after every virtualenv is activated.
venv=`basename "$VIRTUAL_ENV"`
if [ -d "$HOME/src/$venv" ]; then
cd "$HOME/src/$venv"
fi
@DazWorrall
DazWorrall / myflask.py
Created September 24, 2012 08:55
Subclass the Flask exception handler
'''
Original here: https://github.com/mitsuhiko/flask/blob/master/flask/app.py#L1295
'''
from flask import Flask
class MyFlask(Flask):
def log_exception(self, exc_info):
"""
Overriden to provide the full url (including scheme, hostname and query string)
@DazWorrall
DazWorrall / new_stacktrace.log
Created September 25, 2012 15:58
Taking a screenshot using selenium
Connecting
Traceback (most recent call last):
File "screenshot.py", line 16, in <module>
desired_capabilities=desired_capabilities,
File "/Users/daz/.virtualenvs/1a5c5f7263517393/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 63, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Users/daz/.virtualenvs/1a5c5f7263517393/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 105, in start_session
'desiredCapabilities': desired_capabilities,
File "/Users/daz/.virtualenvs/1a5c5f7263517393/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in execute
self.error_handler.check_response(response)
@DazWorrall
DazWorrall / shell.out
Created October 1, 2012 10:35
Raven error when client disconnects on async server
$ pip install flask blinker raven gunicorn gevent
...
$ gunicorn -k gevent test:app
2012-10-01 11:16:57 [62111] [INFO] Starting gunicorn 0.14.6
2012-10-01 11:16:57 [62111] [INFO] Listening at: http://127.0.0.1:8000 (62111)
2012-10-01 11:16:57 [62111] [INFO] Using worker: gevent
2012-10-01 11:16:57 [62112] [INFO] Booting worker with pid: 62112
2012-10-01 11:26:00 [62292] [ERROR] Error handling request
Traceback (most recent call last):
File "/Users/daz/.virtualenvs/b99e1a9fba3d9901/lib/python2.7/site-packages/gunicorn/workers/async.py", line 44, in handle
@DazWorrall
DazWorrall / brew doctor.out
Created November 15, 2012 11:02
brew install bitlbee
$ brew doctor
Your system is raring to brew.
@DazWorrall
DazWorrall / homebrew.mxcl.bitlbee.plist
Created November 15, 2012 14:12
Bitlbee launchd script
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC
"-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>mac.bitlbee</string>
<key>ProgramArguments</key>
<array>
@DazWorrall
DazWorrall / logstash.conf
Last active November 3, 2015 12:00
Grok config for Magento exception.log
input {
file {
path => "/path/to/exception.log"
type => "magento_exception"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601}"
negate => true
what => "previous"
}
}
@DazWorrall
DazWorrall / client.out
Created February 21, 2013 11:24
Script to reproduce failed login bug in pyftpdlib 1.0 using the multiprocess ftp server
Connected to 172.16.137.140.
220 pyftpdlib 1.0.0 ready.
Name (172.16.137.140:daz): bad
331 Username ok, send password.
Password:
421 Service not available, remote server timed out. Connection closed.
ftp: Login failed
ftp>
@DazWorrall
DazWorrall / foo.sh
Created February 28, 2013 09:33
Useful varnishlog commands
varnishlog -c -m TxStatus:503 #Log client (not backend) requests that result in a 503 being returned to a client
@DazWorrall
DazWorrall / test_salt.py
Last active December 14, 2015 13:09
Apply a salt state to the current machine using the internal api
import salt.config
opts = salt.config.minion_config('/tmp/foo') # Doesnt need to be present
opts['file_client'] = 'local' # I dont know if this is right. Not 'remote'
opts['cachedir'] = '/tmp/salt' # Needs to be writeable
d = {
'/tmp/bacon': {
'file': [
'directory',