Skip to content

Instantly share code, notes, and snippets.

detectPeaks = function(data, delta){
var peaks = [],
valleys = [];
var min = Infinity,
max = -Infinity,
minPosition = Number.NaN,
maxPosition = Number.NaN;
@robseward
robseward / MusicPlayerCurrentSensor.ino
Created June 30, 2015 03:04
Current sensing music player
/***************************************************
This code takes input from a non-ivasive current sensor connected to a lamp.
When the lamp is turned on it plays a track on the VS1053 mp3 player (see
link below). The tracks advance each time the lamp is turned on and if the
lamp is left on tracks loop.
- Music files must be labeled track001.mp3, track002.mp3, etc.
- NUM_TRACKS must be set to the number of tracks on the SD card
*.pbxproj -crlf -diff
//
// ImageNameManager.h
//
// Created by Rob Seward on 2/3/11.
// Copyright 2011 VHS DESIGN LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@robseward
robseward / YellowtailIPhone.pde
Created July 6, 2011 15:55
Golan Levin's Yellowtail modified for an iPhone socket connection
/*
* Golan Levin's Yellowtail modified to work with an iPhone socket connection:
* http://robseward.com/blog/2011/06/17/iphone-socket-connection-to-processing/
* Rob Seward 2011
*
*/
import processing.opengl.*;
import java.awt.Polygon;
import processing.net.*;
@robseward
robseward / tag_remover.sh
Created November 9, 2015 19:13
Batch remove git tags from a list (tags.txt)
#!/bin/bash
while read p; do
git push --delete origin $p
git tag -d $p
done <tags.txt
@robseward
robseward / gist:d24e7bc15553ce93b50d
Last active January 5, 2016 15:31
Casting from type Any to AnyObject always fails when Any contains an optional
//: Playground - noun: a place where people can play
import UIKit
var arr = [Any]();
var optionalString: String? = "foo";
arr.append(optionalString);
print(arr[0]); // "Optional("foo")\n"
if let optionalValue = arr[0] as? AnyObject{
print("success") // never executed...
/**
* Z1FFER v0.3.X Firmware.
*
* This code is designed to be as fast as possible.
* It operates two inverted clock signals on pins 9 and 10
* while reading in random bytes on pins 6 and 7.
* Pins are read and written to using the registers for speed.
* The clock signal is irregular but this does not effect the
* performance of the ZIFFER shield.
*/
@robseward
robseward / png_batch_resize.js
Created February 4, 2011 00:20
Finds image in a folder with the suffix "-hd.png", shrinks them by 50% and exports them as a file with the "-hd" removed.
/*
*
* Finds image in a folder with the suffix "-hd.png", shrinks them by 50% and exports them
* as a file with the "-hd" removed.
*
* Rob Seward 2011
*/
$.level=2; //activate debugger if there are problems
import UIKit
var analogValue: Double = 0.00
let max = 1.0
var binaryOut = 0
for _ in (0...100) {
let thermalNoise = Double((arc4random() % 1000)) / 100000
analogValue += thermalNoise