Skip to content

Instantly share code, notes, and snippets.


Daniel Beard daniel-beard

View GitHub Profile
tonyarnold / RangeReplaceableCollectionOperators.swift
Created Aug 25, 2020
Use this to add an operator to append items to sequences, ie: `collection += item`
View RangeReplaceableCollectionOperators.swift
extension RangeReplaceableCollection {
static func += (collection: inout Self, element: Element) {
static func += (collection: inout Self, element: Element?) {
if let element = element {
hfossli /
Last active Apr 8, 2021
Standard bash script format
function usage() {
if [ -n "$1" ]; then
echo -e "${RED}👉 $1${CLEAR}\n";
echo "Usage: $0 [-n number-of-people] [-s section-id] [-c cache-file]"
tkersey /
Created Feb 3, 2018 — forked from ddunbar/
Xcode new build system debugging tricks

New Build System Tricks

Command Line

# enable internal menu
defaults write ShowDVTDebugMenu -bool YES

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
ddunbar /
Last active May 6, 2021
Xcode new build system debugging tricks

New Build System Tricks

Command Line

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
# THIS DOESNT WORK YET: xcbuild openIDEConsole  # … then switch to Xcode ➡️
xcbuild showSpecs
xcbuild build <foo.pif> [—target <target>]
P1kachu / calling_printf_osx.c
Created Nov 24, 2016
Calling printf in OSX - The overkill way
View calling_printf_osx.c
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <mach-o/dyld.h>
#include <mach-o/nlist.h>
#include <mach-o/dyld_images.h>
#include <mach/mach_vm.h>
/* Dyld is the OSX Dynamic Linker
* /usr/include//mach-o/loader.h
steipete / gist:d9b44d8e9f341e81414e86d7ff8fb62d
Last active May 5, 2021
Using iOS 14 devices with Xcode 11.5 (instead of Xcode 12)
View gist:d9b44d8e9f341e81414e86d7ff8fb62d
// The trick is to link the DeviceSupport folder from the beta to the stable version.
// sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
// Support iOS 14 devices (Xcode 12.0) with Xcode 11.5:
sudo ln -s /Applications/ /Applications/
// Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
View how to resolve compiler

Xcode loads xcspec files (ascii plists) that specify everything (tools, buildphases, compilers, rules, etc) based on a set of conditions.

To evaluate these conditions you have to load these files and simulate the build process and construct your own "environment"

The target's build settings will help to resolve most of the environment variables by taking the basics from the particular platform you are using for the target (resolved from the SDKROOT value xcrun --show-sdk-platform-path --sdk)

when you load the spec of the compiler there is a key on it called "Options" which is an array of dictionaries that have

stevenp / gist:a6740694b4e23baccfab
Last active Sep 10, 2015
Disable App Transport Security in iOS 9
View gist:a6740694b4e23baccfab
Add this to the Info.plist:
dnozay /
Last active Apr 24, 2021
jenkins groovy scripts collection.
View Regex.swift
struct Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: self.options, error: nil)
init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern