Skip to content

Instantly share code, notes, and snippets.


Ben Buckman benbuckman

View GitHub Profile
benbuckman / pig-latin.js
Created Jul 20, 2012
Pig Latin Interpreter in javascript/node.js
View pig-latin.js
Pig Latin interpreter
by Ben Buckman, July 20 2012
- All words beginning with a consonant have their first letter moved to the end of word followed by 'ay'.
Example: Hello -> Ellohay
- All words beginning with a vowel have their first letter moved to the end moved to the word followed by 'hay'.
Example: Another -> Notherahay
benbuckman / intercept-stdout.js
Created May 20, 2012 — forked from pguillory/gist:729616
Hooking into Node.js stdout, pipe stdout to telnet
View intercept-stdout.js
var _ = require('underscore'),
util = require('util');
// intercept stdout, passes thru callback
// also pass console.error thru stdout so it goes to callback too
// (stdout.write and stderr.write are both refs to the same stream.write function)
// returns an unhook() function, call when done intercepting
module.exports = function interceptStdout(callback) {
var old_stdout_write = process.stdout.write,
old_console_error = console.error;
benbuckman / seq-test.js
Created Dec 11, 2011
Understanding node-seq (control flow library for node.js)
View seq-test.js
### OUTPUT ###
vars at end: { firstVar: 'A', secondVar: 'B', thirdVar: 'C' }
in A
vars: {}
in B
vars: {}
timer done in A
in C
vars: {}
benbuckman / drupal-syslog-parser.js
Created Nov 29, 2011
node.js script to parse Drupal logs in linux syslog (and find distinct 404'd URLs)
View drupal-syslog-parser.js
// drupal log parser w/ node.js
// takes a filtered syslog file
// run as node `drupal-syslog-parser.js LOGPATH`
// [install dependencies (lazy,underscore) first with `npm install ___`]
var lazy = require('lazy')
, fs = require('fs')
, path = require('path')
, _ = require('underscore');
View php: output to downloaded csv.php
// force download of CSV
// simulate file handle w/ php://output, direct to output (from
// (could alternately write to memory handle & read from stream, this seems more direct)
// headers from
header('Content-Description: File Transfer');
header('Content-Type: application/csv');
header("Content-Disposition: attachment; filename=FILENAME.csv");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
View Drupal - Re-Sync Content Taxonomy.php
* Implementation of hook_drush_command().
function MODULE_drush_command() {
$items = array();
$items['resync-content-taxonomy'] = array(
'description' => "Re-sync content_taxonomy from term_node",
return $items;