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 / AssetExtractor.swift
Created April 11, 2019 06:28
Get URL from Xcode asset catalogs
import UIKit
//It basically just gets image from assets, saves its data to disk and return file URL.
class AssetExtractor {
static func createLocalUrl(forImageNamed name: String) -> URL? {
let fileManager = FileManager.default
let cacheDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let url = cacheDirectory.appendingPathComponent("\(name).png")
@fahied
fahied / MyWKWebVC.Swift
Created January 10, 2017 06:46
WKWebView controller example with progress bar
//
// MyWKWebVC.Swift
// Example
//
// Created by Fahied on 04/01/2017.
//
import Foundation
import UIKit
import WebKit
@fahied
fahied / gist:4b6621f4cee24c5c59ad
Created August 30, 2014 09:54
SOLVED: adb not responding. you can wait more or kill adb process manually and click 'restart'
ISSUE:
When try to run/debug programm in Android Studio
adb not responding. you can wait more or kill adb process manually and click 'restart'
Reason:
The adb server cannot start if the port 5037 was occupied by other process. So we need to find which one occupied it and kill the process to release this port.
@fahied
fahied / apns-pem
Created December 12, 2016 11:46
Create pem file for apple push notifications
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
@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 {
@fahied
fahied / apns
Created March 20, 2016 07:52
How to create APNS Certificates and merge into one PEM
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
Step 4: Now we have to merge the Key .pem and Certificate .pem to get Development .pem needed for Push Notifications in Development Phase of App
// 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) {