This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Promises, the big deal | |
// Here's a, a small function that returns a promise, | |
// which resolves itself at a random time between 0 and 1/2s, returning "My question num" | |
var a = (num) => { | |
return new Promise( (res, rej) => { | |
// return "My question num" between immediately and 1/2 s. | |
return setTimeout( () => res(`My question ${num}`), 500 * Math.random()) | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Script to sort HN comments by post date **/ | |
var itemsArray = [], | |
tb = document.querySelectorAll('table.itemlist > tbody > tr'); | |
function sortBycom(a, b) { | |
var left = a[1].querySelector('td.subtext > a:last-child'), | |
right = b[1].querySelector('td.subtext > a:last-child'); | |
// If no comments has been made yet, push them at the end |
NewerOlder