Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Rehan Ali rehannali

🏠
Working from home
View GitHub Profile
@rehannali
rehannali / nav-bar-image.swift
Created Nov 7, 2022
Set Image in Navigation Bar
View nav-bar-image.swift
public extension UIViewController {
func setTitleImage(_ image: UIImage) {
let imageView = UIImageView(image: image)
let width = navigationController?.navigationBar.frame.size.width ?? 0
let height = navigationController?.navigationBar.frame.size.height ?? 0
let axisX = width / 2 - image.size.width / 2
let axisY = height / 2 - image.size.height / 2
imageView.frame = CGRect(x: axisX, y: axisY, width: width, height: height)
imageView.contentMode = .scaleAspectFit
@rehannali
rehannali / storyboarded.swift
Created Nov 7, 2022
Initialize from Storyboard
View storyboarded.swift
public extension UIViewController {
class func initializeFromStoryboard(storyboardName: CONSTANTS.StoryboardName, bundle: Bundle? = nil, identifier: String = "") -> Self {
return initializeFromStoryboard(storyboardName: storyboardName.rawValue, bundle: bundle, identifier: identifier)
}
class func initializeFromStoryboard(storyboardName: String, bundle: Bundle? = nil, identifier: String = "") -> Self {
let storyboard = UIStoryboard(name: storyboardName, bundle: bundle)
if let controller = initializeFromStoryboard(storyboard: storyboard, type: self, identifier: identifier) {
return controller
}
@rehannali
rehannali / top-current-vc.swift
Created Nov 7, 2022
Find Top View Controller
View top-current-vc.swift
public extension NSObject {
func findTopViewController(vc: UIViewController) -> UIViewController {
if (vc.presentedViewController != nil) {
return UIViewController().findTopViewController(vc:vc.presentedViewController!)
} else if (vc.isKind(of: AKSideMenu.self)) {
let rvc = vc as! AKSideMenu
if let left = rvc.leftMenuViewController {
return UIViewController().findBestVC(vc: left)
@rehannali
rehannali / install_realvnc_server.sh
Last active Jun 26, 2022 — forked from vietanhdev/install_realvnc_server.sh
Install RealVNC Ubuntu Headless - Raspberry Pi 4 armhf or using armhf
View install_realvnc_server.sh
#!/usr/bin/env bash
mkdir realvncserversetup && cd realvncserversetup
echo 'Adding armhf arch'
sudo dpkg --add-architecture armhf && sudo dpkg --print-foreign-architectures
echo 'Update Repositories'
sudo apt update && sudo apt upgrade -y
@rehannali
rehannali / supervisord.service
Last active Apr 21, 2022 — forked from tonyseek/supervisord.service
Running supervisord with systemd.
View supervisord.service
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecReload=/usr/bin/supervisorctl reload
ExecStop=/usr/bin/supervisorctl shutdown
@rehannali
rehannali / .. MediaCreationTool.bat ..md
Created Oct 3, 2021 — forked from AveYo/.. MediaCreationTool.bat ..md
Universal MediaCreationTool wrapper for all MCT Windows 10 versions from 1507 to 21H1 with business (Enterprise) edition support
View .. MediaCreationTool.bat ..md

Not just an Universal MediaCreationTool wrapper script with ingenious support for business editions,
Preview
A powerful yet simple windows 1X deployment automation tool as well!

awesome gui dialogs to pick windows version and preset action
Auto Setup choice for upgrade directly without prompts, with edition change / intelligent fallback
Create ISO choice for authoring iso file directly via DIR2ISO snippet, including any 'oem' customizations
Create USB choice for authoring usb via native MCT, including any 'oem' customizations (prompts once)
Select in MCT choice for vanilla MCT processing without 'oem' modifications, script quits straightway
control via set script vars, commandline parameters or rename script like iso 21H2 Pro MediaCreationTool.bat

@rehannali
rehannali / build-universal-xcframework.sh
Created Jun 25, 2021
Universal Framework for xcframework
View build-universal-xcframework.sh
#!/bin/sh
# Make sure to run this script in Framework folder to work properly.
# Create universal-framework.sh and copy all content to it.
# Provide FRAMEWORK_NAME to start build
# Globals Variables
# Avilable Platforms/Architectures
# macosx | iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator
@rehannali
rehannali / build-universal-framework.sh
Created Jun 25, 2021
Universal Framework depends on Cocoapods
View build-universal-framework.sh
#!/bin/sh
# Make sure to run this script in Framework folder to work properly.
# Create universal-framework.sh and copy all content to it.
# Provide FRAMEWORK_NAME to start build
# Globals Variables
# Avilable Platforms/Architectures
# macosx | iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator
@rehannali
rehannali / Delegation.swift
Created Jul 8, 2020
A simple solution for [weak self] or [unowned self] dance. No need to worry about retain cycles.
View Delegation.swift
struct Delegation<Input, Output> {
private(set) var callback: ((Input) -> Output?)?
mutating func delegate<Target: AnyObject>(to target: Target, _ callback: @escaping (Target, Input) -> Output) {
self.callback = { [weak target] (input) in
guard let target = target else {
return nil
}
return callback(target, input)
}
@rehannali
rehannali / extract_categories.py
Created Dec 21, 2019
Get categories from Jackett index
View extract_categories.py
from bs4 import BeautifulSoup
with open("/Users/rehan/Documents/iOS Projects/Developers Clan/abc.html", "r") as file:
html_doc = file.read()
categories_arr = []
html_parser = BeautifulSoup(html_doc, "lxml")
all_td_tags = html_parser.find_all("td")