Skip to content

Instantly share code, notes, and snippets.

View twidi's full-sized avatar
🕶️

Stéphane "Twidi" Angel twidi

🕶️
View GitHub Profile
@miohtama
miohtama / gist:5158737
Created March 14, 2013 04:11
Colorful Python logger
# -*- coding: utf-8 -*-
"""
Python logging tuned to extreme.
"""
__author__ = "Mikko Ohtamaa <[email protected]>"
__license__ = "MIT"
from time import time
from functools import wraps
MINUTE = 60
HOUR = MINUTE * 60
DAY = HOUR * 24
class Metrics(object):
def __init__(self, redis, keyspace='metrics'):
self.db = redis
@nvie
nvie / p.fish
Created February 13, 2013 09:43
This is my favorite way of automatically invoking the best suitable Python REPL. It is smart about the environment that it is invoked in (e.g. will respect your current virtual env) and is smart about which interpreter fits best (e.g. using `ipython` if available, or using `python manage.py shell` in case of Django, or `python manage.py shell_pl…
function p --description 'Start the best Python shell that is available'
set -l cmd
if test -f manage.py
if pip freeze ^/dev/null | grep -q 'django-extensions'
set cmd (which python) manage.py shell_plus
else
set cmd (which python) manage.py shell
end
else
@adewes
adewes / data.js
Last active December 12, 2015 03:58
Hierarchical Pie Chart
code_hierarchy_data = [
"",
[
416598,
11581
],
{
"docs": [
"docs",
[
import functools
import logging
def test_test1(*dargs, **dkwargs):
def decorator(function):
@functools.wraps(function)
def wrapper(request, *args, **kwargs):
logging.warning("plouf plouf 1")
return function(request, *args, **kwargs)
@revolunet
revolunet / angularjs.md
Last active October 22, 2021 00:36
BeerJS + AngularJS Paris le 25/2

AngularJS best ressources

Following the AngularJS PARIS meetup (25/2 à 19h à Paris with @sampaccoud @dzen @_kemar @tchack13 @vinz et @revolunet)

Here's our best AngularJS ressources : twitter, github, articles & blogs. Please comment and add your good stuff !

@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)
@Boldewyn
Boldewyn / mdshow
Created December 16, 2012 19:38
Show a Markdown file rendered in the browser. The `markdown` program as well as `base64` must be installed. Assumes, that `x-www-browser` is correctly configured.
#!/bin/bash
MDFILE=$1
x-www-browser $(markdown "$MDFILE" | base64 -w0 | \
cat <(echo -n "data:text/html;charset=UTF-8;base64,") -)
@lecram
lecram / escher.py
Last active February 12, 2025 16:49
This is a toy one-file application to manage persistent key-value string data. The file is *both* the application and its data. When you run any of the commands described in `escher.py --help`, the file will be executed and, after data change, it will rewrite itself with updated data. You can copy the file with whatever name to create multiple d…
#! /usr/bin/env python
"""{escher} -- one-file key-value storage.
What?
This is a toy application to manage persistent key-value string data.
The file {escher} is *both* the application and its data.
When you run any of the commands below, the file will be executed and,
after data change, it will rewrite itself with updated data.
You can copy the file with whatever name to create multiple datasets.
@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 = (