Skip to content

Instantly share code, notes, and snippets.

@robseward
robseward / gist:39278e2afaf7857d5a93933cdac7ba62
Last active August 30, 2016 20:21
app store test receipt
{
"status": 0,
"latest_receipt_info": [{
"original_purchase_date_ms": "1471553815000",
"original_transaction_id": "1000000230529246",
"purchase_date_pst": "2016-08-18 13:56:55 America\/Los_Angeles",
"purchase_date_ms": "1471553815000",
"quantity": "1",
"original_purchase_date": "2016-08-18 20:56:55 Etc\/GMT",
"is_trial_period": "false",
@robseward
robseward / arduino_restart_test.py
Created May 9, 2016 16:13
Running this script with a port name as an argument will restart an Arduino attached to that port
import serial
import sys
import time
portname = sys.argv[1]
ser = serial.Serial('/dev/' + portname, 230400)
def reset_arduino():
ser.setDTR(0)
time.sleep(0.22)
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
/**
* 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 / 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...
@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 / 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
detectPeaks = function(data, delta){
var peaks = [],
valleys = [];
var min = Infinity,
max = -Infinity,
minPosition = Number.NaN,
maxPosition = Number.NaN;
@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 / 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