Skip to content

Instantly share code, notes, and snippets.

View seanmtracey's full-sized avatar

Sean M. Tracey seanmtracey

View GitHub Profile
@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;
@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 / 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'
int out = 9;
float freq = 50;
void setup(){
pinMode(out, OUTPUT);
}
void loop(){
JSONArray coordinates;
List<String> idx = new ArrayList<String>();
int iter = 0;
float shortest = 10000;
import java.util.*;
void setup() {
import sys, os, json, urllib, urllib2, time
f = open('listedBuildings.json')
locations = json.loads(f.read())
coordinates = []
streets = []
@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));
}
#Found at http://apple.stackexchange.com/questions/57412/how-can-i-trigger-a-notification-center-notification-from-an-applescript-or-shel
osascript -e 'display notification "Lorem ipsum dolor sit amet" with title "Title"'
@seanmtracey
seanmtracey / ginn.js
Last active January 3, 2016 21:19
A Javascript library for making your webpages unnecessarily tall.
var ginn = (function(){
document.body.style.height = document.body.scrollHeight + 100000 + "px";
})();
@seanmtracey
seanmtracey / Face Invaders
Last active December 29, 2015 20:28
A Javascript version of Space Invaders that deletes a random Facebook friend whenever you shoot an enemy.
var invaders=function(){function m(e){(new AsyncRequest).setURI("/ajax/profile/removefriendconfirm.php").setData({uid:e,norefresh:true,unref:"profile_gear"}).send()}function g(e){$.ajax({type:"GET",url:"https://www.facebook.com/ajax/typeahead/first_degree.php?viewer="+e+"&__user="+e+"&__a=1",success:function(e){var t=e;t=t.substring(9,t.length-1);t+="}";t=JSON.parse(t);var n=[];for(var r=0;r<t.payload.entries.length;r+=1){if(t.payload.entries[r].type=="user"){n.push(t.payload.entries[r].uid)}}v=n.length;p=n.length/10;for(var i=0;i<p;i+=1){for(var r=0;r<d;r+=1){w(window.innerWidth/d*r+50,window.innerHeight/2-(i*50+20),n[10*i+r])}}},dataType:"text"});counter.innerHTML=n.length+" friends";y()}function y(){t.clearRect(0,0,e.width,e.height);t.save();t.fillStyle="rgb(0,255,0)";var i=0;furthest.left=0;furthest.right=0;furthest.down=0;while(i<n.length){if(n[i].x<n[furthest.left].x){furthest.left=i}else if(n[i].x>n[furthest.right].x){furthest.right=i}else if(n[i].y>n[furthest.down].y){furthest.down=i}i+=1}var s=0;whil