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
| ################################################### | |
| # | |
| # Usage: | |
| # {% load help_text_as_placeholder %} | |
| # form.field|help_text_as_placeholder | |
| # OR | |
| # field|help_text_as_placeholder | |
| ################################################### | |
| from django import template |
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
| from bottle import Bottle | |
| from multiprocessing import Process | |
| app = Bottle() | |
| processes = {} | |
| @app.post('/execution') | |
| def create_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
| # pip install watchdog nose nose-cov flake8 | |
| # watchmedo tricks-from tricks.yaml | |
| tricks: | |
| - watchdog.tricks.ShellCommandTrick: | |
| patterns: ["*.py"] | |
| shell_command: "nosetests --with-cov && flake8 $(find . -name '*.py') --ignore W191" |
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
| """Useful functions to handle the class attribute of DOMNode. | |
| Usage: | |
| ``` | |
| >>> el = document['someid'] | |
| >>> add_class(el, 'class-one') | |
| >>> add_class(el, 'old-class') | |
| >>> change_class(el, 'old-class', 'new-class') | |
| >>> remove_class(el, 'class-one') | |
| >>> print(el.class_name) |
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 string | |
| class MyCoder(object): | |
| def __init__(self): | |
| self.letters = string.ascii_uppercase | |
| def encode(self,msg,skip): | |
| return "".join([self.letters[abs(len(self.letters) - self.letters.index(x) - skip)] for x in msg.upper()]) | |
| def decode(self,msg,skip): |
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 | |
| # -*- coding: utf-8 -*- | |
| from decorator import decorator #http://pypi.python.org/pypi/decorator | |
| @decorator | |
| def trace(f, *args, **kwargs): | |
| """Print scope, call, and argument information.""" | |
| _scope = inspect.getmodule(f).__name__ |
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 httplib | |
| import urllib | |
| import re | |
| import os.path | |
| def gist_write(name, content, ext=None, login=None, token=None): | |
| if ext is None: | |
| ext = os.path.splitext(name)[1] |
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 | |
| class Retry(object): | |
| default_exceptions = (Exception) | |
| def __init__(self, tries, exceptions=None, delay=0): | |
| """ | |
| Decorator for retrying function if exception occurs | |
| tries -- num tries | |
| exceptions -- exceptions to catch |
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
| #Dump | |
| mysqldump db | gzip -c > db.sql.gz | |
| pg_dump db | gzip -c > db.sql.gz | |
| #use gzip --fast | |
| #Restore | |
| gunzip < db.sql.gz | mysql db | |
| bunzip2 < db.sql.bz2 | mysql db |
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/fades --python=python2 | |
| import eventlet # fades==0.14.0 | |
| from eventlet.green import urllib2 # fades==0.14.0 | |
| import argparse | |
| import time | |
| import logging | |
| from logging.handlers import RotatingFileHandler | |
| eventlet.monkey_patch() | |
| #logging config | |
| logfile = "replay.log" |
OlderNewer