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
@aperezdc
aperezdc / styles.css.in
Last active August 29, 2015 14:06
One-line CSS pre-processor àla LESS / SCSS / SASS
/*
* Run this through the C/C++ preprocessor like this:
*
* cpp -nostdinc -w -P input.css.in | sed 'y/$/#/' > output.css
*
* Note that the C/C++ preprocessor always interprets octothorpe characters
* at beggining of lines as preprocessor directives. Use sollar signs instead
* to avoid the trouble. Dollar signs are changed into octothorpes using
* "sed" after passing the source through the preprocessor.
*
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 Adrian Perez <aperez@igalia.com>
#
# Distributed under terms of the MIT license.
import bottle
import hipack, yaml, json
@aperezdc
aperezdc / hipack-webservice.html
Created July 24, 2015 06:55
Simple HiPack conversion web service
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HiPack Web Service Test</title>
<script type="text/javascript">
function convertHiPack() {
var req = new XMLHttpRequest();
req.onload = function () {
if (req.readyState == 4) {
@aperezdc
aperezdc / switch-labels-goto.c
Created September 4, 2015 11:13
Jump to label inside a switch statement in C
/*
* Silly example demonstrating that it is valid to jump
* to arbitrary labels inside "switch" statements using
* "goto" in C.
*/
bool is_not_small_power_of_two (int value)
{
if (value < 0) {
/* It is legal to jump into a switch */
#! /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 / 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)
@aperezdc
aperezdc / callfunction.js
Created December 3, 2014 19:07
Compare speed of f.call(...) vs. %_CallFunction(..., f) in V8
// Run with: d8 --allow-natives-syntax callfunction.js
function f1(n, cb, thisArg) {
for (var i = 0; i < n; i++) {
cb.call(thisArg, i);
}
}
function f2(n, cb, thisArg) {
for (var i = 0; i < n; i++) {
@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