Skip to content

Instantly share code, notes, and snippets.

var
test = test || null,
ok = ok || null,
deepEqual = deepEqual || null,
assert = null;
// If we are not running in Qunit in the browser, create a shim from the Qunit API
// to the CommonJS API.
if (typeof exports !== "undefined") {
assert = require("assert");
var FILE = require("file");
require.paths.unshift(FILE.join(FILE.dirname(module.path),
"jsmacros/vendor/jison/lib"));
var Parser = require("jison").Parser;
require.paths.shift();
var grammar = {
lex: {
rules: [
//@use bind.jsm
function returnsMultipleVals () {
return ["foo", "bar"];
}
var foo, bar;
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active April 26, 2024 20:09
Complete Recent Discord Quest

Complete Recent Discord Quest

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory
  2. Join a vc
  3. Stream any window (can be notepad or something)
  4. Press Ctrl+Shift+I to open DevTools
  5. Go to the Console tab
  6. Paste the following code and hit enter:
let wpRequire;
@fitzgen
fitzgen / operations.js
Created February 18, 2011 01:25
Uses a slightly modified version of the Levenshtien Distance algorithm (also known as "edit distance") to calculate the set of the fewest operations which will change string s in to string t.
# Output of the example which is console.logged at the bottom of operations.js:
$ node operations.js
To change 'kitten' in to 'sitting':
[ [ 'delete', 'k' ]
, [ 'insert', 's' ]
, [ 'retain', 1 ]
, [ 'retain', 1 ]
, [ 'retain', 1 ]
, [ 'delete', 'e' ]
@fitzgen
fitzgen / gist:749904
Last active April 26, 2024 20:08
Gerard Paapu's TCO. Works with mutual recursion.
(function () {
// conceal the Thunk class to avoid
// so that the only way to make one is
// to call Function::thunk
function Thunk(fn, args) {
this.fn = fn;
this.args = args;
}
Thunk.prototype.force = function () {
@fitzgen
fitzgen / gist:749901
Created December 21, 2010 12:59
My TCO -- doesn't work with mutual recursion
function toArray(obj, i) {
return Array.prototype.slice.call(obj, i || 0);
}
function tco(fn) {
return function () {
var args = toArray(arguments),
shouldContinue = true,
recur = function () {
shouldContinue = true;
acc = (n)->
(i)->
n += i
=======================
var acc;
acc = function(n) {
return function(i) {
return n += i;