Skip to content

Instantly share code, notes, and snippets.

View Anthonyzou's full-sized avatar
🐟
Shell

Anthonyzou

🐟
Shell
  • Canada
  • 20:20 (UTC -06:00)
View GitHub Profile
@Anthonyzou
Anthonyzou / main.js
Last active January 29, 2024 19:17
hello fresh
$('[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)
@Anthonyzou
Anthonyzou / file.js
Last active January 10, 2023 17:36
Like all in a youtube playlist
$('#contents ytmusic-playlist-shelf-renderer .like.style-scope.ytmusic-like-button-renderer[aria-pressed="false"]')
.map((a,b ) => setTimeout(() => b.click(), a*300));
@Anthonyzou
Anthonyzou / main.js
Last active April 17, 2020 01:28
findDuplicates
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]))
@Anthonyzou
Anthonyzou / index.js
Created January 20, 2020 18:19
Quicksort
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);
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})
var a = [
'Do',
[
'th',
[
'rab',
[
'ho',
[
'w',
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⏎
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();
(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;
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 =>{