This file contains 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 | |
# This script check that the .py files that | |
# you're about to commit are syntactically valid | |
# Might want to check with a specific python binary | |
PYTHON=python | |
exit_status=0 | |
for file in $(git diff --cached --name-only --diff-filter=ACM | grep -e '\.py$') | |
do |
This file contains 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
SELECT user, pid, client_addr, waiting, query, query_start, NOW() - query_start AS elapsed | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' | |
-- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1 | |
ORDER BY elapsed DESC; |
This file contains 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
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import re | |
import sys | |
class ProgressBar(object): | |
""" | |
A simple progress bar for terminal |
This file contains 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
# -*- coding: utf8 -*- | |
""" | |
A simple monkeypath for the pstats module to be able to see sub-millisecond timings | |
If display value is 0.000, display the time in microseconds | |
""" | |
import pstats | |
def f8(x): |
This file contains 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
""" | |
This is a simple "pass-through" patch recipe for python testing | |
Allows to check if a method was called during testing | |
For example: | |
``` | |
with nosy_patch('package.inner_method') as mock: | |
package.outter_method() |
This file contains 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
// ==UserScript== | |
// @name Trello horizontal wheel scroll | |
// @namespace http://chivil.com/ | |
// @downloadUrl https://gist.github.com/romuald/57c28352911313524f10/raw | |
// @version 0.9 | |
// @description Scroll horizontally when using mouse wheel | |
// @author Romuald Brunet | |
// @match https://trello.com/b/* | |
// @grant none | |
// ==/UserScript== |
This file contains 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 | |
""" | |
Converts large bytes into a more readable form. | |
Example:: | |
% python mo.py 769736704 | |
734.08 Mio - 751696.00 Kio | |
""" | |
import sys |
This file contains 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/sh | |
# Drop DNS queries for specific domain names only | |
for DOMAIN in $@; do | |
HEX=$(perl -e 'print map {chr(length($_)).$_} split /\./, "'$DOMAIN'"' | xxd -p) | |
iptables -A OUTPUT -p udp --dport 53 \ | |
-m string --hex-string "|$HEX|" --algo bm -j DROP | |
# Alternatively, drop responses only | |
# Note that this is NOT correct and will drop any response *containing* this name, |
This file contains 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
# -*- coding: utf-8 -*- | |
import pprint | |
import unittest | |
class PrettyDiffPrinter(pprint.PrettyPrinter): | |
"""A pprint subclass to hide some differences | |
that usually don't matter in tests | |
""" |
This file contains 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
// ==UserScript== | |
// @name No Wikipedia fundraiser | |
// @namespace http://chivil.com/ | |
// @version 0.1 | |
// @description Should hide Wikipedia "small" banner on each page | |
// @author Romuald Brunet | |
// @match https://*.wikipedia.org/* | |
// @grant none | |
// @run-at document-end |
NewerOlder