Skip to content

Instantly share code, notes, and snippets.

@learncodeacademy
learncodeacademy / pubsub.js
Created July 29, 2015 02:54
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@nu7hatch
nu7hatch / _utils.bash
Created April 15, 2013 04:44
Utilities for setup scripts.
# _utils.sh --- Utilities used across all the scripts.
set -e
set -o pipefail
# Prints spaces as a prefix to the command's output.
function prefixed {
sed -e "s/^/ /"
}
@lord-otori
lord-otori / couchbase_export_views.php
Last active August 23, 2017 09:29
A script to export all views in a Couchbase server to files.
<?php
/*
* @author: Juan S. Simon
* @copyright: none, just please don't try to sell it, they'll laugh at you...
*
*/
if (php_sapi_name() != 'cli') {
exit("No web access allowed!" . PHP_EOL);
}