Skip to content

Instantly share code, notes, and snippets.

View paulz's full-sized avatar
🍐
pairing is caring

Paul Zabelin paulz

🍐
pairing is caring
View GitHub Profile
@paulz
paulz / 🍔
Last active October 9, 2017 21:26
🍔 is OK in gist but not OK in gist comments
When I try to add a comment with 🍔, I get error:
You can't comment at this time — your comment contains unicode characters above 0xffff.
{"meal":"🍔"}
@paulz
paulz / RemoveObserverSpec.swift
Created November 16, 2017 01:14
Unit Test showing that you have to called removeObserver before deinit when using .addObserver(forName:
import Quick
import Nimble
private let uniqueName = "unique name of notification"
private let testNotificationName = NSNotification.Name(uniqueName)
private var blockInvocationCounter = 0
private class Counter {
var received: Int = 0
var instances: Int = 0
@paulz
paulz / git-pre-commit
Created February 15, 2018 19:10
Rubocop modified Ruby and Rake files as Git Pre-commit Hook
FILES="$(git diff --cached --name-only --diff-filter=AMC *.rb *.rake)"
rubocop -a ${FILES}
@paulz
paulz / xcode-inherit-env.sh
Last active May 1, 2024 04:12
Allow Xcode to access shell environment variables
defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO
@paulz
paulz / README.md
Last active February 28, 2019 10:24
Symbolicate Crash Reports from Device

To symbolicate crashes happening on device for builds made in Xcode, that has not yet been uploaded through Xcode organizer.

//:configuration = Release DEBUG_INFORMATION_FORMAT = dwarf-with-dsym

  1. copy .app and .dSYM to Desktop
  2. Re-symbolicate - from right click menu on crash in Devices and Simulators

//:configuration = Debug DEBUG_INFORMATION_FORMAT = dwarf

@paulz
paulz / after aController.swift
Last active March 1, 2019 01:59
use functions for closures
import UIKit
import Siesta
class LoginOrSignupViewController: UIViewController {
@IBAction func logIn() {
let user = User(email: emailTextField.text!, password: passwordTextField.text!, name: nameTextField?.text)
api.login(user)
.onSuccess(weak(self, type(of: self).transitionToApp))
.onFailure(weak(self, type(of: self).showError))
@paulz
paulz / frequencies.swift
Created April 29, 2019 22:17
Use uniquingKeysWith function
public func frequencies(input: [String]) -> [String: Int] {
return Dictionary(input.map {($0, 1)}, uniquingKeysWith: +)
}
@paulz
paulz / ActionSpec.swift
Last active February 6, 2024 09:49
Make UIAction handler accessible for testing
import Quick
import Nimble
class ActionSpec: QuickSpec {
override func spec() {
describe("UIAction") {
it("should invoke handler") {
waitUntil { done in
let action = UIAction(title: "a title") { action in
done()
@paulz
paulz / Assert.swift
Last active November 15, 2019 23:25
Make swift assert testable
let defaultAssert = {
(_ condition: @autoclosure () -> Bool,
_ message: @autoclosure () -> String,
file: StaticString,
line: UInt) in
Swift.assert(condition(), message(), file: file, line: line)
}
var evaluateAssert: (@autoclosure () -> Bool,
@autoclosure () -> String,
_ file: StaticString,
@paulz
paulz / .bash_profile
Created December 10, 2019 20:11
Bash aliases for Xcode developer
# Xcode Dervide Data clear
alias xdd='rm -rf /tmp/DerivedData'
# WorkSpace open
alias ws='find . -name *.xcworkspace -exec open {} \;'