Skip to content

Instantly share code, notes, and snippets.

@andrewjjenkins
andrewjjenkins / timerdebug.js
Last active March 11, 2022 14:13
Ways to hack setTimeout and setInterval to help debug lingering timers.
(function () {
var oldSetTimeout = GLOBAL.setTimeout;
GLOBAL.setTimeout = function () {
var e = new Error('Just for stack trace');
console.log('New timeout registered from %s', e.stack);
return oldSetTimeout.apply(this, arguments);
};
var oldSetInterval = GLOBAL.setInterval;
GLOBAL.setInterval = function () {
var e = new Error('Just for stack trace');
@andrewjjenkins
andrewjjenkins / rpi-node.sh
Last active August 10, 2021 15:32
Cross-compile node.js for Raspberry Pi
#!/usr/bin/env bash
# Based on https://github.com/needforspeed/Nodejs-ARM-builder/blob/master/cross-compiler.sh
# but updated to use the cross-compiling tools that Raspberry Pi recommends for the kernel.
# Only works for ARMv6.
# AJJ: Released into the public domain.
set -e
@andrewjjenkins
andrewjjenkins / child1.js
Created April 9, 2014 21:21
maliciousChild
var secretKey = 'foo';
setInterval(function () {
secretKey = secretKey + 'bar';
console.log('My secret key is ' + secretKey);
}, 1000);
@andrewjjenkins
andrewjjenkins / simpleLog.js
Last active August 29, 2015 13:55
A really simple javascript module to log
var log = (function () {
"use strict";
var format = require('util').format;
// Customize levels, but do not name any level: "log" "getLevel" "setLevel"
var levels = { ERROR: 10, WARN: 20, INFO: 30, DEBUG: 40, TRACE: 50 };
var currentLevel = 'INFO';
function doGetLevel() { return currentLevel; }
function doSetLevel(level) {