Skip to content

Instantly share code, notes, and snippets.

View agateau's full-sized avatar

Aurélien Gâteau agateau

View GitHub Profile
@agateau
agateau / whichpkg
Created November 17, 2021 08:24
Scrape packages.ubuntu.com to list packages containing a given file
#!/usr/bin/env python3
"""
Scrape packages.ubuntu.com to list packages containing a given file.
"""
import argparse
import subprocess
import sys
import urllib.request
#!/usr/bin/env python3
"""
Change the installation prefix of a Qt install
"""
import argparse
import os
import sys
from pathlib import Path
@agateau
agateau / zzcat
Created April 16, 2020 10:58
Cat log-rotated log files passed as arguments in the right order, unpacking them with zcat, bzcat or xzcat if necessary.
#!/usr/bin/env python3
"""
Cat log-rotated log files passed as arguments in the right order, unpacking
them with zcat, bzcat or xzcat if necessary.
"""
import argparse
import os
import subprocess
import sys
@agateau
agateau / git-push
Last active April 4, 2017 09:07
Git hook to prevent pushing to a list of branches
#!/bin/bash
# Copy this as .git/hooks/pre-push
# Customize PROTECTED_BRANCHES
# Make it executable
set -e
PROTECTED_BRANCHES="master release"
confirm() {
local local_branch
import os
import sys
import time
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy import create_engine, Column, Integer, Unicode, ForeignKey
COUNT = 100
@agateau
agateau / 4i1m.py
Created November 5, 2016 18:40
Given a set of letters and a length, finds all words known to hunspell dictionary
#!/usr/bin/env python3
import argparse
import os
import sys
from itertools import permutations
import hunspell
@agateau
agateau / bisect-node-modules
Created May 15, 2015 13:02
A tool to "bisect" Node modules, useful to find out which module is causing failures
#!/bin/sh
set -e
# A tool to "bisect" Node modules, useful to find out which module is causing
# failures.
#
# Given a `node_modules` list known to work and one which is known to be broken,
# do the following:
#
# mkdir /tmp/base_dir
@agateau
agateau / bleachcheck
Created March 31, 2015 07:50
Check if files can be safely removed, according to lsof
#!/bin/sh
set -e
can_be_removed=""
keep=""
for x in * ; do
if [ ! -f "$x" ] ; then
continue
fi
if lsof "$x" > /dev/null ; then
@agateau
agateau / ctags.vim
Created November 14, 2014 09:25
Modified version of ctags.vim, which shows class names in addition to the function names
" ctags.vim: Display function name in the title bar and/or status line.
" Author: Alexey Marinichev <lyosha-vim@lyosha.no-ip.org>
" Maintainer: Gary Johnson <garyjohn@spk.agilent.com>
" Contributor: Keith Reynolds
" Last Change: 2003-11-26 00:23:22
" Version: 2.1
" URL(1.0): http://vim.sourceforge.net/scripts/script.php?script_id=12
" URL(>=2.0): http://vim.sourceforge.net/scripts/script.php?script_id=610
" DETAILED DESCRIPTION:
@agateau
agateau / save-layers.py
Last active August 29, 2015 14:07
Save GIMP layers as individual png files
#!/usr/bin/python
"""
Saves all visible layers of an image as individual png files in the same
folder as the image, using <layer-name>.png for the name.
To use it:
- Save this file in ~/.gimp-$version/plug-ins/
- Restart GIMP
- Open the Image menu, select "Save Layers"