Skip to content

Instantly share code, notes, and snippets.

View creationix's full-sized avatar
💚
<3

Tim Caswell creationix

💚
<3
View GitHub Profile
From 1734c81a20a2b9a8dcc58f5378f98a29aedb5eff Mon Sep 17 00:00:00 2001
From: Tim Caswell <[email protected]>
Date: Tue, 9 Feb 2010 10:50:05 -0600
Subject: [PATCH] Rewrite sys.inspect to be more reliable and handle crazy edge cases.
---
lib/sys.js | 168 +++++++++++++++++++++++++--------------------
test/mjsunit/test-sys.js | 41 ++++++++++-
2 files changed, 131 insertions(+), 78 deletions(-)
From e71d947e313c63b54a0eba7a9b2c3d85b924aea9 Mon Sep 17 00:00:00 2001
From: Tim Caswell <[email protected]>
Date: Tue, 9 Feb 2010 11:15:02 -0600
Subject: [PATCH] Document the changes to sys.inspect's API. It now takes an optional showHidden argument that shows hidden/non-enumerable properties of objects.
Also cleanup the lib/sys.js file a bit.
---
doc/api.txt | 4 ++--
lib/sys.js | 7 +++----
2 files changed, 5 insertions(+), 6 deletions(-)
// Hook for initial modules.
if (typeof load === 'undefined') { process.mixin(require('creationix'));}
load({
sys: 'sys',
posix: 'posix'
})(function (imports, export) {
imports.sys.puts("Hello");
export(/123/g);
});
@creationix
creationix / async_api.js
Created February 10, 2010 18:13
Scan a directory for files and read them all into an object indexed by filename. Async and Sync versions of code.
var File = require('file'),
Sys = require('sys'),
Posix = require('posix');
// Sync api wrapper around some Posix commands
// Sells it soul to `wait`.
var posix_sync = {
readdir: function (path) {
return Posix.readdir(path).wait();
},

E-Learning Site Architecture

The e-learning site will be build using the latest and greatest open-source technology. The key to the whole architecture is that every part from the browser interface to the web server to the database all use JavaScript. This reduces context switching for developers and allows for tiers to share code and logic.

Browser Interface

Unlike traditional web interfaces where the web-browser is simply a dumb client that renders HTML and submits forms to a server, this project will have an intelligent agent running in the browser. It will be delivered to the browser on page load in the form of a JavaScript file. The index.html file will be a static file with an empty body tag and links to the needed script and css resources.

Once the front-end app downloads (in seconds), the app will start up and begin requesting information from the backend using a simple data interchange protocol.

// Simple Callback implemented
function read(file, callback, errback) {
// Do something and then
callback(text);
}
// Simple Callback used
read("myfile.txt", function (data) {
// We got the content
}, function (error) {
// Error
@creationix
creationix / Many-changes-to-make-file-management-easier.patch
Created February 17, 2010 07:07
Many changes to make file management easier. - Rename fs.cat to fs.readFile - Move file.write to fs.writeFile - Allow strings for the flag argument to fs.open ("r", "r+", "w", "w+", "a", "a+") Also removed the now useless 'file' module and updated
From 93176700235767255f9a8c26d523d078bfafdae2 Mon Sep 17 00:00:00 2001
From: Tim Caswell <[email protected]>
Date: Wed, 17 Feb 2010 01:06:26 -0600
Subject: [PATCH] Many changes to make file management easier.
- Rename fs.cat to fs.readFile
- Move file.write to fs.writeFile
- Allow strings for the flag argument to fs.open
("r", "r+", "w", "w+", "a", "a+")
// Plain callback style
function read(filename, callback, errback) {
// Do async work and then...
callback(data);
}
// Continuation style
function read(filename) { return function (callback, errback) {
// Do async work and then...
callback(data);
// Super simplified sample library
fs.readFile = function (filename, another_arg, more args, callback) {
callback(error, content);
}
// Curried
fs.readFile = function (filename, another_arg, more args) { return function (callback) {
callback(error, content);
}}