Skip to content

Instantly share code, notes, and snippets.

View juancarlospaco's full-sized avatar
👑
https://t.me/NimArgentina

Juan Carlos juancarlospaco

👑
https://t.me/NimArgentina
View GitHub Profile
@bhappyz
bhappyz / help_text_as_placeholder.py
Created May 17, 2014 16:09
Django forms add placeholder from help text template tag
###################################################
#
# Usage:
# {% load help_text_as_placeholder %}
# form.field|help_text_as_placeholder
# OR
# field|help_text_as_placeholder
###################################################
from django import template
@santiavenda2
santiavenda2 / Process Web App
Created July 31, 2014 03:04
A Bottle web app to create and terminate processes
from bottle import Bottle
from multiprocessing import Process
app = Bottle()
processes = {}
@app.post('/execution')
def create_process():
@juanpabloaj
juanpabloaj / tricks.yaml
Last active August 29, 2015 14:10
run test and flake8 with watchdog
# 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"
@viniciusban
viniciusban / useful_functions_to_handle_class_attr_of_DOMNode.py
Created January 19, 2015 20:38
Useful functions to handle the class attribute of DOMNode.
"""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)
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):
@kennethreitz
kennethreitz / _tracer.py
Created September 4, 2010 17:17
The greatest trace decorator of all time
#!/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__
@kennethreitz
kennethreitz / gist.py
Created September 9, 2010 00:26 — forked from soeren/gist.py
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]
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
@kennethreitz
kennethreitz / dump_and_restore_DBs.sh
Created April 23, 2011 21:23 — forked from unbracketed/dump_and_restore_DBs.sh
Recipes for dumping and restoring different databases, using different compression formats
#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
#!/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"