Skip to content

Instantly share code, notes, and snippets.

View royalicing's full-sized avatar

Patrick Smith royalicing

View GitHub Profile
@aparente
aparente / SKILL.md
Last active May 27, 2026 18:57
tufte-viz Claude Code skill — Edward Tufte data visualization principles

name: tufte-viz description: | Ideate and critique data visualizations using Edward Tufte's principles from "The Visual Display of Quantitative Information." Use this skill when: (1) Designing new data visualizations or charts (2) Critiquing or improving existing visualizations (3) Reviewing dashboards or reports for graphical integrity (4) Deciding between visualization approaches (5) Reducing chartjunk or improving data-ink ratio (6) Planning small multiples or high-density displays

@vistar941
vistar941 / ViewController.swift
Last active April 28, 2026 17:25
Work around UIButton limitations using only public APIs.
import UIKit
final class MenuControl: UIControl {
private let label: UILabel = {
let label = UILabel()
label.text = "Public API-Only Menu"
label.font = .boldSystemFont(ofSize: 15)
label.textAlignment = .center
label.textColor = .white
<!-- i have to warn you, this code SUCKS! i DO NOT recommend using this code, but you can if you want -->
<div style="width:calc(442px + 28px * 2); outline:1px solid #232323; border-radius:8px;position: absolute;top:0;left:0;translate:calc(50vw - 50%) calc(50vh - 50%); box-sizing: border-box;container-type: size;height:600px;contain:strict">
<div style="overflow: clip;contain:strict;width:100%;height:100%;position:absolute">
<div style="padding:28px;display: flex;height:100%;box-sizing:border-box;flex-direction: column;align-items: center;justify-content: center;">
<svg class="nv-block sm:nv-hidden nv-h-6 nv-w-auto" style="width:100px;margin-top:2px" viewBox="0 0 1230.574 519.774" xmlns="http://www.w3.org/2000/svg" aria-label="Cloudflare"><path d="m784.025 512.011 5.872-20.311c6.998-24.169 4.394-46.511-7.349-62.926-10.801-15.122-28.804-24.022-50.666-25.056l-414.114-5.281c-2.788-.147-5.096-1.403-6.518-3.471-1.44-2.123-1.773-4.856-.886-7.478 1.366-4.08 5.41-7.164 9.62-7.349l417.954-5.299c49.576-2.271 103.2
@Kyle-Ye
Kyle-Ye / CAHostingLayer.md
Last active May 26, 2026 06:01
Using CAHostingLayer in SwiftUI — access SwiftUI's SPI CALayer without Apple internal SDK

Using CAHostingLayer in SwiftUI

Background

SwiftUI provides more than just UIHostingController / _UIHostingView (iOS) and NSHostingController / NSHostingView (macOS) for embedding SwiftUI views into UIKit/AppKit.

Starting from iOS 18.0 / macOS 15.0, SwiftUI also offers CAHostingLayer<Content: View> — a CALayer subclass that can host SwiftUI content directly at the layer level. This API is currently marked as SPI (@_spi(ForUIKitOnly) / @_spi(ForAppKitOnly)) and is used internally by UIKit, AppKit, and WebKit.

Accessing CAHostingLayer without Apple Internal SDK

@Kyle-Ye
Kyle-Ye / disable-calayersystem-swiftui-ios26.md
Created March 8, 2026 18:12
Disabling CALayerSystem Behavior in SwiftUI on iOS 26

Disabling CALayerSystem Behavior in SwiftUI on iOS 26

Starting with iOS 26, SwiftUI's UIHostingView may use CALayer-based rendering (caLayerSystem) instead of the traditional UIKit-based rendering (uikitSystem) when certain conditions are met. This can cause unexpected changes in the view hierarchy — for example, _UIGraphicsView and CGDrawingView subviews may be replaced by plain CALayer and CGDrawingLayer sublayers.

Here are two approaches to temporarily disable this behavior in your local debug environment.

Option 1: Environment Variable

Set the environment variable SWIFTUI_DISABLE_MIXED_VIEW_HIERARCHY=1 in your scheme's Run configuration (Edit Scheme → Run → Arguments → Environment Variables).

@gingerbeardman
gingerbeardman / crt-shader.frag
Created January 5, 2026 11:56
CRT effect as fragment shader for Love2D
// Final CRT shader with all effects including curvature
uniform float scanlineIntensity; // Adjust intensity (0-1)
uniform float scanlineCount; // Number of scanlines
uniform float time; // For flicker effect
uniform float yOffset; // Vertical drift to combat moiré pattern
uniform float brightness; // Overall brightness
uniform float contrast; // Contrast adjustment
uniform float saturation; // Color saturation
uniform float bloomIntensity; // Bloom effect intensity
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef uint8_t u8;
#!/usr/bin/env bun
"use strict";
const fs = require("fs");
const { execSync } = require("child_process");
const path = require("path");
// ANSI color constants
const c = {
cy: '\033[36m', // cyan

The Ultimate Guide to Gleam's Typed Actors

How Gleam builds type-safe concurrent programming on the BEAM

The BEAM virtual machine (which runs Erlang, Elixir, and now Gleam) is renowned for its actor model concurrency. But traditionally, message passing has been untyped - any process can send any message to any other process, leading to runtime crashes when unexpected messages arrive.

Gleam changes this game entirely by building a sophisticated type-safe layer on top of BEAM's primitives. In this deep dive, we'll explore exactly how Gleam achieves compile-time type safety for concurrent programming, revealing the elegant implementation strategies that make it all work.

The Foundation: BEAM Processes and Raw Message Passing

defmodule Task do
defp await_one(tasks, timeout \\ 5_000) when is_list(tasks) do
awaiting =
Map.new(tasks, fn %Task{ref: ref, owner: owner} = task ->
if owner != self() do
raise ArgumentError, invalid_owner_error(task)
end
{ref, true}
end)