Skip to content

Instantly share code, notes, and snippets.

View ctreffs's full-sized avatar
💭
🏊 🚴‍♂️ 🏃

Christian Treffs ctreffs

💭
🏊 🚴‍♂️ 🏃
View GitHub Profile
@ctreffs
ctreffs / ByteArrayEncoderDecoder.swift
Last active January 29, 2018 20:41
[Swift] Byte Array Encoder & Decoder
func encode<T>(_ value: T) throws -> [UInt8] {
var value: T = value
return withUnsafePointer(to: &value) {
let count: Int = MemoryLayout<T>.stride
return $0.withMemoryRebound(to: UInt8.self, capacity: count) {
return [UInt8](UnsafeBufferPointer(start: $0, count: count))
}
}
}
@ctreffs
ctreffs / xcode_build_settings.xcconfig
Last active May 16, 2018 14:47
Xcode 9.3 build settings & project variables
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
@ctreffs
ctreffs / anagrams.txt
Last active January 31, 2018 22:53
German anagrams - based on data from dict.cc
aachener, archaeen
aalbrut, blutaar
aalen, anale
aalgabel, elagabal
aalgang, galanga
aalkirsche, saalkirche
aalrute, laureat
aare, area
aasgeier, agerasie
aasgeruch, aschgraue
@ctreffs
ctreffs / clearPreferredWiFiNetworks.sh
Last active July 31, 2019 18:55
[macOS] Clear / cleanup preferred WiFi networks list keeping your whitelisted WiFi networks
#!/bin/bash
set -e
# networkServiceList=$(networksetup -listallnetworkservices | tail -n +2)
netserviceName="Wi-Fi"
wifiDeviceName=$( networksetup -listallhardwareports | grep -i -A 1 "${netserviceName}" | grep -v "Hardware" | awk {'print $2'} )
wifiNetworkList=$( networksetup -listpreferredwirelessnetworks "${wifiDeviceName}" | sed $'s/^\t//g' | grep -v "Preferred networks on ${wifiDeviceName}:")
### Keybase proof
I hereby claim:
* I am ctreffs on github.
* I am ctreffs (https://keybase.io/ctreffs) on keybase.
* I have a public key ASAJ3TaFSxprW0Q4Q-Fz_74myNro5TgdNACMxd64Zlq6SQo
To claim this, I am signing this object:
@ctreffs
ctreffs / bash_script_template.sh
Last active May 16, 2018 14:48
Bash Script Template
#!/usr/bin/env bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Log nicely.
log() { echo -e "\e[0;33m${1}\e[0m"; }
# Ask for the administrator password upfront.
@ctreffs
ctreffs / UIFont+Extensions.swift
Last active June 18, 2018 08:36
List Fonts by Family and Names [iOS]
extension UIFont {
class var listFontsByFamilyAndNames: [String] {
return UIFont.familyNames.map { (familyName) in
UIFont.fontNames(forFamilyName: familyName).joined(separator: ", ")
}.sorted()
}
}
@ctreffs
ctreffs / copy_appropriate_google-service-info-plist.sh
Created June 26, 2018 13:42 — forked from tylermilner/copy_appropriate_google-service-info-plist.sh
A shell script to selectively copy your GoogleService-Info.plist into your app bundle based on the current build configuration.
# Name of the resource we're selectively copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
# Get references to dev and prod versions of the GoogleService-Info.plist
# NOTE: These should only live on the file system and should NOT be part of the target (since we'll be adding them to the target manually)
GOOGLESERVICE_INFO_DEV=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Dev/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_PROD=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Prod/${GOOGLESERVICE_INFO_PLIST}
# Make sure the dev version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_DEV}"
@ctreffs
ctreffs / StreamingExample.swift
Created June 28, 2018 05:41 — forked from lucasecf/StreamingExample.swift
Example of how to use the streaming feature of the iOS MultipeerConnectivity framework
/*
For this Gist, we have two sides: sender and receiver. The same user can be a sender and a receiver, but I will separate this
two roles to be more clear.
This gist assumes thatyou already have a MCSession created, and the peers are connected,
*/
@ctreffs
ctreffs / XcodeBuildSettingsReference.md
Created August 21, 2018 14:43 — forked from NSExceptional/XcodeBuildSettingsReference.md
The Xcode Build Settings Reference in a searchable document, as of Xcode 8.3.2

Build settings reference

Active Build Action (ACTION)

A string identifying the build system action being performed.

Additional SDKs (ADDITIONAL_SDKS)

The locations of any sparse SDKs that should be layered on top of the one specified by Base SDK (SDKROOT). If more than one SDK is listed, the first one has highest precedence. Every SDK specified in this setting should be a "sparse" SDK, for example, not an SDK for an entire macOS release.

Alternate Install Group (ALTERNATE_GROUP)