Skip to content

Instantly share code, notes, and snippets.

@jwatte
jwatte / gist:5dd89b259eb3f42b54eb
Created March 6, 2015 17:50
soundstretch wrapper for extracting BMP from MP3
#!/bin/bash
trap "rm /var/tmp/foo.wav" EXIT
mpg123 -w /var/tmp/foo.wav "$1" >/dev/null 2>/dev/null
echo -n "$1 ; "
bpm=`soundstretch /var/tmp/foo.wav -bpm 2>&1 | grep "Detected BPM rate" | sed -e "s/Detected BPM rate //"`
echo "$bpm"
@jwatte
jwatte / example.csv
Last active August 29, 2015 14:13
IMVU CSV file data
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 1 column, instead of 3. in line 2.
Raw data:
=========
1,2,5\n
3,4,9
Expected:
2,3,7
@jwatte
jwatte / Display.cpp
Created August 16, 2014 05:19
Problem C++ file for Raspberry Pi
#include "All.h"
#include <VG/openvg.h>
#include <VG/vgu.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <bcm_host.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
@jwatte
jwatte / system-local.conf
Created August 3, 2014 22:22
system-local.conf in /etc/dbus-1
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<servicedir>/usr/local/src/voltmon</servicedir>
<policy user="root">
<allow eavesdrop="true"/>
<allow eavesdrop="true" send_destination="*"/>
</policy>
@jwatte
jwatte / net.watte.robots.voltmon.conf
Created August 3, 2014 22:21
net.watte.robots.voltmon.conf in /etc/dbus-1/system.d
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<allow own="net.watte.robots.voltmon"/>
<allow send_destination="net.watte.robots.voltmon"/>
<allow send_interface="net.watte.robots.voltmon"/>
</policy>
</busconfig>
@jwatte
jwatte / dbusvolt.py
Created August 3, 2014 22:17
dbusvolt.py module using dbus
import dbus
class DBusVolt(object):
def __init__(self):
self.bus = dbus.SystemBus()
self.svc = self.bus.get_object('net.watte.robots.voltmon', '/net/watte/robots/voltmon')
self.readfn = self.svc.get_dbus_method('read', 'net.watte.robots.voltmon')
self.offfn = self.svc.get_dbus_method('off', 'net.watte.robots.voltmon')
def read(self):
return self.readfn()
@jwatte
jwatte / voltservice.py
Created August 3, 2014 22:16
voltservice.py file using dbus
#!/usr/bin/python2
import gtk
import dbus
import dbus.service
import dbus.mainloop
import dbus.mainloop.glib
import spivolt
from dbus.mainloop.glib import DBusGMainLoop
@jwatte
jwatte / net.watte.robots.voltmon.service
Created August 3, 2014 22:14
net.watte.robots.voltmon.service file
[D-BUS Service]
Name=net.watte.robots.voltmon
Exec=/usr/local/src/voltmon/voltservice.py
Path=/usr/local/src/voltmon
User=pi
@jwatte
jwatte / Single Reactive Property
Last active December 13, 2015 19:19
Doing reactive/data-flow programming in C# is ludicrously verbose.
public class DrawingFeature : Feature {
public ReactiveProperty<Drawing> Drawing = new ReactiveProperty<Drawing>(this.OnFeatureChanged);
}
// use: theDrawingFeature.Drawing.It = ...;
// theDrawingFeature.Drawing.Change += new EventHandler( ... );
public class ReactiveProperty<T>