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
def my_thread_func(comment_id): | |
# form url based on comment id so http://www.evite.com/services/<comment_id>/whatever | |
# send request | |
# check result, log error | |
from multiprocessing.pool import ThreadPool as Pool | |
def main(): | |
# Read file into a list of IDs | |
list_of_ids = [read from file] |
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 a json body. | |
curl -v -H "Content-Type: application/json" -X POST \ | |
-d '{"action": "Say Hello"}' \ | |
http://example.com/say/hello |
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
# A simple example of using the simple wsgiproxy as a nudge fallback app. | |
# We used this to proxy unfinished requests from appengine, back to our | |
# ec2 app | |
from nudge.publisher import ServicePublisher | |
from wsgiproxy.app import WSGIProxyApp | |
PROTO = 'http' | |
FALLBACK_HOST = 'example.com' |
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
# Prepend something to the beginning of each line | |
cat .gitignore| while read line; do echo "[ERROR] $line"; done > somefile.txt | |
# Delete all the GD pyc files starting in this dir | |
find . -name '*.pyc' -exec rm -f {} \; | |
# | |
# ** Below are some SHELLpers to deal with removing crap from a go vendor dir | |
# NOTE cgo stuff might not like this process ^_^ |
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 re | |
# ---------------------------------------------------------------------------- # | |
# Regex sting substitution | |
# | |
# As a first example, lets say we have a jinja2 template that needs | |
# a particular section(s) replaced | |
LEFT_NAV = re.compile(r'{{\s*left_nav\s*}}') |
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
class TestIter(object): | |
def __init__(self): | |
self.i = 0 | |
self.l = [1,2,3,4] | |
def __iter__(self): | |
return self |
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 logging | |
''' | |
THIS IS A WORK IN PROGRESS. Do not use unless you fully understand this | |
code, and can make needed modifications. | |
''' | |
class LRUCache(object): | |
''' Dumb/fake least recently used cache to just run in memory. | |
''' |
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
''' | |
This is a quick reference example to get you started with yaml. Please review this, | |
but spend the time to fully read the wikipedia page on yaml: | |
http://en.wikipedia.org/wiki/Yaml | |
Note that the magic quote-less yaml parsing will still always strip values. | |
To avoid this you need to use quotes. Quotes can also force types to string type, | |
and are always valid (meaning omitting quotes is for convenience not necessity). | |
''' |
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 traceback | |
for line in traceback.format_stack(): | |
print line.strip() |
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 | |
''' | |
Example of a way you could hash a password with a salt. | |
Pass the password as the first and only parameter. | |
WARNING this is just an example. NEVER put a real password in the clear | |
on the command line like this. | |
''' |