Skip to content

Instantly share code, notes, and snippets.

View yhkaplan's full-sized avatar
⚙️

Joshua Kaplan yhkaplan

⚙️
View GitHub Profile
@yhkaplan
yhkaplan / get_derived_data.sh
Created September 19, 2018 11:37
Get DerivedData path
DERIVED_DATA_PATH=$(xcodebuild -showBuildSettings | grep PROJECT_TEMP_ROOT | grep -o '[a-zA-Z0-9/]*DerivedData')
@yhkaplan
yhkaplan / AutoLayoutSugar.swift
Last active January 17, 2019 10:06
AutoLayout Syntax Sugar
// Referred to the below heavily
// https://www.swiftbysundell.com/posts/building-dsls-in-swift
/* How to use:
subView.layout(on: parentView) {
$0.top <= $1.top
$0.bottom >= $1.bottom
$0.leading == $1.leading - 20.0
$0.trailing == $1.trailing + 10.0
}
*/
@yhkaplan
yhkaplan / RegexExtensions.swift
Last active January 15, 2019 07:20
Swifty wrapper for NSRegularExpression
import Foundation
struct Regex: ExpressibleByStringLiteral {
private let pattern: String
private var nsRegularExpression: NSRegularExpression? {
return try? NSRegularExpression(pattern: pattern)
}
typealias StringLiteralType = String
@yhkaplan
yhkaplan / URLSession+Codable.swift
Created January 15, 2019 06:03
Basic explainer resource for beginners
import Foundation
import PlaygroundSupport
// Model
struct Character: Decodable {
let name: String
}
// NW
// Swift safety
/// Type safety
let i: UInt8 = 1
let x: Int = 4
// Error
// let result = i*x
infix operator ???
extension Optional where Wrapped == String {
var isEmptyOrNil: Bool {
return self == nil || self == ""
}
static func ???(lhs: String?, rhs: String) -> String {
guard let lhs = lhs, lhs != "" else {
return rhs
#!/usr/bin/env sh
PLIST_BUDDY="/usr/libexec/PlistBuddy"
INFO_PLIST_PATH="app/Info.plist"
CURRENT_FULL_VERSION=$("$PLIST_BUDDY" -c "Print CFBundleVersion" "$INFO_PLIST_PATH")
CURRENT_MARKETING_VERSION=$("$PLIST_BUDDY" -c "Print CFBundleShortVersionString" "$INFO_PLIST_PATH")
ALL_INFO_PLIST_FILES=$(git grep --files-with-matches "CFBundleVersion" -- "*Info.plist")
for INFO_PLIST_FILE in $ALL_INFO_PLIST_FILES; do
@yhkaplan
yhkaplan / Podfile.rb
Created July 27, 2020 09:03
Make cocoapods static
pre_install do |installer|
installer.pod_targets.each do |pod|
if !dynamic_frameworks.include?(pod.name)
puts "Overriding the static_framework? method for #{pod.name}"
def pod.static_framework?;
true
end
end
end
end