Skip to content

Instantly share code, notes, and snippets.

View Techcable's full-sized avatar
🇺🇸
Procrastinating

Techcable

🇺🇸
Procrastinating
View GitHub Profile
@Techcable
Techcable / rust-lang-issue-labels.json
Created September 8, 2025 02:34
The issue labels for rust-lang/rust as of 2025-09-07
[
{
"id": 3422528123,
"node_id": "LA_kwDOAAsO6M7L_6J7",
"url": "https://api.github.com/repos/rust-lang/rust/labels/-Clink-dead-code",
"name": "-Clink-dead-code",
"color": "712F83",
"default": false,
"description": "Linkage option: -Clink-dead-code"
},
@Techcable
Techcable / const_track_caller.rs
Last active August 27, 2025 08:05
Demonstrating a bizzare interaction between `#[track_caller]` and const-evaluation.
#![allow(dead_code)]
use std::panic::Location;
#[track_caller]
fn runtime_line() -> &'static u32 {
Box::leak(Box::new(core::panic::Location::caller().line()))
}
#[track_caller]
fn inline_const_line() -> &'static u32 {
@Techcable
Techcable / raw_vec.rs
Created August 24, 2025 08:12
[DRAFT] An implementation of the stdlib-internal `RawVec` type using the `Vec` for the allocation
use std::marker::PhantomData;
use std::mem::ManuallyDrop;
use std::ptr::NonNull;
/// Check if growth is necessary.
#[inline]
pub fn needs_to_grow(capacity: usize, len: usize, additional: usize) -> bool {
// https://github.com/rust-lang/rust/blob/1.89.0/library/alloc/src/raw_vec/mod.rs#L626-L628
additional > capacity.wrapping_sub(len)
}
@Techcable
Techcable / urljoin.py
Created July 24, 2025 21:15
A small script to join URLs against a base path
#!/usr/bin/env python3
"""A command line interface to urllib.parse.urljoin"""
import argparse
from urllib.parse import urljoin
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("base", help="The base URL")
@Techcable
Techcable / strip_comments.py
Created July 18, 2025 22:10
Strip line comments from a file
#!/usr/bin/env python3
"""
Strip line comments from a file
By default, this requires whitespace to surround a comment for it to be valid.
This means that `a#a` is not a valid comment.
"""
from __future__ import annotations
@Techcable
Techcable / slowprint.py
Created May 26, 2025 03:18
Slowly print lines, for testing command line interfaces
#!/usr/bin/env python3
"""
Print lines slowly
Intended for testing command line interfaces
"""
import argparse
import itertools
import time
@Techcable
Techcable / extract_table.py
Created April 4, 2025 19:21
Parses a markdown table into a CSV file
#!/usr/bin/env -S uv run --script
# Extracts data from the first markdown table found in the input file,
# converting it into CSV
# /// script
# dependencies = [
# "marko~=2.1"
# ]
# ///
import csv
import sys
@Techcable
Techcable / makechawan.fish
Last active March 31, 2025 15:53
Build chawan browser on macOS (https://sr.ht/~bptato/chawan/)
#!/usr/bin/env fish
set --local openssl_prefix $(brew --prefix openssl)
set --local libssh_prefix $(brew --prefix libssh2)
set -gx CFLAGS "-I$openssl_prefix/include -I$libssh_prefix/include -lssl -lssh2"
set -gx LDFLAGS "-L$openssl_prefix/lib -L$libssh_prefix/lib -lssl -lssh2"
if not test -f ./nim.cfg; or not test -f ./README.md
echo "ERROR: Should be in chawan root directory" >&2;
@Techcable
Techcable / back2dir.fish
Created February 7, 2025 21:18
Return to the most recently used directory when starting the fish shell
# Return to the most recently used directory when starting fish shell
#
# Ported from this xontrib: https://github.com/anki-code/xontrib-back2dir
#
# Uses fish "universal variables" for storage
#
# TODO: Is using universal variables (as opposed to a dedicated file)
# going to slow things down or hurt SSD?
# Right before the first pompt is shown, we go back to the last directory
#!/usr/bin/env python3
# A nice little script to hash the contents of tarfiles
# Works in parallel
import shutil
import os
import re
import sys
import subprocess
from math import ceil