Skip to content

Instantly share code, notes, and snippets.

View vidhanio's full-sized avatar
🦀

Vidhan Bhatt vidhanio

🦀
View GitHub Profile
@vidhanio
vidhanio / find_one_of.rs
Last active October 8, 2023 00:32
find the first occurrence of either of two substrings.
use std::ops::ControlFlow;
/// Finds the first occurrence of either `a` or `b` in `s`.
///
/// Returns the index of the first occurrence of either `a` or `b` in `s`,
/// as well as a boolean indicating whether the first occurrence was `a`.
/// (If it was `b`, the boolean is `false`.)
fn find_one_of(s: &str, a: &str, b: &str) -> Option<(usize, bool)> {
let control_flow =
s.bytes()
@vidhanio
vidhanio / a2l.user.js
Last active November 17, 2022 14:39
McMaster Fast Login User Scripts
// ==UserScript==
// @name McMaster Avenue to Learn Fast Login
// @namespace http://github.com/vidhanio
// @description Skip the two clicks needed to log in to Avenue to Learn.
// @match https://avenue.cllmcmaster.ca/d2l/login
// @match https://avenue.mcmaster.ca
// @author Vidhan Bhatt
// ==/UserScript==
const target = new URLSearchParams(window.location.search).get("target");