start new:
tmux
start new with session name:
tmux new -s myname
| import bottle | |
| # monkey patch bottle to strip trailing slash if result not found | |
| app = bottle.app() | |
| router_match = app.router.match | |
| def our_match(environ): | |
| try: | |
| targets, urlargs = router_match(environ) | |
| except HTTPError as e: | |
| if e.status == 404 and environ['PATH_INFO'].endswith('/'): |
| [ | |
| { | |
| "event": "send", | |
| "msg": { | |
| "ts": 1365109999, | |
| "subject": "This an example webhook message", | |
| "email": "example.webhook@mandrillapp.com", | |
| "sender": "example.sender@mandrillapp.com", | |
| "tags": [ | |
| "webhook-example" |
| from rest_framework import mixins | |
| from rest_framework.generics import SingleObjectAPIView | |
| from yourapp.mixins import PartialUpdateModelMixin | |
| class RetrievePartialUpdateDestroyAPIView(PartialUpdateModelMixin, | |
| mixins.RetrieveModelMixin, | |
| mixins.UpdateModelMixin, | |
| mixins.DestroyModelMixin, | |
| SingleObjectAPIView): |
| """ | |
| Example of setting up CORS with Bottle.py. | |
| """ | |
| from bottle import Bottle, request, response, run | |
| app = Bottle() | |
| @app.hook('after_request') | |
| def enable_cors(): | |
| """ |
Wes Winham winhamwr@gmail.com
There are many tutorials floating around the web that almost get you a dynamic VPN in EC2. The goal of this tutorial is to be a one-stop-shop for this specific setup.
| #!/bin/sh | |
| # Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh | |
| set -e | |
| # Must be a valid filename | |
| NAME=foo | |
| PIDFILE=/var/run/$NAME.pid | |
| #This is the command to be run, give the full pathname | |
| DAEMON=/usr/local/bin/bar |
| import math | |
| import Image | |
| import Levenshtein | |
| class BWImageCompare(object): | |
| """Compares two images (b/w).""" | |
| _pixel = 255 |
| I use Homebrew and wanted to install pip for mercurial. Pip requires a homebrew-installed version of Python, which is fine and dandy; however, I noticed that webkit2png was broken after I installed Python with Homebrew (it was missing pyobjc libs, which comes with the OS X Python install by default). | |
| This assumes that the current homebrewed version of Python is 2.7.1 and that homebrew is set up for /usr/local. If that's not the case, you may have to change the minor version of setuptools (e.g. from 2.7 to 2.8) and change the PATH accordingly. | |
| $ brew install python | |
| Modify your PATH to include the path to Python's bin directory: | |
| export PATH="/usr/local/Cellar/python/2.7.1/bin:/usr/local/bin:$PATH" |