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
/**
* This is an example Wiki web application written on Pintura
*/
var pageFacets = require("./facet/page"),
pageChangeFacets = require("./facet/page-change"),
admins = require("commonjs-utils/settings").security.admins,
fullModel = require("./model/index"),
Package = require("perstore/model").Package,
copy = require("commonjs-utils/copy").copy,
Register = require("pintura/security").Register;
var request = require("rhino-http-client").request;
var r = request({url:"http://www.google.com"});
r.then(function(r){
print("status: " + r.status);
r.body.forEach(function(){
print("part")
}).then(function(){
print("done");
})
});
node>when = require("promised-io/promise").when;
[Function]
node>defer = require("promised-io/promise").defer;
[Function]
node>d = defer();
node>when(when(d.promise,function(){},function(){return 5}),function(){print("su
ccess");});
{ then: [Function] }
node>d.reject("error");
dojo.provide("dojo.socket");
dojo.socket = function(/*dojo.__XhrArgs*/ argsOrUrl){
// summary:
// Provides a simple socket connection using WebSocket or long-polling based
// communication in legacy browsers for comet-style communication. This is based
// on the WebSocket API and returns an object that implements the WebSocket interface:
// http://dev.w3.org/html5/websockets/#websocket
// argsOrUrl:
// This uses the same arguments as the other I/O functions in Dojo, or a
require.def("uses-foo",["has!node:./node/foo,svg:./svg/foo,./default/foo"],function(foo){
foo.bar();
});
@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;
}
};
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 / data.json
Created February 4, 2011 16:34
CSS template
{
"cars": [
{"make": "Honda", "model": "Accord"},
{"make": "Ford", "model": "Taurus"},
]
}
@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 / 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
...