Skip to content

Instantly share code, notes, and snippets.

View denizozger's full-sized avatar
🧿

Deniz Ozger denizozger

🧿
  • Zurich, Switzerland
View GitHub Profile
@denizozger
denizozger / multiple_settimeouts.js
Created August 5, 2016 12:07
Visualise settimeout behaviour in call stack
function log(n) { console.log(n); }
setTimeout(function A() {
setTimeout(function B() {
log(1);
setTimeout(function D() { log(2); }, 0);
setTimeout(function E() { log(3); }, 0);
}, 0);
setTimeout(function C() {
@denizozger
denizozger / commentsToTree.js
Last active August 29, 2015 13:57
Sort a list of comments in date and reply order
/**
* Given a list of random comments, having dates and parentIds, this code
* sorts the list following parent-child relationships and dates.
*
* Notation:
* C1R2 stands for 'Second reply to first comment'
* C2R2R1R1 stands for '1st Reply to the 1st Reply to the
* 2nd Reply of the 2nd Comment'
*
* Input:
@denizozger
denizozger / log_object
Created December 10, 2013 15:15
Log a Javascript object preventing circular structure error (a minor amendment to http://stackoverflow.com/a/9653082)
var testObject = {
id : 5,
name : 'foo'
}
function censor(censor) {
return (function() {
var i = 0;
return function(key, value) {