Instantly share code, notes, and snippets.

View toq_answer.js
#!/usr/bin/env node
/*
refs [interview question](https://gist.github.com/mjpearson/0ea04a4ba886d3f02333)
@author michael pearson <mjpearson@gmail.com>
To turn on debugging, from shell : `export NODE_DEBUG=1`
If execute bit set on toq_answer.js, run with `cat input.txt | ./toq_answer.js`
View toq.md

Code Question --- Pattern-Matching Paths

I Was A Moron For Answering In This Way

enjoy

Problem Description

View twilio_pod_inline.js
#!/usr/bin/env node
var pod = require('bip-pod-twilio');
pod.init(
'twilio',
undefined,
{},
function(msg, level) {
console[level](msg);
},
View gist:5f2b8ded61dd9879779a
#!/usr/bin/env node
var memwatch = require('memwatch'),
heapdump = require('heapdump'),
_ = require('underscore'),
ldap = require('ldapjs');
function dump() {
var f = '/tmp/node_' + process.pid + '_' + Date.now() + '.heapsnapshot';
console.log('Writing Heap Snapshot ' + f);
global.gc();
View foundationshim.js
require.config({
baseUrl : "/static/js",
paths: {
jquery: 'vendor/jquery-bundle-min',
foundation : 'vendor/foundation.min'
},
shim : {
foundation : {
deps : ["jquery" ],
View saucyparser.php
#!/usr/bin/env php
<?php
// Retrieves all selenium screenshot/video test results from saucelabs in a useful way
// quick and dirty, deal with it.
//
// cache is in /cache/{job_id} : remove any job and rerun to reprocess the job
// usable output is in /data/{domain name}/[s|v]_[html_file_name]_[browser][version][job_id][operating_system][_screenshot.png|_video.flv].
//
// @author michael pearson michael@cloudspark.com.au
View sc-dl.js
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);
View Zend_Plugin_Controller_AcceptDetect
<?php
/**
* Detects an XHTML or JSON request type based on the Accept request header
* Can optionally detect whether the request is an XHR request type for further
* routing or rendering decisions (JSONP wrappers for example)
*
*
* How to use (put in application/Bootstrap.php):
*