Skip to content

Instantly share code, notes, and snippets.

Timo Tijhof Krinkle

Block or report user

Report or block Krinkle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Krinkle
Krinkle / 01-parkers-number-of-feb2014.js
Created Apr 18, 2019
3435 – The sum of each digit raised to the power of itself.
View 01-parkers-number-of-feb2014.js
const MAX = 100 * 1000 * 1000; // 100 million
function powself(number) {
if (number === 0) {
return NaN; // matt does not like zero.
} else {
return Math.pow(number, number);
}
}
@Krinkle
Krinkle / 01-bench_mw-loader-register.js
Last active Feb 9, 2019
This gist is referred to in mediawiki-core.git:/resources/src/startup.
View 01-bench_mw-loader-register.js
// Node.js and browser
var perf = typeof performance !== 'undefined' ? performance : require('perf_hooks').performance;
var registry;
var i;
var start;
var diff;
var count = 10000;
// Baseline: Multi-purpose (one and multi), self-call to unbatch
@Krinkle
Krinkle / perfect-numbers.js
Last active Mar 18, 2019
Distribute exponential task sizes via Node.js cluster workers.
View perfect-numbers.js
/**
* Requires Node 6.0+
*
* Author: Timo Tijhof (2018).
* License: Public domain.
*/
const cluster = require('cluster');
let pidLabel = cluster.isMaster ? 'master' : 'worker';
@Krinkle
Krinkle / 01-search-all-grafana.js
Last active Oct 14, 2018
Search Grafana dashboard JSON
View 01-search-all-grafana.js
const path = require('path');
const req = require('request-promise');
const urlListQuery = 'https://grafana.wikimedia.org/api/search?query=&starred=false';
const urlTplDashQuery = 'https://grafana.wikimedia.org/api/dashboards/$1';
const pattern = process.argv[2];
if (!pattern) {
const cmd = path.basename(process.argv[0]);
const base = path.basename(process.argv[1]);
View cost.js
/**
* https://tfl.gov.uk/corporate/terms-and-conditions/tfl-call-charges
*
* > The rate is 0.66p per minute.
* > There is also a 40p connection charge.
* > Call charges are rounded up to the nearest 10p, with a minimum charge of 60p.
*
* @param {number} seconds
* @return {string} Cost in GBP
*/
View 02-2015-by-month.txt
335709 Apr/2014
634580 May/2014
472835 Jun/2014
557525 Jul/2014
385136 Aug/2014
723163 Sep/2014
738108 Oct/2014
1233766 Nov/2014
1241514 Dec/2014
1072986 Jan/2015
You can’t perform that action at this time.