Skip to content

Instantly share code, notes, and snippets.

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
@bwhitman
bwhitman / CoreMotion.m
Last active July 6, 2016 03:53
Example output and query code for the historical "M7" data from CMMotionActivityManager
/*
2013-09-29 21:23:26.468 perf[3911:60b] Sep 26, 2013, 8:47 AM confidence high type walking steps 16
2013-09-29 21:23:26.469 perf[3911:60b] Sep 26, 2013, 8:56 AM confidence high type walking steps 0
2013-09-29 21:23:26.471 perf[3911:60b] Sep 26, 2013, 8:56 AM confidence low type steps 0
2013-09-29 21:23:26.472 perf[3911:60b] Sep 26, 2013, 8:56 AM confidence low type walking steps 0
2013-09-29 21:23:26.474 perf[3911:60b] Sep 26, 2013, 8:56 AM confidence medium type walking steps 0
2013-09-29 21:23:26.475 perf[3911:60b] Sep 26, 2013, 8:56 AM confidence high type walking steps 341
2013-09-29 21:23:26.476 perf[3911:60b] Sep 26, 2013, 9:04 AM confidence high type walking steps 6
2013-09-29 21:23:26.478 perf[3911:60b] Sep 26, 2013, 9:04 AM confidence low type steps 18
2013-09-29 21:23:26.480 perf[3911:60b] Sep 26, 2013, 9:05 AM confidence low type steps 6
@bwhitman
bwhitman / gist:1041662
Created June 23, 2011 00:56
Echoprint song/identify query example
http://developer.echonest.com/api/v4/song/identify?api_key=N6E4NIOVYMTHNDM8J&code=eJy1mVuSZCkORLcEkgCxHF7a_xLmEPMxNmUWxEdZ9cMts4i4FySXu9OdUtKWHjDlBfsFOc0XmLzA0wv2E2I9QO5nvsMYL-D7D4j2AO3rAZb8Bfk8gBe8ILcX_FX39wN-dF_0BWO-4JQHSI4X6HlBkRfM9YJdH6Ac-wG3nF_B8nyB2gP-JTfyC1Z7wQ_m-AtqfsHsLzj2ANH9gjc3ur1g9AeoP6HPF6z6AEtPaPGAf8icH93vL9D6giov8P2Ct6rYeMG7-1ejv4KaPuBHB0u8wMcL-nnAr-6PF_yNbuz1gF_dfyqDnxf8O92o_QX_jDlvZdCQB1j2B1zTesA1pe_wN9w47QG5jRe8u_-e_Xus72D9BT98YT1AU31BXS_44QvtASmVF7w7eDf-HU59QL4b_w4_JnQ_QKq_4N2j-_iv8CPXvWdwzxdEfsCvDtoLfnRwvOBvOvjDf58dfE_Zu7_P3K63JN_hL9LX33TQrpF-gRkHQzvqq7fky_PYYy7lD4g508_Ke_H3iRRr2ZDWUxt1lSPcrFtva1ibSYTPe_Ex3QtOlWuT1CUV3-5mbdU81snbd6-lnai5yJZ8fIY3DR3ZoseM3UvfJrP2Heiwmo1Wp2WVJVaWsjubY-fI5Yy1Wi82Vs7Dy5giM00eZOxBHVdrkZcdSs8rXEvMms7yZn62n-ll0jKfyfcSlXN2EQxpxGyn8-3tKw7XaRULj1mGpS0zeqFK0c7Y1WduU8M6G0spmle-FUUXNVBV9-rK3nlo99xzC9rcVCoXsdLZWo_NptOxMndZ-ahx4s97_1hl5yO-rnqI5Cn8ARVtrffTOF_10HWblmN1duS7YeQnNT-lm68jlHzVuAXOW6XQEs6YecbsvR4_1jTL3qdNWRyljaalr7lXj7QnP9kOhQNSqD4H6oXP0J1GimVrIWW3rHoqXBla7fDcnj
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)
@bwhitman
bwhitman / gist:8676124
Created January 28, 2014 20:50
salami file
# title: Love Comes Quickly
# artist: Pet Shop Boys
# metre: 4/4
# tonic: B
0.0 silence
0.743038548 A, intro, | B:5 | B:5 | B:5(b7) | B:5 |, (synthesizer
11.193129251 B, instrumental, | G:maj/3 | G:maj/3 | F#:min/b3 | B:min |
20.140702947 | G:maj/3 | G:maj/3 | F#:min/b3 | B:min |
29.032562358 | G:maj/3 | G:maj/3 | F#:min/b3 | B:min |
@bwhitman
bwhitman / gist:8300812
Created January 7, 2014 15:17
@kurtjx leaves me a present
# hahaha good luck reading this you fucker.
for catype, catfunc, class_labels in (('f', lambda x:_f_demos(x["f"]) , [x for x in features.F_RANGES]), ('sub', lambda x:1 if x['class']=='sub_a' else 0, ('sub_a', 'sub_b'))):
#!/usr/bin/env python
# encoding: utf-8
"""
salami.py
"""
import sys
import re
import os
@bwhitman
bwhitman / words.txt
Created October 16, 2013 20:13
Words of Advice for Young People by William Burroughs
People often ask me if I have any words of advice for young people.
Well here are a few simple admonitions for young and old.
Never intefere in a boy-and-girl fight.
Beware of whores who say they don't want money.
The hell they don't.
What they mean is they want more money. Much more.
If you're doing business with a religious son-of-a-bitch,
Get it in writing.
His word isn't worth shit.
Not with the good lord telling him how to fuck you on the deal.
@bwhitman
bwhitman / perf.c
Last active December 24, 2015 06:09
FFT performance on the 5s 64-bit mode vs. 32-bit mode
/*
100,000 iterations of a 1024 point real->imag FFT, computing magnitude & phase and then its inverse again
Run twice, once with double precision and then again using the single precision float vDSP
5s in 32 bit mode
2013-09-29 13:48:47.009 perf[3513:60b] doFFT double precision took 157.924796 seconds
2013-09-29 13:49:13.707 perf[3513:60b] doFFT single precision took 26.697247 seconds
5s in 64 bit mode
2013-09-29 13:51:47.402 perf[3524:60b] doFFT double took 57.861582 seconds (2.7x speedup over 32-bit mode)
@bwhitman
bwhitman / gist:6263131
Created August 18, 2013 18:17
Suggestions for the Echo Nest Softball Team Name
What's on Second
Itsamateursecco
The Ghost Tracks
Marni & The Greenbergs
I Can't Believe The Echo Nest Has a Softball Team
Family Game Night
The Sonos Whiplash
Echo Best
The Taste Profiles
reallyhit()