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; |
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
// This is the trait that has .tuple_combinations_while() | |
trait HasTupleCombinationWhile: Iterator { | |
/// Return an iterator adaptor that iterates over the combinations of the elements from an iterator. | |
/// With the added beneift of being able to short-circuit | |
fn tuple_combinations_while<P>( | |
mut self, | |
predicate: P, | |
) -> TupleCombinationsWhile<Self, Self::Item, P> | |
where | |
Self: Clone, |
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
require('log-timestamp'); | |
const timers = []; | |
function setTimeout(fn, time) { | |
const ret = global.setTimeout(() => { | |
console.log(`Finished timer ${timers.indexOf(ret)} after ${time}`); | |
fn(); | |
}, time); | |
console.log(`Started timer ${timers.push(ret) - 1} with ${time}`); |
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 serde::{Deserialize, de::{self, Deserializer, Visitor}}; | |
use std::fmt; | |
#[derive(Debug)] | |
enum Shape { | |
Triangle = 3, | |
Rectangle = 4, | |
Pentagon = 5, | |
} |
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 std::{ | |
pin::Pin, | |
task::{Context, Poll}, | |
}; | |
use tokio::io::AsyncRead; | |
enum Either<T, U> { | |
A(T), | |
B(U), | |
} |
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
async fn is_reader_ready<R>(reader: &mut R) -> bool where R: AsyncRead + Unpin { | |
let mut me = &mut *reader; | |
poll_fn(|cx| { | |
let mut v = []; | |
Poll::Ready(Pin::new(&mut me).poll_read(cx, &mut v[..]).is_ready()) | |
}).await | |
} |
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 std::{ | |
collections::HashSet, | |
ffi::OsString, | |
fs, | |
hash::{Hash, Hasher}, | |
path::Path, | |
}; | |
#[derive(Debug, PartialEq, Eq)] | |
pub enum DirEntry { |
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
#![no_std] | |
extern crate alloc; | |
use alloc::borrow::Cow; | |
use core::iter; | |
enum Tag { | |
/// A non-HTML tag that renders into nothing for wrapping text | |
Fragment, |
OlderNewer