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
| function escapeRegExp(str) { | |
| return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | |
| } |
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
| function groupBy(arr, fn) { | |
| fn = fn || ((o) => o); | |
| let g = []; | |
| let v = []; | |
| for (let i = 0; i < arr.length; ++i) { | |
| let val = fn(arr[i]); | |
| let idx = g.indexOf(val); | |
| if (idx === -1) { | |
| g.push(val); |
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
| // Flatten array from desired level | |
| let flattenArray = function(arr, lvl = 0) { | |
| if (!(arr instanceof Array)) return lvl === 0 ? arr : [arr]; | |
| if (lvl > 0) { | |
| return arr.map((el) => flattenArray(el, lvl-1)); | |
| } else { | |
| return arr.reduce((arr, el) => { | |
| return arr.concat(flattenArray(el, lvl-1)); | |
| }, []); |
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
| let Generator = (function*(){}).constructor; | |
| // function Generator(...a) { | |
| // let [args, body] = a; | |
| // if (a.length === 0) [args, body] = [[], '']; | |
| // if (a.length === 1) [args, body] = [[], a[0]]; | |
| // return new Function(`return function*(${args.join(',')}){${body}};`)(); | |
| // } |
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
| function pascalsTriange(depth) { | |
| let last = [1]; | |
| let res = []; | |
| for (let i = 0; i < depth; i++) { | |
| let n = []; | |
| for (let j = 0; j < i + 1; j++) { | |
| n[j] = (last[j-1] || 0) + (last[j] || 0); | |
| } | |
| res.push(n); | |
| last = n; |
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
| const flatten = arr => arr.reduce((res, el) => [...res, ...(Array.isArray(el) && flatten(el) || [el])], []) |
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
| // get skin names from this address | |
| // http://www.agarioguide.com/skins/ | |
| $$('.wp-caption-text span').map(el=>el.innerHTML).join('|'); | |
| // declare skin names: | |
| let skins = '2ch.hk|4chan|8ch|9gag|Argentina|France|Austria|ayy lmao|Bait|Bangladesh|Belgium|Bosnia|Botswana|Brazil|Bulgaria|Byzantium|Cambodia|Canada|Chile|China|cia|Confederate|Croatia|Denmark|Doge|ea|Earth|Estonia|European Union|German Empire|Germany|Greece|Hitler|Hong Kong|Hungary|Imperial Japan|India|Indiana|Indonesia|Iran|Iraq|Ireland|Facepunch|Italy|Jamaica|Japan|KC|Latvia|Lithuania|Luxembourg|Maldivas|Mars|Matriarchy|Mexico|Moon|NASA|Agario|Netherlands|Nigeria|Receita Federal|North Korea|Norway|Origin|Pakistan|Patriarchy|Peru|Pewdiepie|Piccolo|Facebook|Pokerface|Poland|Portugal|Prodota|Prussia|Qing Dynasty|Quebec|IRS|Reddit|Romania|Russia|Sanik|Satanist|Scotland|Sealand|Sir|French Kingdom|Steam|Feminism|Finland|Stussy|Sweden|Switzerland|Taiwan|Texas|Thailand|Tsarist Russia|Tumblr|Australia|Austria|Turkey|Ukraine|United Kingdom|USA|USSR|Vinesauce| |
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
| function transpose(arr) { | |
| let [h, w] = [arr.length, arr[0].length]; | |
| let res = []; | |
| for (let x = 0; x < w; ++x) { | |
| res[x] = []; | |
| } | |
| for (let y = 0; y < h; ++y) { | |
| for (let x = 0; x < w; ++x) { | |
| res[x][y] = arr[y][x]; | |
| } |
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
| // https://www.bitmarket.pl/graphs/BTCPLN/depth.svg | |
| alert([].map.call(document.querySelectorAll('.legend'),n=>n.innerHTML).filter(t=>t[0]=='Σ').join`\n`) |
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
| var deepEach = function callee(obj, fn, chain) { | |
| chain = chain && chain + '.' || ''; | |
| // chain += '.'; | |
| for (var i in obj) { | |
| if (obj.hasOwnProperty(i)) { | |
| if (typeof obj[i] === 'object') { | |
| callee(obj[i], fn, chain + i); | |
| } else { | |
| fn(obj[i], i, chain + i); | |
| } |