- Create or find a gist that you own.
- Clone your gist (replace
<hash>with your gist's hash):# with ssh git clone [email protected]:<hash>.git mygist # with https
git clone https://gist.github.com/.git mygist
| #!/usr/bin/env python | |
| """ | |
| mocking requests calls | |
| """ | |
| import mock | |
| import unittest | |
| import requests | |
| from requests.exceptions import HTTPError |
<hash> with your gist's hash):
# with ssh
git clone [email protected]:<hash>.git mygist
# with httpsgit clone https://gist.github.com/.git mygist
| #!/bin/bash | |
| sudo apt-get update | |
| sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev | |
| cd | |
| git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
| echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
| echo 'eval "$(rbenv init -)"' >> ~/.bashrc |
| TTL=300 | |
| HOSTED_ZONE_ID= | |
| REVERSE_HOSTED_ZONE_ID= | |
| INSTANCE_ID= | |
| REGION= |
| def timeit(function): | |
| '''Decorator used for debugging. Prints the call and how long it took.''' | |
| def timed(*args, **kwargs): | |
| ts = time.time() | |
| result = function(*args, **kwargs) | |
| te = time.time() | |
| print("{0} ({1}, {2}) {3:.2} sec" | |
| .format(function.__name__, args, kwargs, te - ts)) |
| #!/usr/bin/env python | |
| ## Tiny Syslog Server in Python. | |
| ## | |
| ## This is a tiny syslog server that is able to receive UDP based syslog | |
| ## entries on a specified port and save them to a file. | |
| ## That's it... it does nothing else... | |
| ## There are a few configuration parameters. | |
| LOG_FILE = 'youlogfile.log' |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!