Skip to content

Instantly share code, notes, and snippets.


Andrew Crookston acrookston

Block or report user

Report or block acrookston

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
acrookston /
Last active Oct 19, 2019
Xcode pre-action to build custom Info.plist

Automatic build versions from git in Xcode (and other goodies)

Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.

1. Xcode Scheme pre-action

Edit Xcode Scheme and add a pre-action script. Copy the contents of into the pre-action script box.

View ImageZoom.swift
// The image is originally animated on to the view controller then added to the scroll view.
// So, there might be some animation residue in here.
// Class needs: <UIScrollViewDelegate>
func viewDidLoad() {
let width = UIScreen.mainScreen().bounds.size.width
let aspect: CGFloat = width / shotWidth
var frame = CGRectMake(0, 0, shotWidth * aspect, shotHeight * aspect)
self.scrollView = UIScrollView(frame: frame)
acrookston / NSRegularExpression.swift
Last active Apr 27, 2019
trim, strip and split, regex for Swift String
View NSRegularExpression.swift
extension NSRegularExpression {
convenience init(substrings: [String], options: NSRegularExpression.Options) throws {
let escapedSubstrings: [String] =
let pattern: String = escapedSubstrings.joined(separator: "|")
try self.init(pattern: pattern, options: options)
convenience init?(with pattern: String, options: NSRegularExpression.Options = []) {
do {
try self.init(pattern: pattern, options: options)
acrookston / draft.swift
Last active Jan 23, 2019
Exploring view/controller state with Loading / Content / Error (LCE)
View draft.swift
/// ContentLoader is a lightweight state manager for loading and displaying content and/or errors.
/// It allows you to repeatedly make requests and display new content or cached content in the event of an error.
/// Commonly known as RemoteData or LCE (Loading / Content / Error).
/// Inspired by
final class ContentLoader<T> {
init() { }
@discardableResult func loader(_ loader: (() -> Void)?) -> ContentLoader<T> {
self.loader = loader
acrookston / notes migration.scpt
Created Jan 10, 2019
Apple Notes to Evernote migration import/export script
View notes migration.scpt
# Thanks to:
# Open "Script Editor" application, paste and run.
tell application "Notes"
set theMessages to every note
repeat with thisMessage in theMessages
set myTitle to the name of thisMessage
acrookston / adb-all
Last active Aug 25, 2018
Script to execute an adb command on all connected devices. eg: adb-all uninstall com.example.test
View adb-all
DEVICES=`adb devices | tail -n +2 | cut -f1`
RUN="adb -s $DEVICE $@"
echo $RUN
acrookston / proc_mem_pid
Last active Jun 28, 2018
Munin plugin for monitoring memory usage based on process id's
View proc_mem_pid
# (c) 2015, Andrew Crookston <>
# Licence: GPLv2
# Configure it by using the pidfiles env. Format: name:pidfile name:pidfile. e.g.:
# [proc_mem_pid]
# env.pidfiles munin-node:/var/run/munin/
View String+Extensions.swift
extension String {
func localized(_ args: CVarArg...) -> String {
return String(format: NSLocalizedString(self, comment: ""), arguments: args)
let format = NSLocalizedString("Hello %@", comment: "")
print(String(format: format, "World"))
You can’t perform that action at this time.