Skip to content

Instantly share code, notes, and snippets.

View kriszyp's full-sized avatar
💭
Working on @HarperDB

Kris Zyp kriszyp

💭
Working on @HarperDB
View GitHub Profile
@kriszyp
kriszyp / output.txt
Created October 6, 2011 17:17 — forked from iaincarsberg/output.txt
RequireJS - Compose.js - Chaining Multiple Constructors
Animal - this {}
Animal - debug: [ muppet , bert ]
Hello, my name is bert and I am a muppet
returned: { species: 'muppet', name: 'bert' }
****************************************
Muppet - this {}
Muppet - debug: [ ernie ]
Animal - this {}
Animal - debug: [ muppet , ernie ]
Hello, my name is ernie and I am a muppet
define(["./base/lang"], function(lang){
// module:
// dojo/gesture/tap
// summary:
// This module provides tap gesture event handlers
// - dojo.gesture.tap -> to fire 'tap' event
// - dojo.gesture.tap.hold -> to fire 'tap.hold' event
// - dojo.gesture.tap.doubletap -> to fire 'tap.doubletap' event
// example:
// A. Used with dojo.connect()
@kriszyp
kriszyp / my-widget.js
Created June 24, 2011 05:26
This is how I want to write structured documentation and unit tests
/* This is the module, the implementation, distinct from the specification/interface. */
define([...deps...], function(){
return function(options){
...
};
});
(function(){
var bar = (function(){ // each module factory executed, export assigned to var
return {a:3};
})();
var text = {};
text._resource = "contents of file";
var pckg = {};// nested paths -> nested namespace/sub-objects
pckg.foo = (function(bar){
@kriszyp
kriszyp / response.http
Created March 3, 2011 18:05
Server response of the future?
HTTP/1.1 200 OK
Content-Type: application/foo+json; # Web applications typically do and should use JSON as the semantic data source
# If your mobile device has an app for "application/foo+json", auto-launch app to handle resource
Link: <http://foo.com/ui.html>; rel="renderer" # HTML page to use to renderer it
Link: <http://foo.com/ui.ipa>; rel="ios.renderer" # Recommended device-specific app for this resource
Link: <http://foo.com/schema>; rel="describedby" # schema describing the JSON structure so that search engines can crawl it
...
@kriszyp
kriszyp / profiles.json
Created February 25, 2011 17:04
copy and paste this into your debugger console or http://jsonviewer.stack.hu/ or something to view it.
[{"match":"/BlackBerry.+AppleWebKit\\/([\\d\\.]+)/","name":"BlackBerry","version":400,"has":{"activex":false,"activex-enabled":false,"array-es5":true,"array-every":true,"array-filter":true,"array-foreach":true,"array-indexof":true,"array-isarray":true,"array-lastindexof":true,"array-map":true,"array-reduce":true,"array-reduceright":true,"array-slice-nodelist":true,"array-some":true,"audio":true,"audio-m4a":true,"audio-mp3":true,"audio-ogg":true,"audio-wav":true,"bug-arguments-instanceof-array":false,"bug-array-concat-arguments":false,"bug-bgimagecache":true,"bug-computed-style-hidden-zero-height":false,"bug-computed-values-for-static":false,"bug-contains":false,"bug-dontenum-enumerable":false,"bug-es5-regexp":true,"bug-es5-trim":true,"bug-function-expression":false,"bug-getelementbyid-ids-names":false,"bug-getelementbyid-ignores-case":false,"bug-getelementsbyname":false,"bug-getelementsbytagname-returns-comment-nodes":false,"bug-offset-values-positioned-inside-static":false,"bug-overflow-style":false,"bug-pre
@kriszyp
kriszyp / data.json
Created February 4, 2011 16:34
CSS template
{
"cars": [
{"make": "Honda", "model": "Accord"},
{"make": "Ford", "model": "Taurus"},
]
}
db = new Storage # external implementation
Store = (entity) ->
find: db.find.bind db, entity
get: db.get.bind db, entity
save: db.save.bind db, entity
add: db.insert.bind db, entity
remove: db.remove.bind db, entity
update: db.update.bind db, entity
patch: db.patch.bind db, entity
@kriszyp
kriszyp / define-node.js
Created October 27, 2010 21:08
Add AMD/define() support to NodeJS
var currentModule, defaultCompile = module.constructor.prototype._compile;
module.constructor.prototype._compile = function(content, filename){
currentModule = this;
try{
return defaultCompile.call(this, content, filename);
}
finally {
currentModule = null;
}
};
require.def("uses-foo",["has!node:./node/foo,svg:./svg/foo,./default/foo"],function(foo){
foo.bar();
});