Skip to content

Instantly share code, notes, and snippets.

View perlguy99's full-sized avatar

Brent Michalski perlguy99

  • Senior iOS Engineer
  • St. Louis, MO
View GitHub Profile
@perlguy99
perlguy99 / Xcode Run Script
Created January 3, 2017 20:28
Xcode Sign All Embedded Frameworks, works with projects that have spaces in them
OLSIFS=$IFS
IFS=$'\n'
for f in $(find $CODESIGNING_FOLDER_PATH -name '*.framework')
do
codesign --force --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --preserve-metadata=identifier,entitlements --timestamp=none "$f"
done
IFS=$OLDIFS
String(data: dataVar, encoding: .utf8)
@perlguy99
perlguy99 / UI Main Thread
Created August 7, 2017 15:49
Operate on main thread
// Usage:
// UI {
// Anything in here will execute on the main thread
// }
func UI(_ block: @escaping ()->Void) {
DispatchQueue.main.async(execute: block)
}
@perlguy99
perlguy99 / BG Background Execution
Created August 7, 2017 15:49
BG Background Execution
// Usage:
// BG {
// Anything in here will execute in the background
// }
func BG(_ block: @escaping ()->Void) {
DispatchQueue.global(qos: .default).async(execute: block)
}
#define SCREEN_WIDTH ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height)
#define SCREEN_HEIGHT ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)) ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width)
@perlguy99
perlguy99 / notificationTriggered.swift
Created December 23, 2018 02:19
Terrible, hacky notificationTriggered handler
@objc func notificationTriggered(_ notification: Notification) {
if let userInfo = notification.userInfo {
if let name = userInfo["name"] as? String {
if name == "CaretBlink" {
return
}
}
}
@perlguy99
perlguy99 / UIColor+hex.swift
Created January 8, 2019 16:44
UIColor extension for HEX values
extension UIColor {
convenience init?(hexString: String) {
var chars = Array(hexString.hasPrefix("#") ? hexString.dropFirst() : hexString[...])
let red, green, blue, alpha: CGFloat
switch chars.count {
case 3:
chars = chars.flatMap { [$0, $0] }
fallthrough
case 6:
chars = ["F","F"] + chars
@perlguy99
perlguy99 / debugDescription.swift
Created January 9, 2019 21:52
CustomDebugStringConvertible extension
extension CustomDebugStringConvertible {
var debugDescription: String {
var returnString = lineWith(separator: "+", title: " \(type(of: self)) ")
let selfMirror = Mirror(reflecting: self)
for child in selfMirror.children {
if let propertyName = child.label {
returnString += "\(propertyName): \(child.value)\n"
}
//
// IconTitleTextView.swift
//
// Created by Brent Michalski on 12/23/18.
// Copyright © 2018 Perlguy, Inc. All rights reserved.
//
// THIS CUSTOM CLASS PROPERLY LOADS FROM A STORYBOARD!!!
import UIKit
@perlguy99
perlguy99 / pod.repo.push
Created January 16, 2019 01:47
Pod Repo Push
pod repo push PodSpecs NewPodFile.podspec --allow-warnings