Skip to content

Instantly share code, notes, and snippets.

ntrrgc /
Created Jun 10, 2021
Plots the number of WPT tests passing for a given feature and a set of browsers over time
# Instructions:
# 1. Checkout:
# 2. cd compat-2021
# 3. Edit main.js like this:
# const CATEGORIES = [
# + 'media-source',
# + 'media',
# ];
# ...
ntrrgc /
Last active Apr 6, 2020
My backup script for synology NAS, with safety checks for archival
set -eu
function check_not_empty() {
local path="$1"
if [ ! -d "$path" ]; then
echo "ERROR: $path does not exist!"
elif [ ! "$(ls -A "$path")" ]; then
ntrrgc /
Created Jul 25, 2018
Add library offsets to otherwise useless WebKit crash tracebacks (requires saving /proc/{pid}/maps somewhere before the crash)
import os
import re
from collections import namedtuple
path_maps = os.path.expanduser("~/tmp/rpi-crash-maps")
path_stack = os.path.expanduser("~/tmp/rpi-crash-stack")
MapsLine = namedtuple("MapsLine", ["start", "end", "file"])
ntrrgc / page-watcher.cpp
Created Jun 30, 2018
Proof of concept for page-based watchpoints
View page-watcher.cpp
#define __USE_POSIX199309
#include <cassert>
#include <signal.h>
#include <mutex>
#include <functional>
#include <sys/ptrace.h>
#include <malloc.h>
#include <sys/mman.h>
#include <unistd.h>
#include <set>
ntrrgc /
Created Sep 15, 2017
WebKit remote build with delta downloads
set -eu
BUILD_ARGS=(--gtk --debug)
# Files big enough to deserve xdelta transfer
# Generate with the following command:
ntrrgc /
Last active Mar 31, 2021
Generate crazy MP4 edit lists to be added to media files for testing.
# Generate crazy MP4 edit lists to be added to media files for testing.
# 1. Modify the timescales below with the actual values from the MP4 file.
# 2. Run the following commands to patch the file with Bento:
# # Remove previously existing edit list (optional, only if there is some)
# mp4edit --remove moov/trak/edts original.mp4 patched1.mp4
ntrrgc / graceful-libvirtd-shutdown.service
Created Aug 20, 2017
Gracefully shutdown libvirtd VMs on shutdown. Start and enable the provided systemd service for it to work.
View graceful-libvirtd-shutdown.service
Description=Wait for VMs to shutdown gracefully
ntrrgc /
Created Jul 31, 2017
Script to import CMake flags into a QtCreator project file
#!/usr/bin/env python
# Usage: python CMakeLists.txt.user -DPORT=GTK -DENABLE_MEDIA_SOURCE=ON ...
from argparse import ArgumentParser
from xml.etree import ElementTree
def clean_cmake_args(cmake_args):
Not all arguments are relevant for QtCreator.
Returns a list with only the relevant ones.
ntrrgc / find-borders.cpp
Created Apr 21, 2016
This program scans images in order to find white borders having no substantial content inside.
View find-borders.cpp
* This program scans images in order to find white borders having no
* substantial content inside. This can be used to automatically crop
* meaningless parts of images.
* This program is designed to work only with white backgrounds.
* A Qt based test utility is provided in the main() function.
* Copyright (c) 2016 Juan Luis Boya
ntrrgc /
Created Jan 27, 2016
Ugliest hack in quite a time... Fixes the volume control lag in Spotify in the weirdest way you can imagine.
# For some reason, volume control lags in Spotify, but not when pavucontrol is
# executing.
# Other volume control apps, like gnome-control-center are not enough, it has
# to be pavucontrol.
# This is unfortunate, among other reasons, because pavucontrol uses quite a
# few CPU resources while opened.