Skip to content

Instantly share code, notes, and snippets.

View raxetul's full-sized avatar
👋
I may be slow to respond.

Emrah URHAN raxetul

👋
I may be slow to respond.
View GitHub Profile
@david-a-perez
david-a-perez / fastest_day6_part2.rs
Last active July 3, 2024 09:49
Advent of Code 2023 Day 6 Optimizations
// time: [1.8843 µs 1.8897 µs 1.8955 µs]
pub fn original(input: &[u8]) -> Option<usize> {
let mut idx = 0;
'outer: while idx + 13 < input.len() {
let mut state = 0;
for (next_idx, byte) in input[idx..idx + 14].iter().enumerate().rev() {
let bit_idx = byte % 32;
if state & (1 << bit_idx) != 0 {
idx += next_idx + 1;
continue 'outer;

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@elieux
elieux / msys2-mirror.sh
Last active April 2, 2017 14:45
MSYS2 pacman repos mirroring script
#!/usr/bin/bash
ROOT="$(pwd)"
dl() {
local cookie="/tmp/pacman-mirror-cookie.txt"
touch "${cookie}"
local file
@nicktoumpelis
nicktoumpelis / repo-rinse.sh
Created April 23, 2014 13:00
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive