Skip to content

Instantly share code, notes, and snippets.

View neonstalwart's full-sized avatar

Ben Hockey neonstalwart

  • google.com
  • Boulder, CO
View GitHub Profile
dojo.provide("dojox.mustache._Templated");
dojo.require("dijit._Templated");
//
// INSTALL: copy http://github.com/janl/mustache.js to this folder as _base.js
// Add dojox.mustache = dojo.hitch(Mustache, "to_html") in _base.js, wrapping
// the whole file in a self-executing-anonymous-function. eg:
//
// dojo.provide("dojox.mustache._base");
// (function(){
// /* contents of Mustache.js */
(function(d){
console.log("Wrapping dojo.connect/subscribe");
var dc = d.connect,
ddc = d.disconnect,
ds = d.subscribe,
dus = d.unsubscribe,
uniqueHandleId = 0,
handleIds = {};
var handleData = { connect: 0, disconnect: 0, subscribe: 0, unsubscribe: 0 };
@igstan
igstan / parser.js
Created June 9, 2011 13:29
JavaScript Monadic Parser Combinators
var bind = function (prev, bridge) {
return function (input) {
var result = prev(input);
return result.length === 0 ? result : bridge(result[0])(result[1]);
};
};
var result = function (a) {
return function (input) {
return [a, input];
@idris
idris / lesswatch.js
Created July 13, 2011 14:37
lesswatch command that can be run to watch a directory and compile .less files to .css files when they are modified.
#!/usr/bin/env node
var fs = require('fs');
var exec = require('child_process').exec;
/*
* lesswatch usage:
*
* `lesswatch` to watch the current directory
@Gozala
Gozala / weak-map.js
Created October 7, 2011 10:34
Harmony WeakMap shim for ES5
/* vim:set ts=2 sw=2 sts=2 expandtab */
/*jshint asi: true undef: true es5: true node: true devel: true
forin: false latedef: false */
/*global define: true */
if (typeof(WeakMap) === 'undefined') WeakMap = (function(global) {
"use strict";
function defineNamespace(object, namespace) {
@phiggins42
phiggins42 / tunlr
Created November 11, 2011 15:05
tunlr!
#!/usr/bin/env node
/*
tunlr - simple SSH tunnel management
usage: tunlr [options] [command]
options:
-q quiet. suppress console output.
@Raynos
Raynos / weak-map.js
Last active September 18, 2019 07:49 — forked from Gozala/weak-map.js
Harmony WeakMap shim for ES5
// Original - @Gozola. This is a reimplemented version (with a few bug fixes).
window.WeakMap = window.WeakMap || (function () {
var privates = Name()
return {
get: function (key, fallback) {
var store = privates(key)
return store.hasOwnProperty("value") ?
store.value : fallback
},
@bryanforbes
bryanforbes / adapt.js
Created June 20, 2012 18:19
Deferred adapter for node
define([
"dojo/Deferred"
], function(Deferred){
var slice = Array.prototype.slice;
return function adapt(func){
var args = slice.call(arguments, 1),
def = new Deferred;
args.push(function(err, value){
if(err){
anonymous
anonymous / ui.js
Created August 8, 2012 13:24
Separating presentation vs behavior
collectionModel = /* could be from some model constructor with direct data array, from a query result, a URL, or whatever */
// first we bind the collectionModel to this TC, so there will be a child widget created for each item in the array
// the binding will handle observing the collection model for changes to add and remove children
bind(collectionModel, new TabContainer())
.forEach(function(item){ // called for each child
var cp = new ContentPane({}); // create the child widget to use (could be optional)
var form = cp.domNode; // get the domNode to attach the children