Skip to content

Instantly share code, notes, and snippets.

View JetForMe's full-sized avatar

Rick M JetForMe

View GitHub Profile
@JetForMe
JetForMe / OptionalBindableMess.swift
Last active March 21, 2024 21:24
Dealing with @bindable Being Non-Optional
/**
The idea is to be able to invoke `ReminderDetailsWrapper` (forgive the naming, it’s
the result of the organic growth of this thing) with either the ID of an object to edit,
or nil, in which case it will create a new one. In both cases, it has to create a new
`ModelContext` on which to make the changes, and it only saves if the user taps the
“Save” button.
Some of thie could be improved if things could be loaded in `init()`, but that gets
called far too often as SwiftUI rebuilds the view hierarchy.
*/
import AsyncAlgorithms
import SwiftUI
/**
This example shows one possible way to debounce changes from a user typing into a field.
*/
struct
DebouncedTextView : View
{
@JetForMe
JetForMe / ROM.ino
Created April 23, 2023 05:11
Arduino 6502 ROM Emulator
const char sAddrBus[] = { 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 };
const char sDataBus[] = { 39, 41, 43, 45, 47, 49, 51, 53 };
#define qPinClock 2
#define qPinRW 3
const uint8_t sROM[] =
{
//00 0xFEFF
@JetForMe
JetForMe / RoutesBuilderExtension.swift
Last active January 18, 2023 11:45
RoutesBuilder extension to make it easy to return response status along with Content DTOs
import Vapor
/**
Convenience extensions to allow writing route handlers that return a tuple
of `(HTTPStatus, Content)`, so it’s easier to control the response status.
*/
@JetForMe
JetForMe / DynamicallyConfigurableLogHandler.swift
Created December 29, 2022 06:25
DynamicallyConfigurableLogHandler.swift
//
// DynamicallyConfigurableLogHandler.swift
//
//
// Created by Rick Mann on 2022-08-04.
//
import Logging
import Foundation
@JetForMe
JetForMe / make-inst-rom.swift
Created December 10, 2022 15:10
Ben Eater CPU Microcode ROM Generator
#!/usr/bin/env swift sh
/**
This Swift script requires that you have [swift-sh](https://github.com/mxcl/swift-sh) installed:
```
$ brew install swift-sh
```
My CPU differs from Bean Eater’s, in that I program two different ROMs,
struct CurveEditor: View {
var body: some View
{
GeometryReader { geom in
let width = geom.width // Make the rest of the code a bit cleaner
let height = geom. height
Path { path in
path.move(to: CGPoint(x: 10.0, y: 10.0))
path.addLine(to: CGPoint(x: geom.size.width - 10.0, y: geom.size.height - 10.0))
@JetForMe
JetForMe / optimized.asm
Last active April 28, 2021 07:13
SCNQuaternion Test
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 11, 0 sdk_version 11, 3
.globl _main
.p2align 4, 0x90
_main:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
@JetForMe
JetForMe / TestSpecs.md
Last active January 7, 2021 22:12
LA-area COVID test specs

I’ve been getting periodic current-infection COVID tests at Curative sites in Los Angeles for several months now. Today I learned that their test has poor specificity for asymptomatic individuals. I also took their new antibody test.

The new antibody test was developed in a joint effort between Curative and OraSure.1

Test Sensitivity/+Agreement Specificity/-Agreement
Curative RT-PCR2 (asymptomatic) 0/3 82.4%
Curative/OraSure COVID-19 Antibody 90.9% 100%
@JetForMe
JetForMe / Example.swift
Created November 15, 2020 00:55
Home automation DSL in Swift
/**
ExampleAutomationScript.swift
ZWaveTest
Created by Rick Mann on 2020-11-11.
Copyright © 2020 Latency: Zero, LLC. All rights reserved.
This file was born as a scratchpad to help me think about what I wanted this
automation language to look like.
*/