Skip to content

Instantly share code, notes, and snippets.

View codeactual's full-sized avatar

David Smith codeactual

  • Found Apparatus
  • Portland, OR
View GitHub Profile
@codeactual
codeactual / color256.md
Created February 23, 2026 16:07 — forked from jake-stewart/color256.md
Terminals should generate the 256-color palette

Terminals should generate the 256-color palette from the user's base16 theme.

If you've spent much time in the terminal, you've probably set a custom base16 theme. They work well. You define a handful of colors in one place and all your programs use them.

The drawback is that 16 colors is limiting. Complex and color-heavy programs struggle with such a small palette.

@codeactual
codeactual / detect-256-theme.py
Created February 23, 2026 16:07 — forked from jake-stewart/detect-256-theme.py
Detect and handle 256-color themes
#!/usr/bin/env python3
"""
Detects whether the terminal is using a light or dark theme and automatically
adjusts 256-color palette indices so that colors render consistently regardless
of the active theme. This is especially useful when a terminal (e.g. Ghostty)
generates its 256-color palette to match the current theme — or when it doesn't,
and we need to compensate by flipping the indices ourselves.
"""
import os
@codeactual
codeactual / video_noob_guide.md
Created January 4, 2026 23:56 — forked from arch1t3cht/video_noob_guide.md
What you NEED to know before touching a video file

What you NEED to Know Before Touching a Video File

Hanging out in subtitling and video re-editing communities, I see my fair share of novice video editors and video encoders, and see plenty of them make the classic beginner mistakes when it comes to working with videos. A man can only read "Use Handbrake to convert your mkv to an mp4 :)" so many times before losing it, so I am writing this article to channel the resulting psychic damage into something productive.

If you are new to working with videos (or, let's face it, even if you aren't), please read through this guide to avoid making mistakes that can cost you lots of computing power, storage space, or video quality.

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

struct OverflowLayout: Layout {
var spacing = CGFloat(10)
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
let containerWidth = proposal.replacingUnspecifiedDimensions().width
let sizes = subviews.map { $0.sizeThatFits(.unspecified) }
return layout(sizes: sizes, containerWidth: containerWidth).size
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
@codeactual
codeactual / archive-env.log
Created June 3, 2023 07:53 — forked from uxduck/archive-env.log
XCode environment variables available during Archiving
ACTION=install
ADDITIONAL_SDKS=
AD_HOC_CODE_SIGNING_ALLOWED=YES
ALL_OTHER_LDFLAGS=' '
ALL_OTHER_LIBTOOLFLAGS=' '
ALTERNATE_GROUP=staff
ALTERNATE_LINKER=
ALTERNATE_MODE=u+w,go-w,a+rX
ALTERNATE_OWNER=username
ALTERNATE_PERMISSIONS_FILES=
@codeactual
codeactual / sqlite_random_sample.sql
Created February 27, 2023 22:34 — forked from swayson/sqlite_random_sample.sql
Efficient way to do random sampling in SQLite.
SELECT * FROM table
WHERE _ROWID_ >= (abs(random()) % (SELECT max(_ROWID_) FROM table))
LIMIT 1
//
// SFSymbolImage.swift
// SFSymbolVariableValueAnimationWrong
//
// Created by Matthew Young on 12/22/22.
//
import SwiftUI
struct AnimatableVariableValueModifier: Animatable, ViewModifier {
@codeactual
codeactual / AVPlayer+Scrubbing.swift
Created November 15, 2022 19:27 — forked from shaps80/AVPlayer+Scrubbing.swift
Enables smooth frame-by-frame scrubbing (in both directions) – similar to Apple's applications.
public enum Direction {
case forward
case backward
}
internal var player: AVPlayer?
private var isSeekInProgress = false
private var chaseTime = kCMTimeZero
private var preferredFrameRate: Float = 23.98
@codeactual
codeactual / UIScrollViewWrapper.swift
Created November 11, 2022 20:32 — forked from timothycosta/UIScrollViewWrapper.swift
UIScrollView wrapped for SwiftUI
//
// UIScrollViewWrapper.swift
// lingq-5
//
// Created by Timothy Costa on 2019/07/05.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import SwiftUI