Skip to content

Instantly share code, notes, and snippets.

View gerardpaapu's full-sized avatar
🏠
Working from home

Gerard Paapu gerardpaapu

🏠
Working from home
View GitHub Profile
(function () {
var apply = Function.prototype.apply;
var flatten = apply.bind(Array.prototype.concat, []);
Array.prototype.selectMany = function (fn) {
return flatten(this.map(fn));
};
}());
// usage
@gerardpaapu
gerardpaapu / gist:4528317
Last active December 11, 2015 02:09 — forked from fitzgen/gist:749904
(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 () {
// ==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==
@gerardpaapu
gerardpaapu / ihfhMqfN.html
Created May 16, 2012 04:52 — forked from anonymous/ihfhMqfN
a guest on May 15th, 2012 - this.x in setValues is a number. In update it's NaN
<!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>
// with let
for (let i = 0; i < children.length; ++i) {
let (child = children[i])
setTimeout(function(){ doSomethingTo(child) }, 1000)
}
// 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;
}