Skip to content

Instantly share code, notes, and snippets.

View romuald's full-sized avatar
🍣

Romuald Brunet romuald

🍣
View GitHub Profile
@romuald
romuald / gitlab-thumbs-in-tabs.js
Created February 27, 2020 12:40
Greasemonkey script to add thumbs up and thumbs down buttons beside GitLab tabs in merge requests
// ==UserScript==
// @name Gitlab thumbs in tabs
// @version 1.0
// @description Add thumbs up/down buttons in the "tab" section (tested with gitlab 12.7)
// @author Romuald Brunet <[email protected]>
// @match https://gitlab.com/*/merge_requests/*
// ^ Add your gitlab instance(s) here ^
// @grant none
// ==/UserScript==
@romuald
romuald / subl.sh
Created January 22, 2020 16:18
Sublime text alias, with +lineno option
#!/bin/bash
# Allow to use the subl command with +linenumber to go to line number (like vim)
# example: subl filename.py +208
original=/usr/bin/subl
last="${@: -1}"
prev="${@:~1:1}"
if [ "$#" -gt 1 ] && [ -n "$last" ] && [ -n "$prev" ] && [[ "$last" =~ ^\+ ]]; then
@romuald
romuald / deezer-remote-chrome.py
Created October 1, 2019 12:26
Pilot a Chrome tab with deezer, need to have remote debugging enabled
#!/usr/bin/env python
from __future__ import print_function
import sys
import socket
import json
import optparse
import requests
import websocket # websocket-client
@romuald
romuald / mock_passthrough.py
Created September 2, 2019 12:18
A simple pass-though mock template
import unittest.mock
def mock_passthrough(*args, **kwargs):
"""
A simple mock template to check that a method was called,
not modifying to original patched method.
Behave the same as mock.patch.object(), default autospec is True,
and side_effect is always overrided
@romuald
romuald / yr-highlight-graph.js
Created August 10, 2019 12:26
Hilight the closest line to mouse on YR.no temperature graphs
// ==UserScript==
// @name YR highlight graph
// @namespace chivil.com
// @version 1.0
// @description Hilight the closest line to mouse on temperature graphs
// @author Romuald Brunet
// @match https://www.yr.no/place/*
// @grant none
// ==/UserScript==
@romuald
romuald / divide.py
Created July 17, 2019 15:05
Search python files for division operators, helping spot issues with python3 migrations
#!/usr/bin/env python
"""
This script will search python files inside directories and list use of
the division operator.
It is meant to help spot possible issues with python3 migrations
"""
import io
import os
@romuald
romuald / astgrep.py
Created April 2, 2019 16:46
grep python source strings
#!/usr/bin/env python
"""
grep -r for python source strings
Allows to search for strings splitted across multiple lines
"""
from __future__ import print_function
import io
import re
@romuald
romuald / taskpool.py
Created November 7, 2018 14:17
Simple TaskPool implementation with asyncio
class TaskPool:
"""
asyncio task pool, run no more than n tasks concurrently
Example:
>>> pool = TaskPool(5)
>>> todo = [session.get(url) for url in urls]
>>> tasks = pool.create_tasks(todo)
@romuald
romuald / shielded.py
Created November 2, 2018 14:00
python asyncio shield decorator
def shielded(func):
"""
Makes so an awaitable method is always shielded from cancellation
"""
@wraps(func)
async def wrapped(*args, **kwargs):
return await asyncio.shield(func(*args, **kwargs))
return wrapped
@romuald
romuald / evolution-in-addressbook.pl
Created June 4, 2018 16:14
evolution-in-addressbook
#!/usr/bin/perl
=head1 evolution-in-addressbook
=head2 Synopsis
Parse a mail and tell if the From: is coming from
a contact in one of your evolution address books
=head2 Usage