Skip to content

Instantly share code, notes, and snippets.

Learning Combine and SwiftUI 🚜🕊️

Ben Chatelain phatblat

Learning Combine and SwiftUI 🚜🕊️
View GitHub Profile
phatblat /
Last active Jul 2, 2018 — 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 Mar 15, 2018
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 Jan 9, 2018
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
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 }
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 Oct 16, 2020
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
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
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
View UIColor+Name.patch
diff --git a/SwiftGenWMO/Base.lproj/Main.storyboard b/SwiftGenWMO/Base.lproj/Main.storyboard
index 3f93ac0..8bf89f1 100644
--- a/SwiftGenWMO/Base.lproj/Main.storyboard
+++ b/SwiftGenWMO/Base.lproj/Main.storyboard
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
+<document type="" version="3.0" toolsVersion="9059" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<deployment identifier="iOS"/>
phatblat / build_carthage_framework.rb
Last active Mar 23, 2016
Fastlane action to build and archive a framework using Carthage
View build_carthage_framework.rb
module Fastlane
module Actions
module SharedValues
class BuildCarthageFrameworkAction < Action
def"carthage build --no-skip-current")"carthage archive #{params[:framework_name]}")