This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// monkey patch for and adaption of node module loader code | |
// joiner from node/lib/modules.js | |
var joiner = process.platform === 'win32' ? '\\' : '/'; | |
// allow package default to be overridden | |
exports.defaultPackageDir = 'node_modules'; | |
exports.patch = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// when defined in js json-schema doesn't need no quoted keys | |
// and you can can use the native type classes if you don't have any options | |
var Person = { | |
// properties and validations | |
properties: { | |
{ id: {type: "number", unique:true, nullable:false }, | |
{ email:String, unique:true, nullable:false, minimumValue:1, maximumValue:55, pattern: '[a-b]' }, | |
{ salt: String }, | |
{ pswd: String }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(10/11/2010 10:49:36 AM) Vladimir1: Hi! Saw you posted about you don;t like how exception handling is done currently in promised-io/promise. What were those helpers you mentioned you developed? | |
(11:16:23 AM) deanlandolt: i didn't develop helpers for that...i thought kris mentioned something to you about developing something...something like a different style of when...i was saying i'm working on some helpers for framing streams | |
(11:26:08 AM) Vladimir1: ah, i see. what he proposed was whenCall() which is fed with not direct promise, but a function returning that promise. I found that is not so useful since another indirection level ugly-fies the code... | |
(11:26:49 AM) deanlandolt: it's fed with a function that MAY return a promise, but may also return immediately...or *throw* | |
(11:27:48 AM) deanlandolt: that's the key...we have to trap that through...the only way to do that is to trap is with a new lexical scope (the function passed to whenCall)...the only /other/ way is to actual try/catch IN your code, and sha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Media handler for generating HTML from Wiki markup-based doc | |
*/ | |
var Media = require("pintura/media").Media, | |
when = require("promised-io/promise").when; | |
Media({ | |
mediaType:"text/html", | |
getQuality: function(object) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clip from media handler/serializer | |
//load the template, should return a promise from the compile() method | |
if (response.status > 400) { | |
//print("Error Response: " + response.status); | |
template = templateEngine.compile("/error/"+response.status); | |
}else{ | |
template = templateEngine.compile(templateId, (mediaParams && mediaParams.template)); | |
} | |
//when we get the template function back, execute it which returns the rendered html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//load the template, should return a promise from the compile() method | |
if (response.status > 400) { | |
//print("Error Response: " + response.status); | |
template = templateEngine.compile("/error/"+response.status); | |
}else{ | |
template = templateEngine.compile(templateId, (mediaParams && mediaParams.template)); | |
} | |
//when we get the template function back, execute it which returns the rendered html | |
// i've tried a bunch of different ways to do this, but i'm not sure what should be happening in the when here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1: how could you rewrite the following to make it shorter? | |
foo ? bar.doSomething(el) : bar.doSomethingElse(el); | |
// 2: what is the faulty logic in the following code? | |
var foo = 'hello'; | |
(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileId = JSON.parse(mock.POST("/File/", { | |
headers: { | |
"content-type": "text/plain", | |
"content-disposition": "attachment", | |
accept: "application/json" | |
}, | |
body: {forEach: function(write) { | |
write("foo\r\nbar\r\nbaz"); | |
}} | |
}).body).id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("util/narwhal-compat"); | |
var assert = require("patr/assert"), | |
when = require("promised-io/promise").when, | |
whenPromise = require("promised-io/promise").whenPromise; | |
var Model = require("perstore/model").Model, | |
Server = require("perstore/store/couchdb").Server, | |
Database = require("perstore/store/couchdb").Database, | |
server = Server(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo Starting Persevere | |
setlocal | |
set SHELL=cmd.exe | |
set PACKAGE_HOME=%~dp0.. | |
call %PACKAGE_HOME%\packages\narwhal\bin\activate.cmd |