let docDirPath =
NSSearchPathForDirectoriesInDomains(.documentDirectory,
.userDomainMask, true).first
print(docDirPath)
let docDirUrl =
FileManager.default.urls(for: .documentDirectory,
in: .userDomainMask).first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var backgroundColor: [UInt8] = [0, 0, 0, 0] | |
| let GaussianBlurKernel: [Int16] = | |
| [ 1, 4, 6, 4, 1, | |
| 4, 16, 24, 16, 4, | |
| 6, 24, 36, 24, 6, | |
| 4, 16, 24, 16, 4, | |
| 1, 4, 6, 4, 1 | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Accelerate | |
| import UIKit | |
| public extension UIImage { | |
| public func applyLightEffect() -> UIImage? { | |
| return applyBlur(radius: 30, tintColor: UIColor(white: 1, alpha: 0.3)) | |
| } | |
| public func applyExtraLightEffect() -> UIImage? { | |
| return applyBlur(radius: 20, tintColor: UIColor(white: 0.97, alpha: 0.82)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Assumes ARGB8888 | |
| CGImageRef CGImageCreateBlurredImage(CGImageRef inImage, NSUInteger blurRadius) | |
| { | |
| if (!inImage) { return NULL; } | |
| uint32_t radius = (blurRadius % 2) ? (uint32_t)blurRadius : (uint32_t)++blurRadius; | |
| vImage_Error error; | |
| vImage_CGImageFormat imageFormat = {(uint32_t)CGImageGetBitsPerComponent(inImage), (uint32_t)CGImageGetBitsPerPixel(inImage), CGImageGetColorSpace(inImage), CGImageGetBitmapInfo(inImage), 0, NULL, kCGRenderingIntentDefault}; | |
| vImage_Buffer source; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://crunchybagel.com/blend-uicolor-swift-extension/ | |
| extension UIColor { | |
| func blend(with: UIColor) -> UIColor { | |
| var orgR: CGFloat = 0, orgG: CGFloat = 0, orgB: CGFloat = 0, orgA: CGFloat = 0 | |
| var overR: CGFloat = 0, overG: CGFloat = 0, overB: CGFloat = 0, overA: CGFloat = 0 | |
| self.getRed(&orgR, green: &orgG, blue: &orgB, alpha: &orgA) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TAGS="TODO:|FIXME:" | |
| ERRORTAG="ERROR:" | |
| HELPERS="fdescribe|fcontext|fit" | |
| VIOLATIONS=$(find "${SRCROOT}" "./SUBDIRA" "./SUBDIRB" \ | |
| \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number \ | |
| --only-matching "($TAGS).*\$|($ERRORTAG).*|($HELPERS).*\$" |\ | |
| perl -p -e "s/($TAGS)/ warning: \$1/" |\ | |
| perl -p -e "s/($ERRORTAG)/ error: \$1/" |\ | |
| perl -p -e "s/($HELPERS)/ error: \$1/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService | |
| # https://stackoverflow.com/a/57159637 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # This function lets you easily create series of commands into a single call | |
| # It will print each successive command, run it and, as long as it returned | |
| # with code 0, continue to the next step. | |
| # If any step fails, it will stop and let you pick it back up after you fix the | |
| # issues. | |
| # | |
| # Example of script using this function: | |
| # !/usr/bin/env bash |
Author: Chris Lattner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| struct UILabelDebugOptions: OptionSet { | |
| let rawValue: Int | |
| static let bounds = UILabelDebugOptions(rawValue: 1 << 0) | |
| static let ascender = UILabelDebugOptions(rawValue: 1 << 1) | |
| static let descender = UILabelDebugOptions(rawValue: 1 << 2) | |
| static let xHeight = UILabelDebugOptions(rawValue: 1 << 3) | |
| static let capHeight = UILabelDebugOptions(rawValue: 1 << 4) |