Skip to content

Instantly share code, notes, and snippets.

View fahied's full-sized avatar

Muhammad Fahied fahied

  • Emirates Airlines
  • Dubai
View GitHub Profile
@fahied
fahied / sample.swift
Created October 16, 2021 04:38 — forked from chriseidhof/sample.swift
SwiftUI View Inspection
import SwiftUI
struct SizeKey: PreferenceKey {
static func reduce(value: inout CGSize?, nextValue: () -> CGSize?) {
value = value ?? nextValue()
}
}
struct ContentView: View {
@State var width: CGFloat? = nil
var body: some View {
// Don't forget to add to the project:
// 1. DeepLabV3 - https://developer.apple.com/machine-learning/models/
// 2. CoreMLHelpers - https://github.com/hollance/CoreMLHelpers
enum RemoveBackroundResult {
case background
case finalImage
}
extension UIImage {
@fahied
fahied / jamf.md
Created November 1, 2020 06:03 — forked from prenagha/jamf.md
removing all restrictions on jamf managed macos device - Provided you have root access.

REMOVE JAMF RESTRICTIONS ON MAC

REMOVE ONLY RESTRICTIONS

sudo jamf removeMDMProfile removes all restrictions

sudo jamf manage brings back all restrictions and profiles

REMOVE ALL RESTRICTIONS AND DISABLE JAMF BINARIES WHILE KEEPING YOUR ACCESS TO VPN AND OTHER SERVICES

sudo jamf removeMDMProfile removes all restrictions

@fahied
fahied / modal-view.md
Created July 28, 2020 11:34 — forked from barbietunnie/modal-view.md
Swift Modal View Controller with transparent background

You can do it like this:

In your main view controller:

func showModal() {
    let modalViewController = ModalViewController()
    modalViewController.modalPresentationStyle = .OverCurrentContext
    presentViewController(modalViewController, animated: true, completion: nil)
}
@fahied
fahied / UINavigationController+Extension.swift
Created May 4, 2020 17:47
Filter ViewControllers in a NavigationController by a Protocol
// Important Protocol is marked @objc and conform to AnyObject
@objc protocol Hostable: AnyObject { }
extension UINavigationController {
func viewControllers(conforming: Protocol) -> [UIViewController]? {
return viewControllers.filter { $0.conforms(to: conforming) }
}
func popToFirstViewController(conforming: Protocol, animated: Bool) {
@fahied
fahied / findsymbol.command
Created March 20, 2020 18:55
find Symbols/API usage in a framework
cd mapp.app //in Product folder under Xcode
nm myapp | grep UIWeb
for framework in Frameworks/*.framework; do
fname=$(basename $framework .framework)
echo $fname
nm $framework/$fname | grep UIWeb
done
@fahied
fahied / UserDefault.swift
Created February 16, 2020 11:20
Reduce Boiler Plate code for UserDefault using PropertyWrapper
// Strongly Typed key
struct Key: RawRepresentable {
let rawValue: String
}
extension Key: ExpressibleByStringLiteral {
init(stringLiteral: String) {
rawValue = stringLiteral
}
@fahied
fahied / autotrack.swift
Last active December 17, 2019 10:16
Auto Track Analytics iOS
@objc class AutoTrackedViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tracker.trackScreen(name: Self.screenName, className: Self.className)
addTrackingTarget()
}
override func viewDidLoad() {

iOS Swift - Cancellable Task with GCD

#iOSBySheldon

I think most of you guys know GCD pretty well. Basically, GCD is a high level API to handle multi-threading operations. We use GCD almost on daily basis to switch thread and execute codes like:

DispatchQueue.main.async { //execute some codes here } 
//switch to main queue and execute codes asynchronously

DispatchQueue.main.sync { //execute some codes here } 
//switch to main queue and execute codes synchronously
@fahied
fahied / symbolicateiOS.md
Last active December 15, 2019 11:20
Symbolicate iOS crash manually

Step 1: Use the following command in Terminal to find the dSYM on your Mac which build the app

mdfind "com_apple_xcode_dsym_uuids == 12345678-90AB-CDEF-1234-567890ABCDEF"

The string "12345678-90AB-CDEF-1234-567890ABCDEF" is the UUID string from the crash report reformatted to uppercase and 8-4-4-4-12 groups.

Step 2: Symobolicate Crash Report. Excute the following line before symbolicating