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
| $('[data-test-id*=-order-history-discount],[data-test-id*=-order-history-total]') | |
| .toArray() | |
| .map((idx, i)=> idx.textContent.replace(/[^0-9.]/g, "")) | |
| .map(parseFloat) | |
| .reduce((a,b) => a+b,0) |
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
| $('#contents ytmusic-playlist-shelf-renderer .like.style-scope.ytmusic-like-button-renderer[aria-pressed="false"]') | |
| .map((a,b ) => setTimeout(() => b.click(), a*300)); |
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 findDuplicates(arr) { | |
| var tortoise = arr[0] | |
| var hare = arr[0] | |
| do { | |
| tortoise = arr[tortoise] | |
| hare = arr[arr[hare]] | |
| } while (tortoise != hare) | |
| return arr[tortoise] | |
| } | |
| console.log(findDuplicates([1, 2, 3, 4, 5, 5, 6])) |
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 mergeSort (unsortedArray) { | |
| // No need to sort the array if the array only has one element or empty | |
| if (unsortedArray.length <= 1) { | |
| return unsortedArray; | |
| } | |
| // In order to divide the array in half, we need to figure out the middle | |
| const middle = Math.floor(unsortedArray.length / 2); | |
| // This is where we will be dividing the array into left and right | |
| const left = unsortedArray.slice(0, middle); |
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 items = []; | |
| $('.wikitable tbody tr:not(.expand-child)').each((i, item) => { | |
| item = $(item) | |
| const next = $(item.next()); | |
| const name = item.find('p a').text(); | |
| const traits = [] | |
| next.find('a').each((a, b) => traits.push(b.innerText)) | |
| items.push({name, traits}) |
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 a = [ | |
| 'Do', | |
| [ | |
| 'th', | |
| [ | |
| 'rab', | |
| [ | |
| 'ho', | |
| [ | |
| 'w', |
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
| openssl req -x509 -sha256 -newkey rsa:2048 -keyout server.key \ | |
| -out server.crt -days 36500 -nodes \ | |
| -subj "/C=CA/ST=Alberta/L=/O=Localhost/OU=Org/CN=localhost" \ | |
| -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:localhost")) \ | |
| -reqexts SAN -extensions SAN⏎ |
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 KoaServer() { | |
| const Koa = require('koa'); | |
| const compose = require('koa-compose'); | |
| const helmet = require('koa-helmet'); | |
| const serve = require('koa-static'); | |
| const compress = require('koa-compress'); | |
| const prerender = require('koa-prerender'); | |
| const makeApp = () => { | |
| const app = new Koa(); |
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 () { | |
| function CustomEvent ( event, params ) { | |
| params = params || { bubbles: false, cancelable: false, detail: undefined }; | |
| var evt = document.createEvent( 'CustomEvent' ); | |
| evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); | |
| return evt; | |
| } | |
| CustomEvent.prototype = window.Event.prototype; |
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
| Promise.all( | |
| [ | |
| 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.2/lodash.min.js', | |
| 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js', | |
| 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.16.0/moment.min.js' | |
| ].map( site => | |
| fetch(site) | |
| .then( data => data.text() ) | |
| ) | |
| ).then(data =>{ |
NewerOlder