Skip to content

Instantly share code, notes, and snippets.

View onurkerimov's full-sized avatar

Onur Kerimov onurkerimov

View GitHub Profile
@onurkerimov
onurkerimov / setInterval-wrapper.js
Last active October 9, 2018 11:58
A practical setInterval function wrapper that I oftenly use, in which the interval is cleared when the callback function returns true.
(function() {
$.setInterval = function(int, fn) {
var returnValue
var interval = setInterval(function() {
if (returnValue === true) {
clearInterval(interval);
} else {
returnValue = fn()
}
}, int)
@onurkerimov
onurkerimov / Math-alias.js
Last active October 9, 2018 11:34
A template for using the functions and variables in native Math object, without writing "Math." at the beginning, also "print" is the alias for "console.log"
(function(print, abs, acos, acosh, asin, asinh, atan, atanh,
atan2, ceil, cbrt, expm1, clz32, cos, cosh, exp, floor,
fround, hypot, imul, log, log1p, log2, log10, max, min,
pow, random, round, sign, sin, sinh, sqrt, tan, tanh,
trunc, E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1_2, SQRT2) {
// Function Body
})(console.log, Math["abs"], Math["acos"], Math["acosh"], Math["asin"],
Math["asinh"], Math["atan"], Math["atanh"], Math["atan2"], Math["ceil"],