Skip to content

Instantly share code, notes, and snippets.

View eventualbuddha's full-sized avatar

Brian Donovan eventualbuddha

View GitHub Profile
@eventualbuddha
eventualbuddha / proxy.coffee
Created April 28, 2011 22:42
An HTTP proxy server that can act as a system proxy or a local port forwarder with an optional delay
#!/usr/bin/env coffee
sys = require('sys')
http = require('http')
## Argument parsing
args = process.argv.slice(2)
port = 9090
delay = 0
@eventualbuddha
eventualbuddha / gist:974911
Created May 16, 2011 17:27
Illustrates a bug in Github's markdown processor (note the URL)

I've been doing some development on the wesabe-ssu project (I submitted a fix for the Amex scraper wesabe/ssu#1).

(function(exports) {
/*global __fail__*/
/**
Define an assertion that will throw an exception if the condition is not
met. Ember build tools will remove any calls to ember_assert() when
doing a production build.
## Examples
@eventualbuddha
eventualbuddha / gist:3754109
Created September 20, 2012 05:29
Separate alternating grayscale & color photos into separate albums in iPhoto
tell application "iPhoto"
set colorsAlbum to (new album name "COLORS")
set bwAlbum to (new album name "BW")
set allPhotos to (get photos of current album)
set isColor to true
repeat with thisPhoto in allPhotos
if isColor then
add thisPhoto to colorsAlbum
set isColor to false
else
@eventualbuddha
eventualbuddha / gist:4032447
Created November 7, 2012 16:01
Historical US Presidential Election Results
# From http://en.wikipedia.org/wiki/United_States_presidential_election, with percentages for the winners added.
1st 1788–1789
George Washington (no party) – 69 electoral votes (56%)
John Adams (no party) – 34 electoral votes
John Jay (no party) – 9
Robert H. Harrison (no party) – 6
John Rutledge (no party) – 6
2nd 1792
var a = [];
Object.freeze(a);
a.push('foo');
if (a.length === 1) {
console.log("FAIL Object.freeze() with Array");
} else {
console.log("PASS Object.freeze() with Array");
}
@eventualbuddha
eventualbuddha / 00_README.markdown
Created July 16, 2013 17:45
es6ify bug: "Invalid access to private name"

Invalid access to private name

This project is intended to reproduce a bug in which loading es6ify and then loading a file built using es6ify+browserify causes an exception in node.js. When run with grunt the output is shown below:

Running "browserify:dist" (browserify) task
>> Bundled tmp/math.es5.js

Running "concat:dist" (concat) task
File "dist/math.js" created.
@eventualbuddha
eventualbuddha / t.sh
Last active August 29, 2015 14:00
tmux session management
# tmux helper
_t_usage() {
echo "t SESSION # attach to SESSION or do \`z SESSION\` and create tmux SESSION"
}
t() {
case "$1" in
"-h" | "--help")
_t_usage
return 0
@eventualbuddha
eventualbuddha / t.sh
Created August 15, 2014 17:39
tmux helper
# tmux helper
_t_usage() {
echo "t SESSION # attach to SESSION or do \`z SESSION\` and create tmux SESSION"
}
t() {
case "$1" in
"-h" | "--help")
_t_usage
return 0
@eventualbuddha
eventualbuddha / node-attach-test.js
Created August 28, 2014 16:49
Testing matching block comments to AST nodes
var types = require('ast-types');
var n = types.namedTypes;
var esprima = require('esprima');
function printCommentsAndNode(ast, calculatePositionOffset) {
ast.comments.forEach(function(comment) {
if (comment.type !== 'Block' || comment.value[0] !== '*') { return; }
var associatedNode = findAssociatedNodeInAstForComment(ast, comment, calculatePositionOffset);
console.log('COMMENT');