Skip to content

Instantly share code, notes, and snippets.

View romuald's full-sized avatar
🍣

Romuald Brunet romuald

🍣
View GitHub Profile
@romuald
romuald / with.py
Created November 20, 2014 10:15
python context manager behavior changing over python versions
import sys
class Bar(object):
def __enter__(self):
pass
def __exit__(self, exc, exc_type, tb):
return True
# pong.py
import sys
from time import time, sleep
while True:
print time()
sys.stdout.flush()
sleep(1)
@romuald
romuald / trello-hscroll.js
Last active April 1, 2022 14:24
Trello horizontal wheel scroll
// ==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==
@romuald
romuald / gist:0346c76cfbbbceb3e4d1
Created April 30, 2015 16:05
Sub-millisecond profiling for python pstats
# -*- 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):
@romuald
romuald / dropnames.sh
Last active February 22, 2022 15:58
Drop DNS queries for specific domain names only
#!/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,
@romuald
romuald / deezequalizer.js
Last active September 1, 2015 08:11
Stop Deezer player equalizer animation
// ==UserScript==
// @name Deezer equalizer stop
// @description Stop Deezer player equalizer from animating, saving CPU time in the process. Very useful to save battery
// @namespace http://chivil.com/
// @grant none
// @match https://*.deezer.com/
// @match http://*.deezer.com/
// @include http://*.deezer.com/
// @include https://*.deezer.com/
// @version 1
@romuald
romuald / mo.py
Created August 26, 2015 14:47
Convert bytes into Kbytes, MBytes & cie
#!/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
@romuald
romuald / nofundraiser.js
Last active December 25, 2021 15:18 — forked from anonymous/nofundraiser.js
Greasemonkey script to hide the "small" Wikipedia fundraiser banner
// ==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
@romuald
romuald / readable-docker-docs.js
Created November 12, 2015 10:31
Readable Docker docs
// ==UserScript==
// @name Readable Docker docs
// @namespace http://your.homepage/
// @version 0.1
// @description Readable docs, use more than 50% screen size
// @author You
// @match http://docs.docker.com/*
// @grant none
// ==/UserScript==
@romuald
romuald / bitmap-cache.c
Created December 21, 2015 13:56
Pebble bitmap cache
static BitmapLayer *s_graph_layer;
static GBitmap *s_cache_bitmap;
static void init_bitmap(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
s_graph_layer = bitmap_layer_create(bounds);
s_cache_bitmap = gbitmap_create_blank(bounds.size, GBitmapFormat8Bit);
}