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("fs"); | |
var util = require("util"); | |
function walkSync(filename, cb) { | |
try { | |
var stat = fs.lstatSync(filename); | |
if(stat.isDirectory()) { | |
try { | |
if(cb(null, filename, stat)) { | |
var files = fs.readdirSync(filename); |
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
setTimeout(function () { | |
t= Date.now()-t; | |
STOP= 1; | |
console.log(["ctr: ",ctr, ", t:", t, "ms -> ", (ctr/t).toFixed(2), "KHz"].join('')); | |
}, 2e3); | |
var ctr= 0; | |
var STOP= 0; | |
var t= Date.now()+ 2; | |
while (t > Date.now()) ; //get in sync with clock |
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
// 2010-12-15 [email protected] | |
// Uses 2 threads | |
function walk (file, cb) { | |
var fs = require('fs'); | |
var e= {path:file, q:[]}; | |
var q= [e]; | |
begin(); | |
function begin () { |
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
// 2010-12-16 [email protected] | |
// loopFreq.js displays event loop tick period in ms and KHz | |
// with debugger; slows down to a crawl ! | |
var k_ms= 1e3; | |
setTimeout(function display () { | |
t= Date.now()-t; | |
console.log(["ctr: ",ctr, ", t:", t, "ms -> ", (ctr/t).toFixed(2), "KHz"].join('')); | |
setTimeout(display, k_ms); |
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
// 2010-12-31 [email protected] | |
// JavaScript ms clock's wow and flutter | |
var kSample= 1e3; | |
var res= new Array(kSample); | |
var ctr; | |
var st= Date.now()+ 2; //start time | |
while (Date.now() < st) ; //get in sync with ms clock |
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
function server (request, response) { | |
var uri = url.parse(request.url).pathname; | |
if(uri=='/pong') { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
response.end('PONG'); | |
} else if ((match = uri.match(/^\/echo\/(.*)$/)) != null) { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
response.end(match[1]); |
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
(function () { | |
function photoOK (imageURI) { | |
console.log("**** photoOK"); | |
console.log(imageURI); | |
} | |
function photoErr (mesage) { | |
console.log("**** photoErr"); |
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 k= require('constants'); | |
var fs = require('fs') | |
var b = new Buffer('AAAAAAAAAA'); | |
fs.open('./f', k.O_WRONLY, 0666 , cb); | |
function cb (err, fd) { | |
fs.write(fd,b,0,10,10); | |
} |
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
function LinkedList() { | |
this._length = 0; | |
this._head = null; | |
this._tail = null; | |
} | |
LinkedList.prototype = { | |
add: function (data){ | |
var node = { data: data, next: null}; | |
if (this._length == 0) { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- Change this if you want to allow scaling --> | |
<meta name="viewport" content="width=default-width; user-scalable=no"> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>gira</title> | |
OlderNewer