Skip to content

Instantly share code, notes, and snippets.

@whichlight
whichlight / white-noise-gen.js
Created January 24, 2016 06:49
white noise generator in javascript
var whiteNoiseGen = function(){
var bufferSize = 4096; //Math.pow(2,13); //between 8 & 14
//make this a global var so it isnt garbage collected
whiteNoise = context.createScriptProcessor(bufferSize, 0, 2);
whiteNoise.onaudioprocess = function(e) {
var outputBuffer = e.outputBuffer;
for (var channel = 0; channel < outputBuffer.numberOfChannels; channel++) {
var outputData = outputBuffer.getChannelData(channel);
for (var i = 0; i < bufferSize; i++) {
@whichlight
whichlight / rangefinder_hcsr04.ino
Created September 23, 2012 15:49
rangefinder code hc-sr04
int pingPin = 13;
int inPin = 12;
void setup() {
Serial.begin(9600);
}
void loop()
{
// establish variables for duration of the ping,
@whichlight
whichlight / flask-tweepy-server.py
Created June 6, 2012 03:50
gist of the server script with tweepy oauth
'''
flask-tweepy-oauth
an example showing how to authorize a twitter application
in python with flask and tweepy.
find the rest of the app here: https://github.com/whichlight/flask-tweepy-oauth
'''
@whichlight
whichlight / kinect-depth-smoothing.js
Last active July 12, 2017 09:38
pixel smoothing and moving average in javascript, for Kinect depth frame buffers in https://github.com/whichlight/figure-sketching-kinect/
//from http://www.codeproject.com/Articles/317974/KinectDepthSmoothing
function smoothDepth(arr){
var res = createArray(width,height);
for(var i=2; i< width-2; i++){
for(var j=2; j < height-2; j++){
if(arr[i][j]===0){
var innerBandCount = 0;
var outerBandCount = 0;
var filterCollection = [];
@whichlight
whichlight / mobile_movie_convert.sh
Created October 1, 2011 05:32
convert all .3gp to .mp4 in a directory
#!/bin/bash
#the video recordings in my phone are in .3gp
#so i wrote this to convert .3GP to .mp4
#
#http://whichlight.com/blog/mobile-video-recording-convert-from-3gp-to-mp4/
LIST=`ls *.3gp`
for i in $LIST;
do ffmpeg -i $i -sameq -ab 64k -ar 44100 ${i%3gp}mp4
done
@whichlight
whichlight / gist:8451255
Created January 16, 2014 07:56
button example with betahaus
var button = "&lt;a class=&quot;embedly-button&quot; href=&quot;http://embed.ly/code&quot; data-lang=&quot;Auto (Determined by Browser)&quot;&gt;Embed&lt;/a&gt;<br/>&lt;script&gt;!function(a){var b=&quot;embedly-platform&quot;,c=&quot;script&quot;;if(!a.getElementById(b)){var d=a.createElement(c);d.id=b,d.src=(&quot;https:&quot;===document.location.protocol?&quot;https&quot;:&quot;http&quot;)+&quot;://cdn.embedly.com/widgets/platform.js&quot;;var e=document.getElementsByTagName(c)[0];e.parentNode.insertBefore(d,e)}}(document);&lt;/script&gt;"; var $button = jQuery('<div/>').html(button).text(); jQuery(".post-content").append($button)
@whichlight
whichlight / gist:7418447
Created November 11, 2013 18:59
RGB 32x32 LED grid programming
// colorwheel demo for RGBmatrixPanel library.
// Renders a nice circle of hues on a 32x32 RGB LED matrix.
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
// If your 32x32 matrix has the SINGLE HEADER input,
// use this pinout:
#define CLK 8 // MUST be on PORTB!
#define OE 9
@whichlight
whichlight / gist:7416081
Created November 11, 2013 16:33
serial reading arduino, semicolon between each measurement (like newlines) and comma between vals of each measurement. ex: x1,y1,c1;x2,y2,c2
if (Serial.available() > 0) {
// get incoming byte:
byteRead = Serial.read();
/*Listen for a comma which equals byte code # 44 */
if(byteRead==44){
data[counter] = String(serialDataIn);
serialDataIn = String("");
counter = counter + 1;
}
else if(byteRead == 59){
@whichlight
whichlight / js_interactive_art_talk.md
Last active December 26, 2015 14:59
Making interactive art with Javascript (BarCampBoston 2013)

Making interactive art with Javascript (BarCampBoston 2013)

@whichlight

community

ubiquity

interest

(not so much the technical parts of the language)

ART + JS

@whichlight
whichlight / node kinect problem
Created September 15, 2013 16:20
having some weird issues installing node-kinect on my old laptop. might be some c issue
Installing the module, this comes up, but it still installs fine
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/kinect/src/kinect.o
../src/kinect.cc:1:1: warning: "BUILDING_NODE_EXTENSION" redefined
<command-line>: warning: this is the location of the previous definition
SOLINK_MODULE(target) Release/kinect.node
ld: warning: in /usr/local/lib/libfreenect.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
SOLINK_MODULE(target) Release/kinect.node: Finished