Skip to content

Instantly share code, notes, and snippets.

Brennan Stehling brennanMKE

Block or report user

Report or block brennanMKE

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@brennanMKE
brennanMKE / README.md
Created Oct 15, 2019
Pull Master (or Mainline)
View README.md

Pull Master

When several Git repositories need to be updated to get the latest changes a single command which goes into each directory, checks the branch and pulls the latest changes can quickly get everything up to date quickly.

This pm command can run without any arguments and defaults to mainline but if you want to use another branch like master or development you can give that argument.

@brennanMKE
brennanMKE / README.md
Created Oct 15, 2019
Work in Progress
View README.md

Work in Progress

Git commit hooks can be slow and often get in the way when working locally with various branches which may be incomplete or experimental. Using the --no-verify switch to disable the commit hooks and allow the commit to save the selected changes speeds up development. This wip script makes it even easier to make a quick commit which can be squashed or fixed up later.

@brennanMKE
brennanMKE / DeviceToken.swift
Created Sep 25, 2019
DeviceToken Swift Playground for transforming Data into a Hex String
View DeviceToken.swift
import Foundation
struct DeviceToken {
enum Failure: Error {
case invalidHexString
}
var data: Data
var hexString: String {
let result = data.map { String(format: "%02x", $0) }.joined().uppercased()
return result
@brennanMKE
brennanMKE / README.md
Created Aug 26, 2019
Recursive Locks
View README.md

Recursive Locks

While dispatch_sync() can replace a lock, it cannot replace a recursive lock. Unlike locks, queues support both asynchronous and synchronous operations, and those operations are ordered by definition. A recursive call to dispatch_sync() causes a simple deadlock as the currently execut- ing block waits for the next block to complete, but the next block will not start until the currently running block completes.

As the dispatch framework was designed, we studied recursive locks. We

@brennanMKE
brennanMKE / README.md
Last active Aug 15, 2019
Multiple Identities for Git
View README.md

Multiple Identities for Git

Interacting with multiple Git hosts using different identities can be useful when there are many repositories in public and proprietary locations.

The includeIf option can be used as a [conditional include] for a path so that your repos in a GitHub path use your GitHub identity while other locations can use your work identity. In your ~/.gitconfig add the following section.

@brennanMKE
brennanMKE / copy-xctest.sh
Created Apr 23, 2019
Copy XCTest.framework into BUILT_PRODUCTS_DIR
View copy-xctest.sh
#!/bin/bash
set -x
if [ ${ARCHS} = "x86_64" ]; then
TARGET_PLATFORM="iPhoneSimulator"
else
TARGET_PLATFORM="iPhoneOS"
fi
@brennanMKE
brennanMKE / SwiftLint.sh
Last active Oct 9, 2018
SwiftLint script which requires a base version
View SwiftLint.sh
#!/bin/sh
BASE_VERSION=0.26.0
SWIFT_LINT_CMD=`which swiftlint`
function version_gt() { test $(printf '%s\n' "$@" | sort --version-sort | head -n 1) != "${1}"; }
if [ ! -f "${SWIFT_LINT_CMD}" ]; then
echo "warning: SwiftLint not installed. Please install using brew. See: https://github.com/realm/SwiftLint"
else
@brennanMKE
brennanMKE / README.md
Last active Oct 4, 2018
Synchronized Map and Array
View README.md

Synchronized Map and Array

Dispatch is often used to protect a property when operating with concurrent behavior. A DispatchQueue can be used to ensure that a property is protected by using the sync function as demonstrated in the sample code below.

@brennanMKE
brennanMKE / Bytes.swift
Created Sep 10, 2018
Bytes formatted for binary or hex strings.
View Bytes.swift
//: [Previous](@previous)
import Foundation
struct Bytes {
enum Size: Int {
case eight = 8
case sixteen = 16
case thirtyTwo = 32
case sixtyFour = 64
@brennanMKE
brennanMKE / check-binaries.sh
Created Aug 29, 2018
Check binaries to see what is what in a built products directory
View check-binaries.sh
#!/bin/sh
set -e
find . -type d -name \*.framework | while IFS= read -r FRAMEWORK; do
FRAMEWORK_NAME=$(basename "$FRAMEWORK")
ROOT_NAME="${FRAMEWORK_NAME%.*}"
BINARY_PATH="${FRAMEWORK_NAME}/${ROOT_NAME}"
echo ${BINARY_PATH}
lipo -info ${BINARY_PATH}
You can’t perform that action at this time.