Skip to content

Instantly share code, notes, and snippets.

@zoeisnowooze
zoeisnowooze / main.rs
Created February 21, 2022 22:02
longest-sub-seq
use std::env;
use std::ops::RangeInclusive;
trait RangeInclusiveExt {
fn len(&self) -> usize;
}
impl RangeInclusiveExt for RangeInclusive<usize> {
fn len(&self) -> usize {
*self.end() - *self.start() + 1
@zoeisnowooze
zoeisnowooze / case_permutations.rs
Last active January 10, 2022 17:02
Case permutations
pub fn case_permutations(s: String) -> Vec<String> {
let mut stack: Vec<String> = vec![String::with_capacity(s.capacity())];
for c in s.chars() {
if c.is_ascii_alphabetic() {
let mut new_stack: Vec<String> = vec![];
for p in stack {
let mut lower = p.clone();
lower.push(c.to_ascii_lowercase());
new_stack.push(lower);
#![allow(unused)]
extern crate itertools;
use itertools::Itertools;
fn phone_letter(number: &str) -> Vec<String> {
number
.chars()
.filter_map(|digit| match digit {
'2' => Some(vec!['a', 'b', 'c']),
#include <stdio.h>
#include <stdlib.h>
static int FACTORS[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101};
struct map_entry {
int sort_key;
int arg_index;
};
const fs = require("fs");
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default;
PATTERNS = [
/BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY/,
/AIza[A-Za-z0-9_-]{35}/,
/sk_live_[A-Za-z0-9]{24}/,
];
@zoeisnowooze
zoeisnowooze / peaks.rs
Last active November 10, 2021 21:29 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![allow(unused)]
fn peaks<T: std::cmp::PartialOrd>(values: Vec<T>) -> Vec<usize> {
values
.windows(3)
.enumerate()
.filter_map(|(i, window)| {
if window[0] < window[1] && window[1] > window[2] {
Some(i + 1)
} else {
@zoeisnowooze
zoeisnowooze / reorder.rs
Last active October 19, 2021 19:45 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![allow(unused)]
fn reorder<T: Clone>(values: Vec<T>, indices: Vec<usize>) -> Vec<Option<(usize, T)>> {
let mut pairs: Vec<_> = indices.iter().zip(values).collect();
pairs.sort_by_key(|v| v.0);
let mut iter = pairs.iter().peekable();
(0..*pairs.last().unwrap().0 + 1)
.map(|i| match iter.peek() {
Some((j, _)) => {
@zoeisnowooze
zoeisnowooze / is_odious.rs
Created October 11, 2021 19:10 — forked from rust-play/playground.rs
Code shared from the Rust Playground
//! Checks if an integer is an odious number.
/// Determine if an integer is an odious number.
///
/// 14 is an odious number because it has an odd number of 1s in its binary
/// expansion 1110. Conversely, 5 isn't an odious number. It has an even number
/// of 1s in its binary expansion 101 and so is called an evil number.
fn is_odious(num: i64) -> bool {
let mut num = num;
let mut sum = false;
@zoeisnowooze
zoeisnowooze / Trans Voice Practice Log.md
Last active October 7, 2021 20:11
Markdown version of Renée Yoxon's Trans Vocal Exploration practice log template, click the "Raw" button and save to your template folder
date
{"date"=>nil}

🔋 Energy:: (1 - 10) 🧠 Mental state:: (Happy Sad Contented Dysphoric Angry Excited Neutral) 👟 Physical state:: (Tired Energized In Pain Neutral)

Check-in

@zoeisnowooze
zoeisnowooze / witchhazelhypercolor.zsh-theme
Last active July 27, 2021 02:53
Witch Hazel Hypercolor ZSH Theme
# Witch Hazel Hypercolor ZSH Theme
#
# by @medecau and @zoeisnowooze
# Witch Hazel by @theacodes
#
# https://witchhazel.thea.codes/
# https://twitter.com/ZoeIsNowOoze/status/1418271734327820289
#
# 1. Create a file ~/.oh-my-zsh/custom/themes/witchhazelhypercolor.zsh-theme
#