Skip to content

Instantly share code, notes, and snippets.

@ntrrgc
ntrrgc / webkit-remote-build.sh
Created September 15, 2017 18:36
WebKit remote build with delta downloads
#!/bin/bash
set -eu
BUILD_HOST=homura.local
BUILD_ARGS=(--gtk --debug)
REMOTE_BUILD_DIR=WebKitBuild/Debug
LOCAL_BUILD_DIR=WebKitBuild/Debug
# Files big enough to deserve xdelta transfer
# Generate with the following command:
@ntrrgc
ntrrgc / gen-edit-lists.py
Last active August 30, 2022 23:59
Generate crazy MP4 edit lists to be added to media files for testing.
#!/usr/bin/python3
#
# 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
ntrrgc / graceful-libvirtd-shutdown.service
Created August 20, 2017 17:04
Gracefully shutdown libvirtd VMs on shutdown. Start and enable the provided systemd service for it to work.
[Unit]
Description=Wait for VMs to shutdown gracefully
After=libvirtd.service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/home/ntrrgc/dotfiles/bin/vm-shutdown
[Install]
@ntrrgc
ntrrgc / patch-qtcreator-project.py
Created July 31, 2017 09:44
Script to import CMake flags into a QtCreator project file
#!/usr/bin/env python
# Usage: python patch-qtcreator-project.py 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
ntrrgc / find-borders.cpp
Created April 21, 2016 22:41
This program scans images in order to find white borders having no substantial content inside.
/*
* 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
ntrrgc / spotify-heisenbug.sh
Created January 27, 2016 18:19
Ugliest hack in quite a time... Fixes the volume control lag in Spotify in the weirdest way you can imagine.
#!/bin/bash
# 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.
@ntrrgc
ntrrgc / example.js
Created December 15, 2015 15:43
fibrous example
var fibrous = require('fibrous');
var fs = require('fs');
var wait = function wait(ms, callback) {
setTimeout(callback, ms);
};
function getSomething() {
var a = fs.sync.readFile('/tmp/a', 'utf8');
var b = fs.sync.readFile('/tmp/b', 'utf8');
@ntrrgc
ntrrgc / comprimir_fotos.sh
Last active November 22, 2015 00:01
Comprimir fotos
#!/bin/bash
if [ ! $# -eq 2 ]; then
echo "Este es un script para comprimir fotos."
echo "Uso: $1 <carpeta con fotos originales> <carpeta de destino para las fotos comprimidas>"
fi
if ! which convert > /dev/null 2>&1; then
echo "No tienes imagemagick... Procedo a instalarlo."
sudo bash -c 'apt-get update && apt-get -y install imagemagick'
fi
@ntrrgc
ntrrgc / base_dir.sh
Created August 18, 2015 18:44
Get the directory where the script resides
# http://stackoverflow.com/a/22614738/1777162
SCRIPT=$( readlink -m $( type -p "$0" )) # Full path to script
BASE_DIR=`dirname "${SCRIPT}"` # Directory script is run in
NAME=`basename "${SCRIPT}"` # Actual name of script even if linked
@ntrrgc
ntrrgc / wallpapers.c
Last active August 29, 2015 14:27
Find images susceptible of being used as wallpaper. The hard way, in C.
#define _BSD_SOURCE
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#include <endian.h>
#include <stdint.h>
#include <sys/stat.h>