Skip to content

Instantly share code, notes, and snippets.

View thecaralice's full-sized avatar
☮️
pls no war

Alice Carroll thecaralice

☮️
pls no war
View GitHub Profile
@thecaralice
thecaralice / main.rs
Last active September 21, 2024 07:21 — forked from oscarvarto/main.rs
Simple command line parser with clap
use clap::Parser;
use regex::Regex;
use std::{
fmt::{self, Debug, Display},
str::FromStr,
};
use thiserror::Error;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
enum Browser {
from dataclasses import dataclass
from typing import TypeVar, Generic, cast
T = TypeVar("T")
@dataclass
class Some(Generic[T]):
value: T
Option = Some[T] | None

Resizable array in different languages

Language Name
Rust Vec
C++ vector
Python list
Java ArrayList
C# List
JavaScript Array
@thecaralice
thecaralice / find-sum.py
Created April 14, 2022 22:01
Given an integer array `numbers` and an integer `target`, find (`i`, `j`) such that `numbers[i] + numbers[j] == target`
from ast import literal_eval
from collections import deque
from typing import Callable, Iterable
from more_itertools import is_sorted
def solve_sorted(numbers: Iterable[int], target: int) -> tuple[int, int] | None:
values = deque(numbers)
start = 0
@thecaralice
thecaralice / main.py
Created March 20, 2022 22:46
colorful checkerboard-like matrix pattern
from typing import TypeVar
from collections.abc import Sequence
from sys import argv, stderr
from itertools import cycle, islice
T = TypeVar("T")
def dist(index: int, length: int) -> int:
if not (0 <= index < length):
raise ValueError("index must be in [0; length)")

Keybase proof

I hereby claim:

  • I am iamalicecarroll on github.
  • I am alicecarroll (https://keybase.io/alicecarroll) on keybase.
  • I have a public key ASA-Bc9gX-KSJlpBLeB4FnyfoVkAsfun_GP_gsRHHfMBGgo

To claim this, I am signing this object:

@thecaralice
thecaralice / alacritty.yml
Created August 5, 2020 16:50
Silver demo config
shell:
program: /bin/fish
args:
- -C silver -c silver.toml init | source
- -C sleep 1000 &
- -C false
font:
normal:
family: JetBrains Mono Nerd Font Mono
size: 7
:root {
--DarkBlack: #282828 !important;
--DarkRed: #cc241d !important;
--DarkGreen: #98971a !important;
--DarkYellow: #d79921 !important;
--DarkBlue: #458588 !important;
--DarkPurple: #b16286 !important;
--DarkAqua: #689d6a !important;
--DarkWhite: #a89984 !important;
--DarkOrange: #d65d0e !important;
@thecaralice
thecaralice / compile.zsh
Created May 21, 2020 09:16
Compiler script for NASM
#!/bin/zsh
filename="${1%.*}"
nasm -felf32 $1 && \
ld -melf_i386 -s -o $filename $filename.o && \
rm $filename.o
@thecaralice
thecaralice / group.py
Last active July 15, 2021 20:32
Useful snippets
import itertools as it
def group(iterable, size, fill=None):
yield from it.zip_longest(*[iter(iterable)] * size, fillvalue=fill)
if __name__ == '__main__':
print(*group(range(10), 3, 0), sep=', ') # -> (0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 0, 0)