Skip to content

Instantly share code, notes, and snippets.

View rehannali's full-sized avatar
🏠
Working from home

Rehan Ali rehannali

🏠
Working from home
View GitHub Profile
@rehannali
rehannali / nav-bar-image.swift
Created November 7, 2022 07:03
Set Image in Navigation Bar
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 November 7, 2022 07:02
Initialize from Storyboard
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 November 7, 2022 06:59
Find Top View Controller
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 June 26, 2022 11:34 — forked from vietanhdev/install_realvnc_server.sh
Install RealVNC Ubuntu Headless - Raspberry Pi 4 armhf or using armhf
#!/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 April 21, 2022 14:54 — forked from tonyseek/supervisord.service
Running supervisord with systemd.
[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 October 3, 2021 06:23 — forked from AveYo/.. MediaCreationTool.bat ..md
Universal MediaCreationTool wrapper for all MCT Windows 10 versions from 1507 to 21H1 with business (Enterprise) edition support

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 June 25, 2021 15:41
Universal Framework for xcframework
#!/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 June 25, 2021 15:40
Universal Framework depends on Cocoapods
#!/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 July 8, 2020 08:24
A simple solution for [weak self] or [unowned self] dance. No need to worry about retain cycles.
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 December 21, 2019 18:38
Get categories from Jackett index
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")