Skip to content

Instantly share code, notes, and snippets.

@johnhaley81
johnhaley81 / factorialCallbackTest.js
Last active March 18, 2021 22:38
Factorial promise/generator test
function factorialCallback(acc, n, callback) {
if (n === 0) {
callback(acc);
} else {
setImmediate(() => factorialCallback(acc * n, n - 1, callback));
}
}
function timedFactorialCallback(n) {
const start = new Date();
@bolshchikov
bolshchikov / .jshintrc
Last active March 4, 2024 12:19
JSHint configuration file
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
// == Enforcing Options ===============================================
//
// These options tell JSHint to be more strict towards your code. Use
// them if you want to allow only a safe subset of JavaScript, very
@dblock
dblock / getWeek.js
Created July 13, 2011 22:49
get week of the year in JavaScript
function( d ) {
// Create a copy of this date object
var target = new Date(d.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (d.getDay() + 6) % 7;
// Set the target to the thursday of this week so the