Skip to content

Instantly share code, notes, and snippets.

View briansorahan's full-sized avatar
🎯
Focusing

Brian Sorahan briansorahan

🎯
Focusing
View GitHub Profile
@briansorahan
briansorahan / crash.c
Last active August 29, 2015 14:11
zmq os x crash
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <zmq.h>
#define SOCKS 1000
#define ZMQ_SUCCESS 0
#define ZMQ_FAILURE -1
int main() {
@briansorahan
briansorahan / zmq-crash.js
Last active August 29, 2015 14:11
zmq crash when creating 118 sockets
var i,
zmq = require('zmq'),
numSocks = 1000,
sockets = [];
console.log('MAX_SOCKETS=' + zmq.Context.getMaxSockets());
console.log('creating sockets');
for (i = 0; i < numSocks; i++) {
@briansorahan
briansorahan / cbwrap.js
Last active August 29, 2015 14:09
callback wrapper for node.js
/**
* Wrap a node callback so that it doesn't have to do error-checking.
* Returns a function that checks for an error as the first argument.
* If the error is truthy and you provided an error handler, it passes
* the error to this function. Otherwise it calls cb with the error.
* If there was no error and you provided an error handler, it
* only passes the remaining arguments to cb. Otherwise it passes
* null as the first argument (the error).
*
* @param {Function} cb - function(err, ...) or function(...)
@briansorahan
briansorahan / sc-deps.bash
Created September 14, 2014 14:58
Supercollider dependencies on ubuntu
#!/bin/bash
function main {
sudo apt-get install \
cmake \
build-essential \
libfftw3-dev \
libxt-dev \
libicu-dev \
libqt4-dev \
libasound2-dev \
#include <stdio.h>
#include <lo/lo.h>
#include <lo/lo_types.h>
void
lo_err(int num,
const char *msg,
const char *where)
{
@briansorahan
briansorahan / pre-commit
Last active August 29, 2015 14:03
Running jshint and npm test in pre-commit git hook
#/bin/sh
#
# ...
#
# The pre-commit.sample template prefixes `git diff-index` with exec.
# This is a convenient way to make pre-commit exit with the status of this
# command, but we need to strip the exec prefix if we want to run other commands
# after git diff-index.
#
git diff-index --check --cached $against -- || exit 1
@briansorahan
briansorahan / container-stats.bash
Last active August 29, 2015 14:03
peek at the cgroup stats in sysfs for a docker container
#!/bin/bash
#
# Get docker container sysfs info
#
# Usage
# ./container-stats.bash <docker container id>
#
# Docker container id's can be found using
# docker ps -notrunc
#
@briansorahan
briansorahan / pcmd50.bash
Created June 17, 2014 19:49
copy files from a sony pcmd50 and fix the file extensions
#!/bin/bash
#
# Copy audio files from a Sony PCM-D50 and
# change the file extension from .WAV to .wav
#
function main {
local src=/media/brian/PCMRECORDER
local dst=.
if [ $# -ge 1 ]; then
@briansorahan
briansorahan / gist:10681572
Created April 14, 2014 20:47
testing piping a gist to String.interpret
{ SinOsc.ar }.play;
@briansorahan
briansorahan / convertToWav.bash
Last active August 29, 2015 13:59
Convert sound files to wav with mpg123 and sndfile-convert
#!/bin/bash
#
# Convert all soundfiles of a particular type located in the
# current directory to wav.
#
function convertToWav {
local ext="$1"; shift
for f in *.${ext}; do