Skip to content

Instantly share code, notes, and snippets.

@phiggins42
phiggins42 / handlebars.js
Created November 15, 2011 13:45 — forked from svnlto/handlebars.js
dojo handlebars.js
dojo.provide("dbp._Handlebars");
dojo.require("dijit._TemplatedMixin");
(function(d) {
// lib/handlebars/parser.js
/* Jison generated parser */
var handlebars = (function(){
var parser = {trace: function trace() { },
yy: {},
symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"param":27,"STRING":28,"INTEGER":29,"BOOLEAN":30,"hashSegments":31,"hashSegment":32,"ID":33,"EQUALS":34,"pathSegments":35,"SEP":36,"$accept":0,"$end":1},
dojo.provide(" myshit.external._Mustache");
dojo.require("dijit._Templated");
(function(d){
/*
mustache.js — Logic-less templates in JavaScript
See http://mustache.github.com/ for more info.
*/
@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.
this.Jerk = (function(){
// summary: Be a jerk.
//
// description:
// Mess with people. Extend prototypes, use faulty (read: wrong)
// implementations. Better yet, do it randomly. Bonus points if
// someone becomes criminally insane from debugging.
//
var threshold = 0.5; // how often do we want to fuck with folks.
@phiggins42
phiggins42 / jerk.js
Last active September 26, 2015 23:48
chaos monkey. If your tests pass with this in page your tests are wrong. or you are very very lucky. buy a lotto ticket.
function jerkify(obj, methods, thres){
methods.forEach(function(meth){
var orig = obj.prototype[meth];
orig && obj.prototype[meth] = function(){
return Math.random() > thres ? orig.apply(this, arguments) : orig.call(this);
}
});
}
jerkify(Array, ["push", "pop", "splice", "slice"], 0.1);
exports.ellipsis = function ellipsis(str, chunk, elip){
// summary: Ellipsis some text. Break `str` into `chunk` sized
// bites (bytes?), breaking only on full words within the `chunk` size
//
// str: String
// The string to break apart.
// chunk: Integer:
// The size of the chunk
// elip: String?
/*
monitor.js - monitors a javascript file and re-executes when file is
saved. eg:
$ node monitor.js /home/me/sample.js
Now edit /home/me/sample.js and watch the console output. Like a "live
firebug", though gives you the comfort of your own editor for quick
testing and prototyping.
define("my/module", ["dojo", "dijit", "dojo/text!my/template.html", "dijit/_Widget"], function(dojo, dijit, template){
return dojo.declare("my.module", [dijit._Widget], {
randomTemplate: template
})
});
// untested poc/theory code
define(["dojo/parser"], function(parser){
var asyncParser = function(rootNode, oldSupport){
// summary: An asyncronous
var dfd = new dojo.Deferred(),
deps = dojo.query("[dojoType], [data-dojo-type]", rootNode).filter(function(n){
return (n.getAttribute("data-dojo-type") || n.getAttribute("dojoType")).replace(/\./g, "/");
})
dojo.onEnterPress = function(ref, context, method){
// summary: Shorthand utility function for hooking up enter-key handling to a text input.
var ENTER = dojo.keys.ENTER, callback = method ? dojo.hitch(context, method) : context, ev = "keypress";
if(typeof ref == "string"){
ref = dojo.byId(ref);
}else if(ref && ref.declaredClass){
ev = "onKeyPress";
}