Skip to content

Instantly share code, notes, and snippets.

View seanmtracey's full-sized avatar

Sean M. Tracey seanmtracey

View GitHub Profile
@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})`})
@seanmtracey
seanmtracey / ip.sh
Created October 7, 2013 08:33
Really small Shell script for grabbing the local IP of the computer it's run on.
#!/bin/bash
_IP=$(hostname -I) || true
if [ " $_IP " ]; then
printf "$_IP"
fi
exit 0
@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
@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";
})();
#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 / 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'