Skip to content

Instantly share code, notes, and snippets.

@mickey35vn
mickey35vn / FilterScriptPhase.sh
Created November 15, 2018 14:53 — forked from steipete/FilterScriptPhase.sh
This filter script phase is required to remove unused architectures from your application, which would be flagged as issue during upload to the Apple AppStore. Read more at http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
@mickey35vn
mickey35vn / .babelrc
Last active February 10, 2017 02:19
Config for ReactJS
{
"plugins": ["transform-react-jsx"],
"presets": ["es2015"]
}
class CustomTextView: UITextView {
private var placeholderText: String = ""
private var placeholderColor: UIColor = .dimGrayColor(0.4)
private var textViewDelegate: UITextViewDelegate?
override func awakeFromNib() {
textViewDelegate = delegate
delegate = self
}
extension UIImage {
public func imageWithColorOverlay(color: UIColor, alpha: CGFloat = 1) -> UIImage {
UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale)
let context = UIGraphicsGetCurrentContext()
let rect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height)
drawInRect(rect)
CGContextSetBlendMode(context, CGBlendMode.Multiply)
@mickey35vn
mickey35vn / MapUtils.swift
Last active March 15, 2016 04:37
Calculate the zoom level of bounds
private let LN2 = 0.6931471805599453
private let WORLD_PX_HEIGHT = 256
private let WORLD_PX_WIDTH = 256
func getBoundsZoomLevel(bounds: GMSCoordinateBounds, mapWidthPx: Int, mapHeightPx: Int) -> Double {
let ne = bounds.northEast
let sw = bounds.southWest
let latFraction = (getLatitudeRadius(ne.latitude) - getLatitudeRadius(sw.latitude)) / M_PI
@mickey35vn
mickey35vn / Connection.swift
Created March 14, 2016 13:12
Check for internet connection in Swift
import SystemConfiguration
func isConnectedToNetwork() -> Bool {
var zeroAddress = sockaddr_in()
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)
let defaultRouteReachability = withUnsafePointer(&zeroAddress) {
SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
}
var flags = SCNetworkReachabilityFlags()
@mickey35vn
mickey35vn / PrintFonts.swift
Created March 14, 2016 13:08
Print all iOS fonts in Swift
func printFonts() {
let fontFamilyNames = UIFont.familyNames()
for familyName in fontFamilyNames {
print("------------------------------")
print("Font Family Name = [\(familyName)]")
let names = UIFont.fontNamesForFamilyName(familyName as String)
println("Font Names = [\(names)]")
}
}