Skip to content

Instantly share code, notes, and snippets.

View hboon's full-sized avatar
Indie hacking

Hwee-Boon Yar hboon

Indie hacking
View GitHub Profile
@hboon
hboon / swift-testing-playbook.md
Created June 8, 2025 00:58 — forked from steipete/swift-testing-playbook.md
The Ultimate Swift Testing Playbook (feed it your agents for better tests!)

The Ultimate Swift Testing Playbook (2024 WWDC Edition, expanded with Apple docs from June 2025)

Updated with info from https://developer.apple.com/documentation/testing fetched via Firecrawl on June 7, 2025.

See also my blog: See also my blog post: https://steipete.me/posts/2025/migrating-700-tests-to-swift-testing

A hands-on, comprehensive guide for migrating from XCTest to Swift Testing and mastering the new framework. This playbook integrates the latest patterns and best practices from WWDC 2024 and official Apple documentation to make your tests more powerful, expressive, and maintainable.


1. Migration & Tooling Baseline

@hboon
hboon / claude_dr_prompt.md
Created June 7, 2025 23:45 — forked from XInTheDark/claude_dr_prompt.md
Custom Deep Research prompt for Claude

Notes

  • MCP servers enabled: Brave Search, Fetch, Puppeteer (optional).
  • Recommended way to use it: create a project "Deep Research" and add the prompt as custom instructions.
  • Recommended model: Sonnet 4 with Thinking. Sonnet vs Opus does not make much difference from experience.
  • (As of the time of writing,) Do not enable Claude's built-in web search feature!
    • I've compared the two versions and the quality difference is significant.
    • It seems that the built-in system prompt that gets enabled, is terrible for deep research. A few examples: It explicitly limits Claude to only running one or a few searches in most cases; it contains numerous instructions regarding never quoting directly,
@hboon
hboon / diffLineWithNext.lua
Last active October 11, 2023 03:56
Handy Lua function to diff current line and the next
--Modified from https://stackoverflow.com/a/5519588
function diffLineWithNext()
local f1 = vim.fn.tempname()
local f2 = vim.fn.tempname()
vim.api.nvim_command(".w " .. f1)
vim.api.nvim_command("+1 w " .. f2)
vim.api.nvim_command("tabedit " .. f1)
vim.api.nvim_command("hor diffsplit " .. f2)
@hboon
hboon / pr.fish
Created August 31, 2023 11:12
Fish shell function to search for a commit on (tmux) screen, generate a branch name and run `gco -b <new-branch> <hash>`
#Use this to do `gco -b <branch> <commit>`
function pr
set --local hash (gcommit)
#echo "in our pr: $hash"
set --local msg (git show -s --format=%B $hash | head -1)
#echo "in our pr: $msg"
set --local branch (string lower $msg | string replace -a -r "[ /#]" "-" | string replace -a -r "[\(\)\.\[\]'`\":]" "")
#echo "in our pr: $branch"
echo "Running: git checkout -b $branch $hash"
git checkout -b $branch $hash
@hboon
hboon / openurls.rb
Created July 11, 2023 00:22
Opens URLs embedded in STDIN (so it's useful in vim by selecting text and running it)
#!/usr/bin/env ruby
#Opens URLs embedded in STDIN (so it's useful in vim by selecting text and running it)
require 'uri'
input = $stdin.read.split("\n")
urls = input.map do |line|
URI.extract(line, ['http', 'https'])
@hboon
hboon / errors.swift
Last active March 20, 2023 02:21
Implementing types that conform to LocalizedError in Swift
//Proper way to implement error types. Implement `errorDescription`, not `localizedDescription` and the global handler `getErrorMessage(error: Error)` is easy to implement, not need a stupid switch case
//Key is implement `errorDescription` instead of `localizedDescription` and must not implement `localizedDescription` at all
import Foundation
struct E1: LocalizedError {
var errorDescription: String? {
return "E1's errorDescription"
}
}
@hboon
hboon / boilerplate.swift
Created December 28, 2022 03:49 — forked from chriseidhof/boilerplate.swift
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@hboon
hboon / GuardURLProtocol.swift
Created October 14, 2022 07:32 — forked from brunophilipe/GuardURLProtocol.swift
GuardURLProtocol class to monitor all connections initiated by app
//
// GuardURLProtocol.swift
// URLProtocol
//
// Created by Bruno Philipe on 16/2/17.
// Copyright © 2017 Bruno Philipe. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
exec 1>&2
@hboon
hboon / code.markdown
Last active April 11, 2020 05:47
self when initialising property with function, inheriting from NSObject

Found a bug in my code because of something very subtle:

class C: NSObject {
	var foo: String = {
		NSLog("non-lazy self: \(self)")
		return ""
	}()
	lazy var bar: String = {
 NSLog("lazy self: \(self)")