This file contains 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
// Use this if you want [2, 3, 5.....] | |
use std::collections::HashMap; | |
/// This is a prime number generator based on [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) | |
/// that can be _trivially_ improved by switching to [Sieve of Atkin](https://en.wikipedia.org/wiki/Sieve_of_Atkin) for extra speed | |
struct PrimeIterator { | |
current: u64, | |
composite_to_primes: HashMap<u64, Vec<u64>>, | |
} |
This file contains 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 puppeteer = require("puppeteer"); | |
// This works around Discord's security measurements | |
// to set values on localStorage before we go to discord.com/login | |
const setDomainLocalStorage = async (browser, url, values) => { | |
const page = await browser.newPage(); | |
await page.setRequestInterception(true); | |
page.on("request", r => { | |
r.respond({ | |
status: 200, |
This file contains 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
Array.from(document.querySelectorAll(".track-name-wrapper")).map(node => { | |
let temp = {} | |
temp.name = node.firstElementChild.textContent | |
let artistAlbum = node.lastElementChild.querySelectorAll("a") | |
temp.artist = {name: artistAlbum[0].textContent, link: artistAlbum[0].href} | |
temp.album = {name: artistAlbum[1].textContent, link: artistAlbum[1].href} | |
return temp | |
}) |
This file contains 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
Array.from(document.querySelectorAll("ytd-playlist-video-renderer")) | |
.slice(121) //Changes this number to the number of the last video you watched | |
.map(x => x.querySelector(".ytd-thumbnail-overlay-time-status-renderer").textContent.trim()) | |
.reduce((acc, video) => { | |
let [h, m, s] = video.split(":").map(x => parseInt(x)); | |
if (!s) {s = m; m = h; h = 0;} | |
acc[0] += h; | |
acc[1] += m; | |
acc[2] += s; | |
return acc; |
NewerOlder