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
// ==UserScript== | |
// @name Remove Verification Nav and Aside | |
// @namespace http://www.sotoestevez.dev/ | |
// @version 0.2 | |
// @description removes the verification aside from twitter | |
// @author sotoestevez | |
// @match https://*twitter.com/* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// @downloadUrl https://gist.github.com/kriogenia/85af9a9e539e26e28b3ad9aec5b9f6db |
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 ADDRESSES: Vec<&str> = Vec::from([ | |
"http://validaddress.com", | |
"http://mainmirror.com", | |
"http://128.0.0.1:1337" | |
]); | |
fn main() { | |
check_addresses() | |
} |
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::sync::OnceLock; | |
static ADDRESSES: OnceLock<Vec<&str>> = OnceLock::new(); | |
fn main() { | |
assert!(ADDRESSES.get().is_none()); | |
let first_attempt = ADDRESSES.set(Vec::from([ | |
"http://validaddress.com", | |
"http://mainmirror.com", |
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
fn main() { | |
// Result of the different operations computing 255 + 1 (overflowing the u8) | |
assert_eq!(u8::MAX.wrapping_add(1), 0); | |
assert_eq!(u8::MAX.checked_add(1), None); | |
assert_eq!(u8::MAX.overflowing_add(1), (0, true)); | |
assert_eq!(u8::MAX.saturating_add(1), u8::MAX); | |
// Wrapping examples | |
assert_eq!(i32::MAX.wrapping_add(12), i32::MIN + 11); | |
assert_eq!(0u8.wrapping_sub(1), u8::MAX); |
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
[package] | |
name = "generify_with_compiler_errors" | |
version = "0.1.0" | |
edition = "2021" | |
authors.workspace = true | |
[dependencies] | |
num = { workspace = true, default-features = true } | |
vector2d.workspace = true |
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
[... rest of the manifest ] | |
[workspace.dependencies] | |
num = { version = "0.4", default-features = false } | |
vector2d = "2.2" | |
rand = "0.8.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
[package] | |
name = "add_trait" | |
version = "0.1.0" | |
edition.workspace = true | |
authors.workspace = true | |
description = "Dissecting Rust Traits to Learn Their Secrets" | |
documentation = "https://betterprogramming.pub/dissecting-rust-traits-to-learn-their-secrets-839845d3d71e" | |
homepage.workspace = true | |
repository.workspace = true | |
license.workspace = true |
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
[package] | |
name = "sotoestevez_medium" | |
version = "0.1.0" | |
[workspace] | |
members = ["add_trait", "beginning_tips", "generify_with_compiler_errors", "modules", "scoped_threads" ] | |
[workspace.package] | |
edition = "2021" | |
authors = ["Soto Estévez <ricardo@sotoestevez.dev>"] |
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
fn instead_of_this(chars: &Vec<u8>) -> Option<&u8> { | |
chars.iter().find(|&&x| x == b"\n"[0]) | |
} | |
fn do_this(chars: &[u8]) -> Option<&u8> { | |
chars.iter().find(|&&x| x == b"\n"[0]) | |
} | |
fn main() { | |
let vec: Vec<u8> = vec![77, 78, 2]; |
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
let mut a = vec![1, 2, 3]; | |
let mut x = 0; | |
std::thread::scope(|s| { | |
s.spawn(|| { | |
println!("hello from the first scoped thread"); | |
// We can borrow `a` here. | |
dbg!(&a); | |
}); | |
s.spawn(|| { |
NewerOlder