Skip to content

Instantly share code, notes, and snippets.

View seanmtracey's full-sized avatar

Sean M. Tracey seanmtracey

View GitHub Profile
@seanmtracey
seanmtracey / wait.pde
Last active August 29, 2015 13:56
Simple Processing function to make your code wait for a period of time.
void wait(int timeToWait){
int startTime = millis();
while (millis() < (startTime + timeToWait));
}
import sys, os, json, urllib, urllib2, time
f = open('listedBuildings.json')
locations = json.loads(f.read())
coordinates = []
streets = []
JSONArray coordinates;
List<String> idx = new ArrayList<String>();
int iter = 0;
float shortest = 10000;
import java.util.*;
void setup() {
int out = 9;
float freq = 50;
void setup(){
pinMode(out, OUTPUT);
}
void loop(){
@seanmtracey
seanmtracey / Mac Volume from Terminal
Created August 5, 2014 14:25
Handy one-liner bash for setting OS X volume from terminal
#X is a number from 1-7
osascript -e 'set volume X'
@seanmtracey
seanmtracey / statusbar.mm
Created August 26, 2014 20:14
A tiny fix for having content display beneath status bar in Cordova on iOS 7
//Code found at http://stackoverflow.com/questions/19209781/ios-7-status-bar-with-phonegap
- (void)viewWillAppear:(BOOL)animated {
// View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
// you can do so here.
// Lower screen 20px on ios 7
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
@seanmtracey
seanmtracey / maths.js
Created January 6, 2015 11:21
Ancient, tiny library of helper functions I use for maths in Javascript
var maths = (function(){
function trigonometry(whichIsIt, xOrY, radius, angle){
if(whichIsIt == "X"){
var trigonometryX = xOrY + (radius*Math.cos(angle*(Math.PI/180)));
return trigonometryX;
} else if(whichIsIt == "Y"){
var trigonometryY = xOrY + (radius*Math.sin(angle*(Math.PI/180)));
return trigonometryY;
{
"big" : ["http://i.imgur.com/CRSzQ4r.png", "http://i.imgur.com/l94Rfsj.png", "http://i.imgur.com/304PJ9p.png", "http://i.imgur.com/mOnnvms.png", "http://i.imgur.com/k5Eif3W.png", "http://i.imgur.com/xSVGJu4.png"],
"evil" : ["http://i.imgur.com/4s6OJQj.png", "http://i.imgur.com/su9edl7.png", "http://i.imgur.com/bCgGgBM.png"],
"grumpy" : ["http://i.imgur.com/EPGllv4.png", "http://i.imgur.com/DKFbRQ0.png", "http://i.imgur.com/bIqsqSK.png"],
"inHats" : ["http://i.imgur.com/6XcjacS.png", "http://i.imgur.com/GC3lgzg.png", "http://i.imgur.com/q7MZgiG.png", "http://i.imgur.com/VkfIH4a.png", "http://i.imgur.com/zy9cJgS.png", "http://i.imgur.com/OA4rZbW.png", "http://i.imgur.com/w0SzOoY.png", "http://i.imgur.com/zVZXKK4.png", "http://i.imgur.com/ZTn8bgI.png", "http://i.imgur.com/iVWFUlj.png"],
"kitten" : ["http://i.imgur.com/KqFuFSQ.png", "http://i.imgur.com/H3YmnA3.png", "http://i.imgur.com/qqWyfvA.png", "http://i.imgur.com/GS6HUnP.png", "http://i.imgur.com/bTvoEeb.png"]
}
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
@seanmtracey
seanmtracey / ES6 Version
Last active December 22, 2015 21:59
Random color generation for all DOM elements so you can see where that pesky whitespace is coming from.
m=Math.random,v=255;Array.from(document.querySelectorAll("*")).forEach(e=>{e.style.background=`rgb(${m()*v|0},${m()*v|0},${m()*v|0})`})