Skip to content

Instantly share code, notes, and snippets.

View mjpearson's full-sized avatar

mike pearson mjpearson

View GitHub Profile
@mjpearson
mjpearson / toq.md
Last active January 11, 2016 05:14

Code Question --- Pattern-Matching Paths

I Was A Moron For Answering In This Way

enjoy

Problem Description

#!/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`
@mjpearson
mjpearson / foundationshim.js
Last active December 14, 2015 20:49
foundation.js shim into requirejs example
require.config({
baseUrl : "/static/js",
paths: {
jquery: 'vendor/jquery-bundle-min',
foundation : 'vendor/foundation.min'
},
shim : {
foundation : {
deps : ["jquery" ],
@mjpearson
mjpearson / saucyparser.php
Created April 30, 2012 21:10
selenium test result retriever for saucelabs
#!/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
@mjpearson
mjpearson / sc-dl.js
Created March 5, 2012 21:10 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(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);
@mjpearson
mjpearson / Zend_Plugin_Controller_AcceptDetect
Created December 21, 2011 19:57
zend xml/json rest predispatch plugin
<?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):
*
#!/usr/bin/env node
var pod = require('bip-pod-twilio');
pod.init(
'twilio',
undefined,
{},
function(msg, level) {
console[level](msg);
},
@mjpearson
mjpearson / gist:5f2b8ded61dd9879779a
Created October 14, 2014 18:16
ldapjs client example - heapdump + gc
#!/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();