Skip to content

Instantly share code, notes, and snippets.

@FrankGrimm
FrankGrimm / eventpassing.js
Created August 1, 2010 23:24
Event passing for #node.js
/*
* eventpassing.js
*
* Monkey patch for passing events between EventEmitters
* Usage: simply require() this module
*
* @author Frank Grimm (http://frankgrimm.net)
* @version 0.1.3
*
*/
@FrankGrimm
FrankGrimm / na-sample.js
Created July 29, 2010 23:47
Abbreviation for command line parameters in node.js
// Example code for node-abbrev
var abbrevlib = require("node-abbrev");
var sys = require("sys");
// valid run modes for the imaginary tool
var validModes = ["help", "start", "stop", "status"];
// create Abbreviate instance for the modes
// second parameter (case sensitivity) optional, defaults to false
var abbrev = new abbrevlib.Abbreviate(validModes);
_sshm()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
ADD_OPTS=$(sshm --complete)
opts="--help --version --add --list --del --show --complete $ADD_OPTS"
if [[ ${cur} == * ]] ; then