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
// Basic getExecutionCounts test. | |
var g = newGlobal('new-compartment'); | |
var dbg = Debugger(g); | |
var s; | |
dbg.onNewScript = function (script) { s = script; }; | |
var f = g.Function("i", | |
"line0 = Error().lineNumber;\n" + | |
"var s = 0;\n" + // line0 + 1 | |
"for (var a = 0; a < i; a++)\n" + // line0 + 2 |
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
123 | |
↙ ↖ | |
231 → 312 | |
132 | |
↙ ↖ | |
321 → 213 |
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
/** | |
* @brief Finds the first position in which @a val could be inserted | |
* without changing the ordering. | |
* @param first An iterator. | |
* @param last Another iterator. | |
* @param val The search term. | |
* @return An iterator pointing to the first element "not less than" @a val, | |
* or end() if every element is less than @a val. | |
* @ingroup binarysearch | |
*/ |
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
function f() { | |
var a = [1, 0.5, 1]; | |
var b; | |
for (var j = 0; j < a.length; j++) { | |
var z = -a[j]; | |
if (b === undefined || z < b) | |
b = z; | |
} | |
} |
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
for (let V = INIT; TEST; UPD) STMT | |
===> | |
{ | |
let %tmp = INIT, %first = true; | |
while (true) { | |
// A fresh binding for V gets either the initializer-expression value(s) | |
// or the value(s) from the end of the previous loop iteration. | |
let V = %tmp; |
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
// *** design #1 | |
if (!forOf(cx, obj, [cx] (const Value &v) { | |
... | |
})) { | |
return false; | |
} | |
// *** design #2 |
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
/* | |
* This is for writing C++ code that does the equivalent of JS try/finally. | |
* Normal infallible C++ cleanup code should just go in a C++ destructor. | |
* This is for cleanup that should be *skipped* in the unusual case that | |
* the try block exits with an uncatchable error (OOM or timeout). | |
* | |
* Use it like this: | |
* | |
* bool ok; | |
* ... YOUR TRY-BLOCK CODE HERE ... |
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
// *** Design #1: helper class | |
if (AutoFinallyBlock afb(cx, ok)) { | |
bool closedOK = CLOSE THE ITERATOR; | |
ok = afb.leave(closedOK); | |
} | |
// *** Design #2: no helper class | |
if (ok || cx->isExceptionPending()) { |
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
# This program is valid Python 2.7 and it's also valid Python 3.2. | |
# To run it, type: python hashfiles.py | |
import os, hashlib, collections | |
# What is a defaultdict? Some sort of data structure, apparently. Hmm. | |
file_groups = collections.defaultdict(list) | |
# This loop is going to execute once for each directory in the tree. | |
for dirpath, dirnames, filenames in os.walk('.'): | |
# The inner loop will run once for each file in the tree. |
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
// Run this | |
// in Scratchpad | |
// in the *target* Firefox | |
// using Environment -> Browser | |
// before opening the script debugger in the other Firefox. | |
Components.utils.import("resource://gre/modules/devtools/dbg-server.jsm"); | |
function allowDebuggersToConnect() { | |
const DEBUGGER_PORT = 60000; |
OlderNewer