Skip to content

Instantly share code, notes, and snippets.

View twidi's full-sized avatar
🕶️

Stéphane "Twidi" Angel twidi

🕶️
View GitHub Profile
@Natim
Natim / uuid_from_text.py
Created March 17, 2014 08:52
UUID from text
import hashlib
import sys
from uuid import UUID
text = sys.stdin.read()
print UUID(hashlib.sha256(text).hexdigest()[:32])
@ishikawa
ishikawa / runtests.py
Created August 31, 2010 16:36
runtests.py: (unit|doc)test discovery
#!/usr/bin/env python
"""
The **runtests.py** script supports simple test discovery (both `doctest`_ and `unittest`_)
and running discovered tests.
* ``-s DIRECTORY`` Directory to start discovery ('.' default)
* ``-t DIRECTORY`` Top level directory of project (default to start directory)
How to use::
@Wilfred
Wilfred / gfm.py
Created April 4, 2011 14:17 — forked from gasman/gfm.py
"""GitHub flavoured markdown: because normal markdown has some vicious
gotchas.
Further reading on the gotchas:
http://blog.stackoverflow.com/2009/10/markdown-one-year-later/
This is a Python port of GitHub code, taken from
https://gist.github.com/901706
To run the tests, install nose ($ easy_install nose) then:
@samuraisam
samuraisam / model_cache.py
Created May 4, 2012 19:30
Django Model Cache and Cached Piston OAuth Store
# The author disclaims copyright to this source code. In place of a legal
# notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
import hashlib, cPickle as pickle, logging
from django.db.models import signals as db_signals
from django.core.cache import cache
@revolunet
revolunet / github.md
Last active October 6, 2015 08:27
Whats missing from Github

Missing features on Github

After some years enjoying github awesomeness, heres what i miss most. Add your comments :)

Id love to use github for agile project management so issues are very important to me :)

Repositories :

@revolunet
revolunet / redisfile.py
Created August 23, 2012 23:36
REDIS file caching
import hashlib
from redis import Redis
#
# automatically cache file access to a redis instance
# check if file changed via md5
#
class RedisFileManager(object):
""" cache file access to a redis instance """
@bartek
bartek / postgres_replication_status.py
Created November 26, 2012 20:18
postgres replication status
# I hate urllib and subprocess, so use tools by Kenneth Reitz.
import envoy
import requests
from socket import socket, AF_INET, SOCK_DGRAM
# Simple script to check the delay in replication between master and slave(s).
# The server runnin this will need to be allowed access via pg_hba to all the
# hosts it connects to.
hosts = (
@jnothman
jnothman / timedeltatype.py
Created November 12, 2012 05:41
An argparse type factory that produces datetime.timedelta objects
import datetime
import re
class TimeDeltaType(object):
"""
Interprets a string as a timedelta for argument parsing.
With no default unit:
>>> tdtype = TimeDeltaType()
@dcramer
dcramer / signals.py
Last active December 10, 2015 16:49
Signals with decorator syntax in Django
from functools import wraps
from django.dispatch import Signal
class BetterSignal(Signal):
def connect(self, receiver=None, **kwargs):
"""
Support decorator syntax:
>>> @signal.connect(sender=type)