A dpd resource for rendering templates on the server as well as exposing them for use in the browser.
Templates live in the root of their resource instance folder (eg. /my-project/resources/templates
) and in a partials
sub folder.
var connect = require('connect') | |
, http = require('http'); | |
var server = http.createServer(function () { | |
console.log('foo'); // this is logged | |
}); | |
var app = connect(server); | |
app.use(function (req, res, next) { |
var http = require('http') | |
, request = require('request') | |
, fs = require('fs'); | |
var server = http.createServer(function (req, res) { | |
req.pipe(fs.createWriteStream('my-file.jpg')); | |
}) | |
.listen(3000) | |
.on('listening', function () { | |
fs.createReadStream('my-file.jpg').pipe(request.post('http://localhost:3000')); |
<!doctype html> | |
<html> | |
<body data-controller="list"> | |
<ul> | |
<li data-repeat="item in items"> | |
{{ item.text }} | |
</li> | |
</ul> | |
var data = []; | |
describe('fast array', function(){ | |
it('setup', function() { | |
var max = 9 * (1000 * 1000); | |
while(data.length < max) { | |
if(data.length === max / 2) data.push(['random', 'random value']); | |
else data.push(['key', 'value']); | |
} | |
// get all widgets | |
dpd.widgets.get(function (err, widgets) { | |
if(err) return alert(err); | |
console.log(widgets); // [Object, Object, Object, ...] | |
}) | |
// get one widget | |
dpd.widgets.first(function (err, widget) { | |
if(err) return alert(err); | |
console.log(widget); |
#!/usr/bin/env node | |
var operation = process.argv[process.argv.length - 1]; | |
var allowed = '--decipher --cipher' | |
if(allowed.indexOf(operation) === -1) { | |
operation = '--cipher'; | |
} | |
// let us type a string |
// start node.js processes on a distributed network | |
// makes sure the process is always available, even if | |
// it has to restart the process on another server | |
// essentially a distributed version of forever | |
// no client/server relationship, all ring nodes are peers | |
var ring = require('ring').join('network guid') | |
, opts = { | |
distribution: { |
I'm getting tired of writing documents to then parse and rebuild in JavaScript. HTML is not a markup language for complex interactive applications. rml
is. Chekk-it.
// html
<img src="http://google.com/logo.png" />
Same thing in simple rml
.
// rml
img('http://google.com/logo.png');
// parallel | |
// 3 requests happen in parallel | |
var urls = ['google.com', 'yahoo.com'] | |
, emitter = new EventEmitter() | |
, done = [] | |
; | |
function increment(res) { | |
done.push(res); | |
if(done.length === urls.length) { |