Skip to content

Instantly share code, notes, and snippets.

View seanmtracey's full-sized avatar

Sean M. Tracey seanmtracey

View GitHub Profile
@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"'
ffmpeg -f gdigrab -framerate 30 -i desktop -s 2880x1800 -r 15 -offset_x 10 -offset_y 20 -video_size 1280x800 -show_region 1 -c:v libx264 -preset fast -pix_fmt yuv420p -threads 0 -f flv "rtmp://live-lhr.twitch.tv/app/[YOUR TWITCH STREAM KEY]"
ffmpeg -f avfoundation -i "1:0" -s 1920x1200 -r 15 -c:v libx264 -preset fast -pix_fmt yuv420p -s 1280x800 -threads 0 -f flv "rtmp://live-lhr.twitch.tv/app/[YOUR STREAM API KEY]"
@seanmtracey
seanmtracey / PGZScreenshots.py
Last active July 4, 2016 08:31
A snippet that enables Pygame Zero games to take screenshots during gameplay and save them to a 'screenshots' directory in the same path.
from pygame import image as PGI
import time
def take_screenshot(Surface):
outputDir = './screenshots/'
if not os.path.exists(outputDir):
os.makedirs(outputDir)
PGI.save(Surface, outputDir + str( int(time.time()) ) + '.png' )
def on_key_down(key):
@seanmtracey
seanmtracey / index.html
Last active March 4, 2017 10:33
Paint with light in less than 1024 bytes.
<!DOCTYPE html>
<html>
<head>
<style>
html, body, canvas{width: 100%; height: 100%;margin:0;padding:0;}
</style>
</head>
<body>
@seanmtracey
seanmtracey / Extract_and_analyse.json
Created November 20, 2017 10:50
A Node-red flow for extracting keyframes from videos and analysing them with Watson Visual Recogntion
[{"id":"146f4acc.4733c5","type":"function","z":"ceee673f.122fb8","name":"Determine File Path","func":"if (msg.req.files) {\n var files = Object.keys(msg.req.files);\n msg.payload.filePath = msg.req.files[files[0]][0].path; \n}\nreturn msg;","outputs":1,"noerr":0,"x":278.5,"y":452,"wires":[["c4cd6b26.2acfc8"]]},{"id":"3bf669a6.9b88e6","type":"httpInMultipart","z":"ceee673f.122fb8","name":"","url":"/analyse","method":"post","fields":"[ { \"name\": \"video\", \"maxCount\" : 1 } ]","swaggerDoc":"","x":145,"y":387,"wires":[["146f4acc.4733c5"]]},{"id":"e1f10989.eab7c8","type":"visual-recognition-v3","z":"ceee673f.122fb8","name":"Analyse frame","apikey":"50a86834a2d8947a442a1ba81e9dde323f074786","image-feature":"classifyImage","lang":"en","x":628,"y":652,"wires":[["1a442f8b.94618","5f0f5910.f08c08"]]},{"id":"5f0f5910.f08c08","type":"function","z":"ceee673f.122fb8","name":"Make Sense","func":"\nconst jobData = flow.get(msg.analysisUUID);\nconst frameData = {\n time : msg.keyframeTimeoffset,\n result :
Array.from(table.querySelectorAll('tr')).map(tr => {tds = Array.from(tr.querySelectorAll('td') ); return `${tds[0].querySelector('input').value}=${tds[1].querySelector('textarea').value}` }).join('\n')