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 () { | |
var apply = Function.prototype.apply; | |
var flatten = apply.bind(Array.prototype.concat, []); | |
Array.prototype.selectMany = function (fn) { | |
return flatten(this.map(fn)); | |
}; | |
}()); | |
// usage |
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 () { | |
// 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 () { |
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
// ==UserScript== | |
// @id dft-postion-unfixed | |
// @name Remove position fixed | |
// @version 1.0 | |
// @namespace dft | |
// @author Matthew Goodall | |
// @description Changes position:fixed to position:relative | |
// @include * | |
// @run-at document-idle | |
// ==/UserScript== |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title> test </title> | |
</head> | |
<body> | |
<canvas id="myCanvas" width="512" height="512" style="border:1px solid #c3c3c3;">Your browser is bad and you should feel bad (no canvas support)</canvas> |
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
// with let | |
for (let i = 0; i < children.length; ++i) { | |
let (child = children[i]) | |
setTimeout(function(){ doSomethingTo(child) }, 1000) | |
} |
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
// Javascript | |
function triangle(a,b) { | |
if(a > 0 && b > 0 ) { | |
function sqroot(x) { | |
return (x > 0) ? Math.pow(x,.5) : 0; | |
} | |
return sqroot( a*a + b*b ); | |
} else return 0; | |
} |