Skip to content

Instantly share code, notes, and snippets.

View bryanwb's full-sized avatar

Bryan Berry bryanwb

View GitHub Profile
// hope this answers your question
//first follow the instructions for setting up narwhal
// http://karmaeducation.org/2010/01/15/getting-started-with-narwhal-a-standard-library-for-javascript/
//update your catalog of available commonJS packages
// tusk is a lot like ruby's 'gem' command
$ tusk update
//then install yuicompressor, shrinksafe others
<body>
<div id="kHeader">
</div>
<!-- Put the help text here -->
<div id="kHelpText" title="Help Title"> Help text here</div>
<div id="feedback"></div>
<div id="gameArea">
<div id="questionBox">What is this?</div>
function divide(a, b) { return function (callback, errback) {
// Use nextTick to prove that we're working asynchronously
process.nextTick(function () {
if (b === 0) {
errback(new Error("Cannot divide by 0"));
} else {
callback(a / b);
}
});
}}
/* reverse: reverse string s in place */
void reverse(char *s)
{
int j = 0;
int temp = 0;
char *i = s;
s += strlen(s) - 1;
while (s != i){
var sys = require('sys');
stdin = process.openStdin();
process.addListener('SIGINT', function(){
sys.puts('Received SIGINT');
});
var timeout = function(){
setTimeout(timeout, 50);
/*
* This demo program tries to rename 3 groups of files without overwriting any of the files in any other groups
* The files are numbered quasi-consecutively tmp1, tmp2, tmp3, tmp11, tmp12, tmp13, etc.
* I rename the files by adding 10 to the numeric part of the name
* tmp1 cannot be renamed to tmp11 until the original tmp11 has been renamed to tmp21
*
*/
var Step = require('ste
/*
* This demo program tries to rename 3 groups of files without overwriting any of the files in any other groups
* The files are numbered quasi-consecutively tmp1, tmp2, tmp3, tmp11, tmp12, tmp13, etc.
* I rename the files by adding 10 to the numeric part of the name
* tmp1 cannot be renamed to tmp11 until the original tmp11 has been renamed to tmp21
*
*/
var Step = require('step');
var fs = require('fs');
var sys = require('sys');
/*
* This demo program tries to rename 3 groups of files without overwriting any of the files in any other groups
* The files are numbered quasi-consecutively tmp1, tmp2, tmp3, tmp11, tmp12, tmp13, etc.
* I rename the files by adding 10 to the numeric part of the name
* tmp1 cannot be renamed to tmp11 until the original tmp11 has been renamed to tmp21
*
*/
var Step = require('step');
var fs = require('fs');
var sys = require('sys');
var sys = require('sys'),
spawn = require('child_process').spawn,
ls = spawn('ls', ['-lh', '/usr']);
ls.stdout.addListener('data', function (data) {
sys.print('stdout: ' + data);
});
ls.stderr.addListener('data', function (data) {
sys.print('stderr: ' + data);
/*
* This demo program tries to rename 3 groups of files without overwriting any of the files in any other groups
* The files are numbered quasi-consecutively tmp1, tmp2, tmp3, tmp11, tmp12, tmp13, etc.
* I rename the files by adding 10 to the numeric part of the name
* tmp1 cannot be renamed to tmp11 until the original tmp11 has been renamed to tmp21
*
*/
var Step = require('step');
var fs = require('fs');