Skip to content

Instantly share code, notes, and snippets.

@leetreveil
leetreveil / node-id3 event relay
Created November 9, 2010 16:11
Takes an internal event and re-emits it as the parent and with an alias.
processor.emit = function() {
var event = arguments[0];
var value = arguments[1];
//emit original event
self.emit(event, value);
//rewrite to new alias
for(var i in MAPPINGS){
var current = MAPPINGS[i];
if(current.from.indexOf(event) > -1){
@leetreveil
leetreveil / mmfolderscan.js
Created May 19, 2011 19:32
node-musicmetadata folder scan
var fs = require('fs'),
walk = require('walk'),
path = require('path'),
mm = require('musicmetadata');
walker = walk.walk('/Users/leetreveil/Music/Mine', { followLinks : false });
walker.on('file', function(root, fileStats, next) {
if (/^.*\.(mp3|m4a|flac|ogg)/.test(fileStats.name)) {
var fullPath = path.join(root, fileStats.name);
@leetreveil
leetreveil / gist:1092829
Created July 19, 2011 15:44
Change the author of a specific commit (git)
git filter-branch -f --env-filter 'if [[ "$GIT_COMMIT" = "119900cd7054c64f2b8e4774e59afbfc39a28e73" ]]; then export GIT_COMMITTER_NAME="Lee Treveil" GIT_AUTHOR_NAME="Lee Treveil" GIT_COMMITTER_EMAIL="[email protected]" GIT_AUTHOR_EMAIL="[email protected]"; fi' HEAD
wchar_t* command = L"my command";
int len = wcslen(command) + 1;
wchar_t* w_msg = (wchar_t*)malloc(sizeof(wchar_t) * len);
wcscpy(w_msg, command);
free(w_msg);
@leetreveil
leetreveil / gist:1959198
Created March 2, 2012 15:33
unable to load shared lib...
test: test.obj
g++ test.o -o kdssvolumeinfo_node.node -L/usr/local/lib $(KDSS_SLIB_NAME) -shared
test.obj:
g++ $(CPPLAGS) $(CFLAGS) -g -fPIC -DPIC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DEV_MULTIPLICITY=0 $(INCLDIRS) -I/usr/local/include/node kdssvolumeinfo_node.cpp -c -o test.o
@leetreveil
leetreveil / benchbulk.sh
Created September 7, 2012 16:07 — forked from jchris/benchbulk.sh
benchmarking CouchDB bulk inserts in bash
#!/bin/bash
# usage: time benchbulk.sh dbname
# it takes about 30 seconds to run on my old MacBook
BULKSIZE=1000
DOCSIZE=100
INSERTS=10
ROUNDS=10
DBURL="http://localhost:5984/$1"
@leetreveil
leetreveil / gist:4647978
Created January 27, 2013 11:40
musicmetadata read from network
var http = require('https');
var musicmetadata = require('musicmetadata');
http.get('https://dl.dropbox.com/u/1269592/Into%20The%20Back%20%28WORNG%20Remix%29.mp3', function (res) {
var parser = new musicmetadata(res);
parser.on('metadata', function (result) {
console.log(result);
});
parser.on('done', function (err) {
if (err) throw err;
@leetreveil
leetreveil / start-mongo-replset.sh
Last active December 8, 2023 06:34
Shell scripts to create a mongodb replica set and sharded cluster locally
#!/bin/bash
# shell script to create a simple mongodb replica set (tested on osx)
set -e
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
default=$(tput sgr0)
@leetreveil
leetreveil / gist:47f8cae575ef7db08cb2
Last active November 20, 2015 13:36
List duplicate celery tasks in redis queues
""" List duplicate celery tasks in redis queues """
import datetime
import redis
import json
import base64
import pickle
from collections import Counter
import argparse
import sys
@leetreveil
leetreveil / index.js
Created August 19, 2014 15:44
requirebin sketch
var musicmetadata = require('musicmetadata');
addDragDropListener(document, function (files) {
musicmetadata(files[0], { duration: true })
.on('metadata', function (result) {
console.log(result);
if (result.picture.length > 0) {
var picture = result.picture[0];
var url = URL.createObjectURL(new Blob([picture.data], {'type': 'image/' + picture.format}));
var image = document.createElement('img');