Skip to content

Instantly share code, notes, and snippets.

View aperezdc's full-sized avatar
🛋️
Couch-potatoing

Adrian Perez aperezdc

🛋️
Couch-potatoing
View GitHub Profile
#! /usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Traverse a directory tree, picking embedded pictures from .MP3 and .M4A audio
# saving them to a “cover.{png,jpg,bmp}” (as long as the file does *not* exist)
# and then removing the embedded pictures from the audio file.
#
# Requires the Mutagen tag edition library: https://code.google.com/p/mutagen/
# Most distributions ship in a package called “python-mutagen“.
#
@aperezdc
aperezdc / lpegxml.lua
Last active September 26, 2022 18:21
Fairly complete LPeg grammar for parsing XML
--
-- LPeg-based XML parser.
--
-- * Grammar term names are the same as in the XML 1.1
-- specification: http://www.w3.org/TR/xml11/
-- * Action functions are missing.
--
-- Copyright (C) 2012 Adrian Perez <aperez@igalia.com>
-- Distribute under terms of the MIT license.
--
@aperezdc
aperezdc / notmuch-launch.sh
Created October 21, 2012 11:17
Launch separate Emacs process for Notmuch UI with own appname+icon, works with GNOME Shell
#! /bin/bash
#
# Copyright (C) 2012 Adrian Perez <aperez@igalia.com>
# Distributed under terms of the MIT license.
#
# Install as:
# ~/.local/bin/notmuch-launch
# Dependencies:
# wmctrl (http://tomas.styblo.name/wmctrl)
# xsetclasshint program
@aperezdc
aperezdc / dis-symbol.sh
Created October 25, 2012 19:04
Disassemble given symbols in an object file (requires Zsh)
#! /bin/zsh
#
# dis-symbol
# Copyright (C) 2012 Adrian Perez <aperez@igalia.com>
#
# Distributed under terms of the MIT license.
#
if [[ $# -lt 2 ]] ; then
cat <<EOF
@aperezdc
aperezdc / my-notmuch.el
Created October 29, 2012 11:36 — forked from anonymous/my-notmuch.el.el
Notmuch misc config files
(require 'notmuch)
(require 'notmuch-address)
(notmuch-address-message-insinuate)
(setq notmuch-address-command "/home/aperez/.local/bin/notmuch-addrlookup")
(setq message-kill-buffer-on-exit t)
(setq mail-specify-envelope-from t)
(setq message-sendmail-envelope-from 'header)
(setq mail-envelope-from 'header)
/*
* Spinlock based on Qt atomic operations. Should be fairly portable.
* To use it, it is recommended to use the SpinLock::Acquire helper
* class to follow RAII patterns, e.g.:
*
* static SpinLock g_myLock;
* // ...
*
* void foo() {
* do_seomething();
@aperezdc
aperezdc / git-apply-patch-set
Created May 15, 2013 08:34
Reads a list of patch file names from standard input and uses “git apply” to get them added as individual commits into a Git repository.
#! /bin/bash
set -e
declare -r NL='
'
# extract_patch_info filename.patch
#
# Sets the PATCH_{AUTHOR,DATE,MESSAGE,GIT_ID} globals according to the
@aperezdc
aperezdc / cue-and-audio-to-mp3s
Created May 15, 2013 08:45
Splits a single audio file and a corresponding .cue file describing the tracks from it (as generated by some CD ripping/recording tools) into MP3 files, cutting the input file in the time point specified in the .cue file. Usage: ./cue-and-audio-to-mp3s input.wav < input.cue
#! /bin/bash
set -e
indexes=( )
titles=( )
read_indexes () {
local -a line
local tmp
local in_file=false
@aperezdc
aperezdc / flatedecode.py
Created August 17, 2013 11:34
Simple flate decoder, can be used e.g. for compression object streams in PDF files
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2013 Adrian Perez <aperez@igalia.com>
# Distributed under terms of the MIT license.
import zlib
import sys
/*
* allocator-test.cc
* Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
*
* Distributed under terms of the MIT license.
*/
#include <cstdlib>
#include <cstdio>