Skip to content

Instantly share code, notes, and snippets.

View phatblat's full-sized avatar

Ben Chatelain phatblat

View GitHub Profile
phatblat / simulating-joins.swift
Created June 22, 2023 21:10 — forked from mbalex99/simulating-joins.swift
How to Do SQL-like JOINs in Ditto
View simulating-joins.swift
class DittoManager {
let ditto: Ditto
static let shared = DittoManager()
init() {
ditto = Ditto(identity: .onlinePlayground(appID: "e23ffe6b-70d1-4246-83a8-94cbd7a79a8d", token: "f058ac2a-4576-4af1-96f2-c4788d848cf8"))
try! ditto.startSync()
phatblat /
Last active August 1, 2022 16:13
Make Automatic Variables Cheatsheet

Make Automatic Variables Cheatsheet

I can never remember all of the automatic variables that can be used in a Makefile so here is a table of them.

Variable Description
$@ File name of the target of the rule
$% Target member name, when the target is an archive member
$< Name of the first prerequisite
phatblat /
Last active July 2, 2018 01:58 — forked from arobb/
Install macOS High Sierra in VirtualBox on macOS host

Step 1 - Create a bootable macOS High Sierra ISO

hdiutil attach Downloads/Install\ macOS\ High\ -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o Downloads/HighSierra.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach Downloads/HighSierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
asr restore -source Downloads/Install\ macOS\ High\ -target /Volumes/install_build -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -rp Downloads/Install\ macOS\ High\ /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
phatblat /
Created March 15, 2018 21:38
Renames a set of groovy files to kotlin, preserving folder hierarchy
for file in **/*.groovy
mv $file (dirname $file)/(basename $file groovy)kt
phatblat / homebrew.mxcl.artifactory.plist
Created January 9, 2018 16:52
Custom Artifactory launchctl plist
View homebrew.mxcl.artifactory.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
phatblat / SchwartzianTransform.swift
Last active May 8, 2016 06:13
An example of the Schwartzian Transform in Swift
View SchwartzianTransform.swift
// Schwartzian Transform
let list = ["a", "aa", "aaaa"]
// Create tuples with the attribute to sort on in the 2nd position
let sorted = { ($0, Int($0.characters.count)) }
.sort { $0.1 > $1.1 }
.map { $0.0 }
phatblat / AppDelegateTests.m
Created May 6, 2016 19:26
This is cheating
View AppDelegateTests.m
- (void)testAppDelegate {
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate applicationWillEnterForeground:[UIApplication sharedApplication]];
[appDelegate applicationDidBecomeActive:[UIApplication sharedApplication]];
[appDelegate applicationWillTerminate:[UIApplication sharedApplication]];
[appDelegate applicationDidEnterBackground:[UIApplication sharedApplication]];
[appDelegate applicationWillResignActive:[UIApplication sharedApplication]];
BOOL output = [appDelegate application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:[NSDictionary new]];
XCTAssertTrue(output,@"is not true");
phatblat / AppDelegate.swift
Last active May 3, 2023 23:34
Example of creating HKObserverQuery and enabling background delivery for multiple HKObjectType
View AppDelegate.swift
final class AppDelegate: UIResponder, UIApplicationDelegate {
let healthKitManager = HealthKitManager()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if onboardingComplete {
healthKitManager.requestAccessWithCompletion() { success, error in
if success { print("HealthKit access granted") }
else { print("Error requesting access to HealthKit: \(error)") }
phatblat / create_branch.rb
Created May 4, 2016 17:42
Script for creating a matching topic branch in each of repos in the current directory
View create_branch.rb
#!/usr/bin/env ruby
# create_branch.rb
ARGV.each do|a|
puts "Argument: #{a}"
phatblat / SpecFunctions.swift
Last active May 29, 2016 14:46
Swift 2.2 curried functions for asserting IB outlets and actions are wired up correctly.
View SpecFunctions.swift
// SpecFunctions.swift
// Created by Ben Chatelain on 6/6/15.
// Copyright (c) 2015-2016 Ben Chatelain.
// 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
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell