Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aturley
aturley / producer.sh
Created October 4, 2011 12:16
The Processing sketch takes pictures, encodes them as strings, and writes them to a fifo. The shell script reads from the fifo, sticks the string into a json object, and publishes to the swarm. The HTML file gets data from swarm and draws the picture.
cat ~/swarmpix | sed 's/^\(.*\)$/{"x":"\1"}/' | ./produce.py produce 660e96311f5ca4c39053726d2d0c81f2661a8ef3 00:23:12:55:73:b7 pic
@aturley
aturley / chrome_reload.sh
Created February 24, 2012 16:22
reload the active document in Chrome
#!/bin/bash
echo 'tell application "Google Chrome" to tell the active tab of its first window
reload
end tell' | osascript -
@aturley
aturley / heapdump.js
Created March 22, 2012 17:32
This generates a heapdump.
var profiler = require('v8-profiler');
var MyClass = function(x) {
this.x = x;
};
MyClass.prototype.getX = function() {
return x;
};
@aturley
aturley / moog.5.js
Created May 23, 2012 15:42
Prettified version of the main javascript source (http://www.google.com/logos/2012/moog.5.js) for the Moog Google Doodle (thanks to http://jsbeautifier.org/).
(function () {
try {
var g = void 0,
i = !0,
j = null,
k = !1,
l, o = this,
aa = function () {},
ba = function (a) {
var b = typeof a;
@aturley
aturley / remacsclient.sh
Created May 24, 2012 17:56
emacsclient-like scripts for open files in remotely running emacs instances. Run remacsserver.sh on the machine running emacs (don't forget to start-server in emacs) and use remacsclient.sh FILENAME to open files. You need to have tramp set up in emacs, a
#/bin/bash
if [ -z "${EMACSCLIENT_HOST}" ]; then
echo "EMACSCLIENT_HOST is not set!"
exit 1
fi
FILENAME=$1
if [ -z "${FILENAME}" ]; then
@aturley
aturley / numberwang.py
Created June 2, 2012 01:09
That's Numberwang!
import random, sys, os
name = [None, None]
sys.stdout.write("enter player 1: ")
sys.stdout.flush()
name[0] = sys.stdin.readline().strip()
sys.stdout.write("enter player 2: ")
sys.stdout.flush()
@aturley
aturley / gist:2955828
Created June 19, 2012 18:45
regex vs split and test in Python
aturley@silverslab [~/play]$ cat regex_vs_split.py
import time
import re
url = "http://octopart.com/api/v2/parts/match?manufacturer_name=texas+instruments&mpn=SN74LS240N&suppress_status_codes=True"
url_x = "http://octopart.com/api/v2/parts/match?manufacturer_name=texas+instruments&mpn=SN74LS240N"
url_l = "http://octopart.com/api/v2/parts/match?manufacturer_name=texas+instruments&mpn=SN74LS240N&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&junk=1&
@aturley
aturley / git-codecheck
Created June 20, 2012 14:55
Run pep8 and pylint on all of the new and modified Python files in a git repo.
#!/bin/bash
if [ -z "$(which pep8)" ];
then
echo "Could not find pep8"
exit 1
fi
if [ -z "$(which pylint)" ];
then
@aturley
aturley / ga_invite.rb
Created June 20, 2012 17:41
GA code snipped
if know_code = true
print "forward this email to 5 friends."
else
print "teach me how to code!"
end
@aturley
aturley / minpylint.py
Created June 27, 2012 18:49
Minimum python file that gets a 10/10 from pylint
"x"