This file contains hidden or 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 templateData = this.responseText; | |
var data = { | |
person: { | |
name : { | |
first : 'Rob', | |
last : 'Ellis' | |
}, | |
age: 30, | |
location : { |
This file contains hidden or 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
// Fails | |
main = document.getElementById("main"); | |
var div = document.createElement('DIV'); | |
div.innerHTML = "<body>This is BODY2</body>"; | |
main.appendChild(div); | |
// Works | |
main = document.getElementById("main"); | |
var div = document.createElement('DIV'); | |
var body = document.createElement('BODY'); |
This file contains hidden or 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
(ironman) ~/projects/personal $ sudo npm build apricot | |
npm it worked if it ends with ok | |
npm configfile /Users/ironman/.npmrc | |
npm cli [ 'build', 'apricot' ] | |
npm version 0.1.20 | |
npm required jsdom->= 0.0.1 | |
npm found [email protected] | |
npm createMain ./lib/apricot | |
npm linkLib apricot-0.0.1 | |
npm ! WARNING ! |
This file contains hidden or 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
UC 1 | |
<p id="test">A simple <b>test</b> string.</p> | |
A simple <b>test</b> string. | |
UC 2 | |
<p>This is a test file</p> | |
This is a test file | |
Looping 1 | |
<li>Item 1</li> |
This file contains hidden or 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
// Using JavaScript (node.js) to Read Variable Length Quantity | |
// See - http://en.wikipedia.org/wiki/Variable-length_quantity for more information | |
Utils = {} | |
Utils.arrayToHex = function(ar) { | |
for (var i=0;i<ar.length;i++) { | |
ar[i] = (ar[i].toString(16) == 0) ? "00" : ar[i].toString(16); | |
} | |
return "0x" + ar.join(''); | |
} |
This file contains hidden or 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
system.use("info.webtoolkit.Base64"); | |
var username = "admin"; | |
var password = "password"; | |
var auth = "Basic " + Base64.encode(username + ":"+ password); | |
checkAuth = function() { | |
if (!this.request.headers.hasOwnProperty('Authorization') || (this.request.headers.hasOwnProperty('Authorization') && (auth != this.request.headers['Authorization']))) { | |
this.response.headers['WWW-Authenticate'] = 'Basic realm="SmartAPI"'; | |
this.response.code = 401; | |
this.response.body = "Not Authorized\n"; |
This file contains hidden or 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
Module.prototype.load = function (filename) { | |
var self = this; | |
this.filename = filename; | |
function require (url) { | |
return loadModule(url, self); | |
} | |
var x = system.filesystem.get(this.filename); |
This file contains hidden or 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
// module.js | |
// This loader is derived from nodes loader. :) | |
// Fixme: path is always absolute ie requre('/math'); | |
// Fixme: bug in loading order, and dependency support is weak | |
// Fixme: using a modified version of filesystem.get to look in the code directory. | |
// - SNIP From: /Applications/Smart.app/Contents/Resources/Image/lib/perl5/site_perl/5.10.0/RSP/Extension/Filesystem.pm | |
/** | |
- in | |
return { | |
'filesystem' => { |
This file contains hidden or 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 sys = require('sys'); | |
var posix = require('posix'); | |
var ini = {'global':{}}; | |
var parseINI = function(d) { | |
var section = 'global'; | |
var lines = d.split('\n'); |
This file contains hidden or 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
Repeat = {}; | |
Repeat.__noSuchMethod__ = function __noSuchMethod__ (id, args) { | |
var numTimes = /x([0-9]+)/.exec(id); | |
if (numTimes != null) { | |
for (var i = 0;i < numTimes[1]; i++) { | |
if (typeof args[0] == 'function') { | |
args[0](); | |
} else { | |
system.console.log(args[0]); | |
} |