Skip to content

Instantly share code, notes, and snippets.

@ferryzhou
ferryzhou / mkdir_if_not_exist.m
Created March 31, 2012 22:59
matlab mkdir if not exist
function mkdir_if_not_exist(dirpath)
if dirpath(end) ~= '/', dirpath = [dirpath '/']; end
if (exist(dirpath, 'dir') == 0), mkdir(dirpath); end
end
@ferryzhou
ferryzhou / get_segments.m
Created March 31, 2012 21:30
Get segments from a binary vector
function segs = get_segments(o)
segs = [];
if o(1), st = 1; state = 1;
else state = 2; end
for i = 2 : length(o)
if o(i)
if state == 2
@ferryzhou
ferryzhou / alsa_loopback_min.c
Created February 22, 2012 20:18
A Minimal ALSA Loopback Program
#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>
#define BUF_BYTES 128
int main (int argc, char *argv[]) {
int err;
unsigned char buf[BUF_BYTES];