This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: upload-test | |
version: 1 | |
runtime: python27 | |
threadsafe: true | |
api_version: 1 | |
handlers: | |
- url: .* | |
script: main.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# post-checkout hook (on <path-to-project>/.git/hooks/post-checkout file) | |
# to avoid errors for old pyc files when checkout. | |
# Remember execution privileges (chmod +x <path-to-project>/.git/hooks/post-checkout). | |
#!/bin/bash | |
# Start from the repository root | |
cd ./$(git rev-parse --show-cdup) | |
# Delete pyc and empty directories | |
echo "[post-checkout] Deleting .pyc and empty directories" | |
find . -name "*.pyc" -delete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In response to https://bitcointalk.org/index.php?topic=56424.msg1454348#msg1454348 | |
# Highlights that json encoding of floats is no good | |
# and that decimals can be used for encoding. | |
import json | |
from decimal import Decimal as D | |
d1 = D(11) / D(10) # 1.1 | |
d2 = D(22) / D(10) # 2.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from flask import Flask, request, g, render_template | |
app = Flask(__name__) | |
app.config['DEBUG'] = True | |
@app.before_request | |
def before_request(): | |
g.request_start_time = time.time() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
class StringIteratorIO(io.TextIOBase): | |
def __init__(self, iter): | |
self._iter = iter | |
self._left = '' | |
def readable(self): | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Convert camel-case to snake-case in python. | |
e.g.: CamelCase -> snake_case | |
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064 | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# I was frustrated that no matter what buffer setting I passed to communicate, | |
# I could not get stdout from my subprocess until the process had completed. | |
# I googled around and came up with this, which illustrates the problem and a | |
# solution. | |
# http://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line | |
# http://bugs.python.org/issue3907 | |
# http://docs.python.org/library/io.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Very simple HTTP server in python (Updated for Python 3.7) | |
Usage: | |
./dummy-web-server.py -h | |
./dummy-web-server.py -l localhost -p 8000 | |
Send a GET request: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import pymongo | |
import logging | |
import time | |
MAX_AUTO_RECONNECT_ATTEMPTS = 5 | |
def graceful_auto_reconnect(mongo_op_func): | |
"""Gracefully handle a reconnection event.""" | |
@functools.wraps(mongo_op_func) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set t_Co=256 | |
set background=dark | |
if !has('gui_running') | |
let g:solarized_termcolors=&t_Co | |
let g:solarized_termtrans=1 | |
endif | |
colorscheme solarized |