% python -i colorful_logging_formatter.py
>>> import logging
>>> logger = logging.getLogger('foo')
>>> logger.setLevel(logging.DEBUG)
>>> import sys
>>> handler = logging.StreamHandler(sys.stderr)
>>> handler.setFormatter(ColorLogFormatter())
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
#!/bin/bash | |
ROOTDIR="$( dirname "$0" )" | |
cd "$ROOTDIR" | |
if [ $# == 0 ]; then | |
python -m unittest discover -v | |
else |
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 collections import OrderedDict | |
class TimerContext(object): | |
def __init__(self, name, callback): | |
self._name = name | |
self._callback = callback | |
self._start = None | |
def __enter__(self): | |
self._start = time.time() |
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
# Rewrite a bunch of commits to clean 'em up | |
# We have a bunch of commits we want to reorganize (anything | |
# after 2a23a731 needs to be reorganized..) | |
% git log --pretty=oneline | |
89bee8d13ae1b0047901d07b139d5980072cddbc fourth | |
984809f2bc6e9598439096dbf4333bbf1aee37d0 third | |
e714be8487bdbb64eb1efc2caa071695825d633f second | |
2a23a731833bb701fae3767452865d4120fadcf4 first |
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
#!/bin/bash | |
## Set a decent keyboard layout.. | |
setxkbmap -layout us -variant altgr-intl & | |
## This is needed for compositing | |
( | |
xrandr --output DP-2 --preferred --primary --pos 0x0 --output LVDS-1 --preferred --pos 1920x300 \ | |
|| xrandr --output DP-2 --preferred --primary --output LVDS-1 --preferred --right-of DP-2 \ | |
|| xrandr --output LVDS-1 --preferred --primary |
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
% pse_admin --help | |
usage: cli-app [-h] {run,db_init} ... | |
positional arguments: | |
{run,db_init} sub-commands | |
run | |
db_init | |
optional arguments: | |
-h, --help show this help message and exit |
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
<!DOCTYPE html> | |
<html><head> | |
<title>Blah</title> | |
<style> | |
body { | |
background: #ddd; | |
} | |
#my-window { | |
position:absolute; |
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 | |
from greenlet import greenlet | |
##------------------------------------------------------------ | |
## | |
## We have a producer (a simple generator) and two | |
## consumers (functions accepting a generator). | |
## |
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 io | |
import re | |
import pytest | |
test_cases = [ | |
(r'eggs:spam:bacon', ['eggs', 'spam', 'bacon']), | |
(r'eggs\:spam:bacon', ['eggs:spam', 'bacon']), | |
(r'eggs\\:spam:bacon', ['eggs\\', 'spam', 'bacon']), | |
(r'eggs\\\:spam:bacon', ['eggs\\:spam', 'bacon']), | |
(r'eggs::spam:bacon', ['eggs', '', 'spam', 'bacon']), |
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
{ | |
"title": "Apache logs", | |
"services": { | |
"query": { | |
"list": { | |
"0": { | |
"query": "*", | |
"alias": "", | |
"color": "#7EB26D", | |
"id": 0, |