Skip to content

Instantly share code, notes, and snippets.

View garretcarrot's full-sized avatar

Garret Thompson garretcarrot

View GitHub Profile
@rygorous
rygorous / main.rs
Created March 2, 2025 04:42
Base64 fixed point test
use bit_set::BitSet;
use std::mem;
// Vanilla RFC 4648
const ALPHABET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
// URL-safe RFC 4648
//const ALPHABET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
const COUNT: usize = 1usize << 24; // 3 bytes worth suffices for this test
fn lookup(index: u32) -> u32 {
//
// OCXML.swift
// Created by Marco Arment on 9/23/24.
//
// Released into the public domain. Do whatever you'd like with this.
// No guarantees that it'll do anything, or do it correctly. Good luck!
//
import Foundation
@krzyzanowskim
krzyzanowskim / .gitconfig
Last active February 4, 2025 21:45
commit-ai
[alias]
# need llm CLI: https://llm.datasette.io/en/stable/
# based on https://gist.github.com/karpathy/1dd0294ef9567971c1e4348a90d69285?permalink_comment_id=5167582#gistcomment-5167582
commit-ai = "!f() { if [ -n \"$(git diff --cached)\" ]; then git commit -m \"$(git diff --cached | llm -m '4o-mini' 'Below is a diff of all staged changes, coming from the command:\\n```\\ngit diff --cached\\n```\\nPlease generate a concise, two-sentence, maximum 100 characteres commit message for these changes. Do not mention project name.')\"; else echo 'No changes to commit'; fi }; f"
@dhh
dhh / linux-setup.sh
Last active March 7, 2025 13:40
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
@JJTech0130
JJTech0130 / psem.swift
Last active February 24, 2024 14:25
Pure Swift raw syscall to retrieve the name of a semaphore
import Foundation
struct psem_fdinfo {
struct proc_fileinfo {
var fi_openflags: UInt32
var fi_status: UInt32
var fi_offset: Int64
var fi_type: Int32
var fi_guardflags: UInt32
}
@graydon
graydon / move.rs
Created January 18, 2024 23:07
Ownership passing vs. borrowing
// This is just an elaboration of an off-hand toot I made earlier today
// concerning a coding pattern I find myself doing whenever possible: passing
// and returning owned values instead of borrowing references.
//
// I find it works well for long-lived values especially since the resulting
// composite objects have no lifetime qualifiers, so I don't have to plumb
// lifetimes through to all the code that uses them.
// Assumption: assume we have a few objects like this: a network connection, a
// database, some commands, etc. and we want to make a session type that uses
@david-crespo
david-crespo / ts-release-highlights.md
Last active May 14, 2023 21:03
TypeScript release highlights thru 5.0

TypeScript release highlights

These aren't meant to be comprehensive. They're just the features that most interest me. CFA = control-flow analysis.

1.4: union types and better inference on generics using the union type

1.6: JSX, intersection types, generic type aliases

1.8: type params referring to other type params, string literal types

@AlecSchneider
AlecSchneider / python_on_iphone.sh
Last active November 18, 2024 16:18
How to install apk and Python on your iPhone using the iSH Shell
cd
# you can do this all in one command
wget -qO- http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86/apk-tools-static-2.10.5-r1.apk | tar -xz sbin/apk.static && ./sbin/apk.static add apk-tools && rm sbin/apk.static
apk add python3
@ourownstory
ourownstory / encrypted_dual_boot_xps_17.md
Last active October 23, 2024 14:32
Encrypted dual boot setup for Pop!_OS and Windows 10 using LUKS and Bitlocker on Dell XPS 17 9700

Encrypted dual boot setup with Pop!_OS and Windows 10

How to guide, using LUKS and Bitlocker on Dell XPS 17 9700

This guide is for those who want to use their XPS 17 in dual boot with their (preinstalled) Windows 10 and a new Pop!_OS installation, without giving up Bitlocker Encryption in Windows nor LUKS encryption in Linux.

The only guides that I could find were for Ubuntu, which it should be identical to, but I found the ommission of a few steps to resolve issues that I encountered in my first install attempt. Hoping to save you some trouble, I am sharing the steps that worked for me, linking the original guides that I found useful.

1. Preparation

  • 1.1 Of course: Backup all your data! You always do this when people tell you to, right? Maybe this time better be safe than sorry.
  • 1.2 Safely note your Bitlocker recovery key somewhere off your XPS. Where to find it
@marcoarment
marcoarment / apns_jwt_token.php
Last active January 8, 2025 14:19
Generate ES256 JWT tokens for Apple Push Notification Service (APNS) in PHP
<?php
function base64url_encode($binary_data) { return strtr(rtrim(base64_encode($binary_data), '='), '+/', '-_'); }
function apns_jwt_token($team_id, $key_id, $private_key_pem_str)
{
if (! function_exists('openssl_get_md_methods') || ! in_array('sha256', openssl_get_md_methods())) throw new Exception('Requires openssl with sha256 support');
$private_key = openssl_pkey_get_private($private_key_pem_str);
if (! $private_key) throw new Exception('Cannot decode private key');