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 / 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
/*
* allocator-test.cc
* Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
*
* Distributed under terms of the MIT license.
*/
#include <cstdlib>
#include <cstdio>
@aperezdc
aperezdc / encore-cm10.2-sdswap.sh
Last active December 22, 2015 21:29
Edits the the Nook Color initial ramdisk of Android 4.3-based ROMs (e.g. CyanogenMod 10.2) to mount the internal eMMC data partition to be used as an “SD card”. You need to run this script from an Unix system (e.g. GNU/Linux) with your device connected. The tools “adb” and “mkimage” (from u-Boot) must be installed.
#! /bin/bash
#
# android-4.3-encore-sdswap-ramdisk
# Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
#
# Distributed under terms of the MIT license.
#
set -e
devices=$(adb devices | sed -e 1d -e '/^[:space:]$/d')
@aperezdc
aperezdc / rand31.d
Created September 18, 2013 16:15
RAND31 random number generator in D. Suitable for generating white noise for audio applications.
/*
* rand31.d
* Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
*
* Implements the rand31 random number generation algorithm, which is
* particularly suitable for use as white noise for sound applications.
*
* For more information on the algorithm, please refer to:
* http://www.firstpr.com.au/dsp/rand31/
*
@aperezdc
aperezdc / rand31.rs
Created September 28, 2013 21:21
RAND31 random number generator in Rust. Suitable for generating white noise for audio applications.
/*
* rand31.rs
* Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
*
* Implements the rand31 random number generation algorithm, which is
* particularly suitable for use as white noise for sound applications.
*
* For more information on the algorithm, please refer to:
* http://www.firstptr.com.au/dsp/rand31/
*
@aperezdc
aperezdc / array-custom-allocation.cc
Created November 1, 2013 15:53
Custom allocation in C++ for arrays without using the built-in new[] and delete[] operators.
/*
* array-custom-allocation.cc
* Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
*
* Distributed under terms of the MIT license.
*/
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
@aperezdc
aperezdc / clock.cc
Last active December 27, 2015 11:39
Simple micro-benchmark to know which is faster: a virtual method invocation, or calling through a function pointer + userdata pointer (the userdata is meant to replace the usage of subclasses and also replaces passing the “this” pointer implicitly in virtual method calls).
/*
* clock.cc
* Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
*
* Distributed under terms of the MIT license.
*/
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L
#endif // !_POSIX_C_SOURCE
@aperezdc
aperezdc / memcount.cc
Last active December 29, 2015 09:29
Tool for simple peak system heap memory tracking. Tested with glibc (Linux), may work with any other reasonable *nix system.
/*
* memcount.cc
* Copyright (C) 2013 Adrian Perez <aperez@igalia.com>
*
* Distributed under terms of the MIT license.
*
* Building:
* =========
*
* g++ -std=c++11 -shared -o memcount.so memcount.cc -fPIC -DTRACK_MEM
@aperezdc
aperezdc / Makefile
Created January 15, 2014 19:41
Example on how to measure memory usage using the V8 counters (or any other thing from the counters).
CXXFLAGS += -Wall -std=gnu++11 $(OPT_CXXFLAGS)
LDFLAGS += -lv8
CC = $(CXX)
all: v8-mem-accounting
v8-mem-accounting: v8-mem-accounting.o
clean:
$(RM) v8-mem-accounting v8-mem-accounting.o

Keybase proof

I hereby claim:

  • I am aperezdc on github.
  • I am aperezdc (https://keybase.io/aperezdc) on keybase.
  • I have a public key ASBkif_OHqrzpx3d7P1K378eO_uN2reqFz2jRmGL3LKgZAo

To claim this, I am signing this object: