Skip to content

Instantly share code, notes, and snippets.

@71
71 / z85t.ts
Created July 5, 2026 06:53
Z85t (Z85 with truncated tail) in TypeScript.
// Copyright (c) 2026 Grégoire Geis
// SPDX-License-Identifier: MPL-2.0
/**
* Encodes a byte buffer to [Z85t](#z85t). Use {@linkcode decodeZ85t()} to get your `buffer` back.
*
* @param buffer A byte array; the only requirement is that it supports `length` and indexing, so
* both plain number arrays and {@linkcode Uint8Array} will work. Every value is assumed to be a
* value between 0 and 255 (included).
*
@71
71 / z85m.ts
Last active July 4, 2026 08:22
Z85m (https://alecmuffett.com/article/14547) implementation in TypeScript
// -------------------------------------------------------------------------------------------------
// MARK: Encode
/**
* Encodes a byte buffer to [Z85](https://rfc.zeromq.org/spec/32) with
* [Z85m padding](https://alecmuffett.com/article/14547).
*
* ### Examples
*
* ```ts
@71
71 / get.sh
Last active July 3, 2026 02:41
Fish completions for Bazel
#!/bin/sh
# Rather than building all of Bazel just to get completions as recommended by
# https://github.com/bazelbuild/bazel/blob/master/scripts/fish/README.md, this
# script directly uses the existing Bazel executable to generate completions.
uv run \
--with absl-py==1.3.0 \
https://github.com/bazelbuild/bazel/raw/refs/heads/master/scripts/generate_fish_completion.py \
--bazel=$(which bazel) \
--output=$HOME/.config/fish/completions/bazel.fish
@71
71 / KoreanSyllable.swift
Created September 13, 2025 07:20
(Not tested)
// Raw translation of
// https://github.com/71/study-korean/blob/c4f3de22cd433c045458198956031f6edbb54f13/app/src/utils/korean.ts
/// A Korean syllable.
public struct KoreanSyllable: CustomStringConvertible {
public let initialJamo: UnicodeScalar
public let medialJamo: UnicodeScalar
public let finalJamo: UnicodeScalar?
/// Converts a Korean syllable such as 김 to its jamo ㄱㅣㅁ.

Move .h files before .cpp files in GitHub PR reviews (https://github.com/71/repo/pull/1/files).

javascript:(function()%7B(()%20%3D%3E%20%7B%0A%20%20const%20showBefore%20%3D%20%5B%0A%20%20%20%20%5B%2F%5C.(h%7Chh%7Chpp%7Ch%5C%2B%5C%2B)%24%2F%2C%20%2F%5C.(c%7Ccc%7Ccpp%7Cc%5C%2B%5C%2B)%24%2F%5D%2C%0A%20%20%5D%3B%0A%20%20const%20maybeMoveBefore%20%3D%20(li1%2C%20li2%2C%20getPath)%20%3D%3E%20%7B%0A%20%20%20%20let%20path1%2C%20path2%2C%20base1%2C%20base2%3B%0A%20%20%20%20if%20(!(path1%20%3D%20getPath(li1))%20%7C%7C%20!(path2%20%3D%20getPath(li2)))%20return%3B%0A%0A%20%20%20%20for%20(const%20%5Bpattern1%2C%20pattern2%5D%20of%20showBefore)%20%7B%0A%20%20%20%20%20%20if%20((base1%20%3D%20path1.replace(pattern1%2C%20%22%22))%20!%3D%3D%20path1%20%26%26%0A%20%20%20%20%20%20%20%20%20%20(base2%20%3D%20path2.replace(pattern2%2C%20%22%22))%20!%3D%3D%20path2%20%26%26%0A%20%20%20%20%20%20%20%20%20%20base1%20%3D%3D%3D%20base2)%20%7B%0A%20%20%20%20%20%20%20%20return%20li2.before(li1)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%2
@71
71 / cpp-include-guard.code-snippets
Created October 16, 2023 14:08
C++ include guard VS Code snippet: replace special characters with _, make upper case
{
"New C++ header": {
"prefix": "newh",
"body": [
// VS Code snippets do not support recursive replacements so we must be
// creative: replace segments like `foo/`, `bar.` and `h<eos>` to `FOO_`,
// `BAR_` and `H_` such that `foo/bar.h` becomes `FOO_BAR_H_`.
"#ifndef PROJECT_${RELATIVE_FILEPATH/(\\w+)(?:\\.|\\/|$)/${1:/upcase}_/g}",
"#define PROJECT_${RELATIVE_FILEPATH/(\\w+)(?:\\.|\\/|$)/${1:/upcase}_/g}",
@71
71 / cgo.nu
Created August 25, 2023 09:00
`git checkout $branch`, but handles files that are assumed not to have changed.
# use cgo.nu
export def main [branch: string] {
let result = (do { git checkout $branch } | complete)
let stderr = $result.stderr
if $result.exit_code == 1 or ($stderr | str contains 'Your local changes to the following files would be overwritten by checkout') {
let files_to_save = ($stderr | rg '^\s+(.+)$' -r '$1' | lines)
let tmp_dir = (mktemp -d)
@71
71 / jj-completions.nu
Created May 1, 2023 10:15
Jujutsu completions for Nushell
# Usage:
# use jj-completions.nu *
# Jujutsu (An experimental VCS)
export extern jj [
--repository(-R): string # Path to repository to operate on
--ignore-working-copy # Don't snapshot the working copy, and don't update it
--at-operation: string # Operation to load the repo at
--at-op: string # Operation to load the repo at
--verbose(-v) # Enable verbose logging
/*
* Copyright (c) 2020 The ZMK Contributors
* Copyright (c) 2022 Innaworks Development Limited, trading as MoErgo
*
* SPDX-License-Identifier: MIT
*/
/* THIS FILE WAS GENERATED BY GLOVE80 LAYOUT EDITOR
@71
71 / OpenInSplitScreen.kt
Created November 27, 2022 15:43
Snippet to show a text box that, when long-pressed, allows Chrome to be dropped into a split-screen.
// Inspired by Launcher3:
// https://cs.android.com/android/platform/superproject/+/35157974d49e70f03687edb9408e5897d04ff845:packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java;l=293
// Jetpack Compose view with interoperability:
// https://developer.android.com/jetpack/compose/interop/interop-apis
AndroidView(factory = { context ->
TextView(context).apply {
text = "Drag me!"
// Drag and drop listener; see: