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
/** | |
* Calls the functions passed in `funcs` taking callbacks in parallel, calling | |
* the callback passed to `doParallel` after each of the other functions have | |
* finished. The `callback` parameter is only called once. | |
*/ | |
function doParallel(funcs, callback) { | |
var maxCount = funcs.length | |
, count = 0 | |
function f() { |
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
// The "common" wannabe-classical way, with closures for hiding. | |
function Person(secret) { | |
// secret is ignored | |
} | |
Person.prototype.eat = function() { ... } | |
Person.prototype.walk = function() { ... } | |
function ComputerSavvyPerson(secret) { | |
Person.call(this, secret) |
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
// Assume `Object.prototype.extend` exists. | |
var Foo = { | |
/* stuff that would go in Foo.prototype */ | |
} | |
var Bar = Foo.extend({ | |
/* stuff that would go in Bar.prototype */ | |
}) | |
var bar = Bar.extend({ foo:10, bar:[1,2,3] }) |
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
my best solution so far: changing the updateTransformation function to take the transformation as an argument and then change the variable... something like updateTransformation({'rotate':-0.05}); | |
function getTransformerCallback(delta) { | |
return function() { | |
delta.rotate && (rotate += delta.rotate) | |
delta.translateX && (translateX += delta.translateX) | |
delta.translateY && (translateY += delta.translateY) | |
updateTransformation() | |
} |
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 WebTerm(pre, width, height) { | |
this.element = pre | |
this.width = width | |
this.height = height | |
this.charbuf = [] | |
this.formatbuf = [] | |
this.caret = { x:0, y:0 } | |
this.defFormatting = |
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
; vim:ft=asm | |
; X : width | |
; Y : height | |
; C : current cell mask (01b or 10b) | |
; 0x1000 ... : cell states | |
; Set width/height | |
set X, 0x10 ; width | |
set Y, 0x08 ; height |
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 assert = require('assert') | |
, disassembler = require('./disassembler') | |
// Prettyprints the given array of instructions + binary blobs, optionally with | |
// colour. | |
exports.prettyPrint = function(instructions, useColour) { | |
var colours = getColourMap(useColour) | |
// First, print a header | |
printComment("; Labels Instruction Cycles Raw") |
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
:begin | |
set A, foo | |
set B, foo | |
add B, 2 | |
set C, 0x8000 | |
jsr upack | |
jsr makevisible | |
:end sub PC, 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
--- dcpu16.txt 2012-04-26 13:57:37.477152465 +0200 | |
+++ dcpu16_1_5.txt 2012-04-26 13:57:12.209965926 +0200 | |
@@ -1,6 +1,6 @@ | |
DCPU-16 Specification | |
Copyright 1985 Mojang | |
-Version 1.4 | |
+Version 1.5 | |
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 x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" + | |
"=39){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return o" + | |
".substr(0,ol);}f(\")95,\\\"YQ[v|c=tf,9y;:7}1=5;;9%?9'!700\\\\)#**|c430\\\\S" + | |
"W\\\\\\\\Q~230\\\\XQA620\\\\Fa320\\\\FRQ[@Bot\\\\v420\\\\MKRLP300\\\\000\\\\"+ | |
"}Npwi}vhv~y_5f|t1d|ksse,@010\\\\030\\\\730\\\\320\\\\230\\\\200\\\\500\\\\J" + | |
"100\\\\220\\\\\\\\\\\\430\\\\730\\\\410\\\\@610\\\\000\\\\610\\\\630\\\\430" + | |
"\\\\430\\\\610\\\\220\\\\620\\\\n\\\\n\\\\\\\"\\\\610\\\\600\\\\17g3/609:tt" + | |
"\\\\i57#8o/qnc$%-3/73m6/%RK^S_\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoC" + | |
"rahCmorf.gnirtS=+o;721=%y;2=*y))y+95(>i(fi{)++i;l<i;0=i(rof;htgnel.x=l,\\\"" + | |
"\\\"=o,i rav{)y,x(f noitcnuf\")" ; |