Skip to content

Instantly share code, notes, and snippets.

View davidgarsan's full-sized avatar
💩
entropy

David davidgarsan

💩
entropy
View GitHub Profile
javascript:(function() {
function textNodesUnder(el){ var n, a=[], walk=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false); while(n=walk.nextNode()) a.push(n); return a; }
Array.prototype.forEach.call(textNodesUnder(document.body), function(elem){
const t = elem.textContent.trim();
if(t) {
fetch("https://ninini-cvyphndqrn.now.sh/ninini/"+t)
.then(resp => resp.text())
.then(text => elem.textContent = text) } });
})()
@davidgarsan
davidgarsan / infiniteArrayPagination.js
Last active August 8, 2018 06:12
Infinite Array Pagination
/**
* Takes an array, a given window size and
* a starting index and returns a fragment of the
* array with infinite pagination.
* If the window size if bigger than teh array size,
* it shouldn't be paginated.
**/
const a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];