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 / 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 / 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 / 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 / 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 / nextdns-with-pfsense-dns-resolver.md
Last active March 31, 2024 20:00
nextdns config with pfsense dns resolver

NextDNS with pfSense dns resolver

this is the basic configuration for nextdns combine with pfSense dns resolver to use both.

1. Login into pfSense GUI

SSH access is turned off by default on pfSense. To enable it, go to System -> Advanced -> Enable Secure Shell

image
@rehannali
rehannali / xcode-warnings.sh
Created March 24, 2025 06:04
xcode-warnings
#!/bin/bash
TAGS="TODO:|FIXME:|WARNING:"
ERRORTAG="ERROR:"
OUTPUT=$(find "${SRCROOT}" -name "*.h" -or -name "*.m" -or -name "*.swift" \( -not -path "${SRCROOT}/Carthage/*" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/")
ECHO "$OUTPUT"
if [[ $OUTPUT == *" error: "* ]]
@rehannali
rehannali / README.md
Created April 1, 2025 16:26
This setup helps you to configure docker container IPs in host file to access later whether in local machine or remote server.

Update Docker Hosts

This utility helps you to configure docker containers IPs into host file to manage containers with hostname instead of IPs. Whther you want to access the container or redirect traffic to that container like using nginx, it worked. You don't have to configure or manually edit the host file to maintain the IPs.

Installation

Prerequisites

  • Make sure you have docker installed on your machine and it is runing.
  • Install jq utility. For example in Ubunut or debian based OS sudo apt install jq -y