This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ImagePicker.swift | |
// Image for Instagram | |
// | |
// Created by Saud Almutlaq on 09/05/2020. | |
// Copyright © 2020 Saud Soft. All rights reserved. | |
// Code from https://stackoverflow.com/questions/24625687/swift-uiimagepickercontroller-how-to-use-it | |
import AVFoundation | |
import Photos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import CommonCrypto | |
//MARK: - String extentions | |
extension String { | |
var isValidURL: Bool { | |
let detector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) | |
if let match = detector.firstMatch(in: self, options: [], range: NSRange(location: 0, length: self.utf16.count)) { | |
// it is a link, if the match covers the whole string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func convertToArbic () -> String? { | |
let formatter = NumberFormatter() | |
formatter.locale = Locale(identifier: "EN") | |
guard let number = formatter.number(from:self ) else{ | |
return nil | |
} | |
formatter.locale = Locale(identifier: "AR") | |
guard let number2 = formatter.string(from: number) else{ | |
return nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImageView { | |
func loadFrom(URLAddress: String) { | |
guard let url = URL(string: URLAddress) else { | |
return | |
} | |
DispatchQueue.main.async { [weak self] in | |
if let imageData = try? Data(contentsOf: url) { | |
if let loadedImage = UIImage(data: imageData) { | |
self?.image = loadedImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add these lines | |
batch | |
passphrase-file <Full path to the key.txt file (without tilda)> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UserNotifications | |
import OneSignal | |
class NotificationService: UNNotificationServiceExtension { | |
var contentHandler: ((UNNotificationContent) -> Void)? | |
var receivedRequest: UNNotificationRequest! | |
var bestAttemptContent: UNMutableNotificationContent? | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Updated to swift 4.2 | |
func calculateAge(dob : String) -> (Int, Int, Int){ | |
let df = DateFormatter() | |
df.dateFormat = "yyyy-MM-dd" | |
let date = df.date(from: dob) | |
guard let val = date else { | |
return (0, 0, 0) | |
} | |
var years = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## based on the blogpost here: http://blog.sjas.de/posts/colored-iptables-output.html | |
iptables --line-numbers -vnL |\ | |
sed -E 's/^Chain.*$/\x1b[4m&\x1b[0m/' |\ | |
sed -E 's/^num.*/\x1b[33m&\x1b[0m/' |\ | |
sed -E '/([^y] )((REJECT|DROP))/s//\1\x1b[31m\3\x1b[0m/' |\ | |
sed -E '/([^y] )(ACCEPT)/s//\1\x1b[32m\2\x1b[0m/' |\ | |
sed -E '/([ds]pt[s]?:)([[:digit:]]+(:[[:digit:]]+)?)/s//\1\x1b[33;1m\2\x1b[0m/' |\ | |
sed -E '/([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}(\/([[:digit:]]){1,3}){0,1}/s//\x1b[36;1m&\x1b[0m/g' |\ | |
sed -E '/([^n] )(LOGDROP)/s//\1\x1b[33;1m\2\x1b[0m/'|\ |