mschwartz@mschwartz:~/src/bench$ cat node.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
mschwartz@mschwartz:~/src/bench$ node node.js
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
Schema.add({ | |
name: 'Content', | |
fields: [ | |
{ name: 'contentId', type: 'int', autoIncrement: true, defaultValue: 0 }, | |
{ name: 'seoFriendly', type: 'varchar', size: 255 }, | |
{ name: 'title', type: 'varchar', size: 255, defaultValue: 'Untitled' }, | |
{ name: 'description', type: 'varchar', size: 255, defaultValue: 'No description' }, | |
{ name: 'body', type: 'longtext' } | |
], | |
primaryKey: 'contentId', |
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
<html> | |
<head> | |
</head> | |
<body> | |
<% | |
if (req.data.button) { | |
console.dir(req.data); | |
var example = {}; | |
req.data.each(function(value, key) { | |
if (key.substr(0, 6) === 'field_') { |
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 fs = require('builtin/fs'), | |
console = require('console'); | |
function DirectoryProxy(path) { | |
return Proxy.create({ | |
get: function(receiver, name) { | |
return fs.readFile(path + '/' + name); | |
}, | |
set: function(receiver, name, value) { |
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 console = require('console'); | |
function handlerMaker(obj) { | |
return { | |
// Fundamental traps | |
getOwnPropertyDescriptor: function(name) { | |
console.log('getOwnPropertyDescriptor ' + name); | |
var desc = Object.getOwnPropertyDescriptor(obj, name); | |
// a trapping proxy's properties must always be configurable | |
if (desc !== undefined) { desc.configurable = true; } |
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 smarty_cache = {} | |
function getCachedSmarty(key) { | |
// (key is whatever you use to lookup in the DB) | |
var template = smarty_cache[key]; | |
if (!template) { | |
template = SQL.getDataRow(query_to_get_template); | |
var compiled = smart.compile(template); | |
template = { | |
template: template, | |
compiled: compiled |
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
title = 'hello' | |
color = req.data.color ? 'red' | |
""" | |
<html> | |
<head> | |
<title>#{title}</title> | |
</head> | |
<body> | |
<h1 style="color: #{color}">Have another cuppa joe!</h1> | |
</body> |
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
// ctest.coffee | |
res.write '<pre>' | |
res.write 'hello, world\n' | |
res.write Util.print_r req | |
outputs in the browser: | |
hello, world | |
(object) : | |
[init] : (function) |
NewerOlder