Skip to content

Instantly share code, notes, and snippets.

View gist:12efca5679c9dc35bf4633ac84084505
Verifying my Blockstack ID is secured with the address 1G86FSKc8eYLDzKbTBmgWXWBFBmgJ5BrKG https://explorer.blockstack.org/address/1G86FSKc8eYLDzKbTBmgWXWBFBmgJ5BrKG
View keybase.md

Keybase proof

I hereby claim:

  • I am bwhitman on github.
  • I am bwhitman (https://keybase.io/bwhitman) on keybase.
  • I have a public key whose fingerprint is DD06 06D4 63E7 28C3 2725 FF0A 6B3F EA00 17FE 9410

To claim this, I am signing this object:

@bwhitman
bwhitman / picblast.sh
Created May 8, 2017
Make an audio collage out of your live photos
View picblast.sh
mkdir /tmp/picblast; cd ~/Pictures/Photos\ Library.photoslibrary; for i in `find . | grep jpegvideocompl`;do ffmpeg -i $i /tmp/picblast/${i:(-8)}.wav; done; cd /tmp/picblast; ffmpeg -safe 0 -f concat -i <( for f in *.wav; do echo "file '$(pwd)/$f'"; done ) ~/Desktop/picblast.wav; rm -rf /tmp/picblast
View read_register.py
# Read length data from a register, return the data
def read_register(register, length):
# To read a register you send reg & 0x80, and then read it back
# If you have blocking off the read will return none if it's too soon after
send_data = [0, register, 0x80, length, 0, 0, 0]
what = _dev.write(send_data)
ret = _dev.read(len(send_data) + length)
return ret[4:4+length] # Data comes in at the 4th byte
View gist:886d5081720aa2a76368e5fed50875a0
carry:respeaker-xmos-hid bwhitman$ python listen_and_get_position.py
Mic gain is set to 30
time 0.88428 angle: 30 vad: 2
time 3.54835 angle: 30 vad: 0
time 3.97157 angle: 330 vad: 2
time 5.57193 angle: 330 vad: 0
time 6.38029 angle: 150 vad: 2
time 7.85256 angle: 150 vad: 0
time 8.37984 angle: 150 vad: 2
time 8.97196 angle: 150 vad: 0
View respeaker hid parameters.csv
address size/byte type description value
0x00 4 unsigned char LED_MODE 0: all off 1: one color r,g,b 2: listening [padding 1 byte] direction [2 bytes] 3: waiting 4:speaking strength [1 byte] direction [2 bytes] 5.volume volume [1 byte] 6.display led data 7:auto voice located
null b null null STRENGTH null null null
null g DIRECTION_L null DIRECTION_L null null null
View recog.py
import nltk
import subprocess
from bs4 import BeautifulSoup
_fake_ua = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
def curl_something(url, user_agent = _fake_ua, referer = None, cookies_file = "cookies.txt", wait_rand = 0):
cmd = 'curl -L -s %s -A "%s" %s "%s"' % \
('' if not referer else '-referer "' + referer +'"', user_agent, '' if not cookies_file else "-b " + cookies_file, url)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
View tdoa.matlab
% 2 microphone TDOA using CPS
% http://www.academia.edu/5280022/Direction_of_arrival_estimation_by_cross-
% power_spectrum_phase_analysis_using_prior_distributions_and_voice_activit
% y_detection_information
function [sample_delay, theta_deg]=tdoa(sig, chunk_size, Fs, dist)
% sig should be samples x 2, and a multiple of chunk_size
% chunk_size is the size of each window
% Fs is Fs
% dist is distance mics are apart in mm
@bwhitman
bwhitman / breaddetector.ino
Last active Aug 29, 2015
Bread Detector loop
View breaddetector.ino
void loop() {
uint sensorValue = read_analog();
delay(10);
if (sensorValue > 0) {
float voltage = sensorValue / 1023.0;
float temp = getTemp();
if (temp < 1) temp = 0; // bad connection or something
temp_average = temp_average + temp;
sensor_average = sensor_average + voltage;
readings = readings + 1;
@bwhitman
bwhitman / aifc.diff
Created Apr 27, 2015
Python aifc.py sampler metadata support
View aifc.diff
296d295
< self._loops = []
328,329d326
< elif chunkname == 'INST':
< self._readinst(chunk)
402,407d398
< def getinst(self):
< if len(self._loops) == 0:
< return None
< return self._loops