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
/* | |
This sample uses your application's keyWindow - the window that all other views hang from. Since UIWindow is simply a subclass of UIView, we can add gesture recognizers to it. | |
No matter where you tap or scroll - the master view's table view, or a map in the detail view - the keyboard will be dismissed and your pan/tap gesture continues unhindered. | |
*/ | |
// Adopt UIGestureRecognizerDelegate and UISearchBarDelegate protocols in .h |
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
tell application "System Events" | |
set ProcNm_ to name of every application process whose visible is true | |
repeat with i_ from 1 to count items of ProcNm_ | |
set TarProc_ to item i_ of ProcNm_ | |
try | |
tell application TarProc_ to quit | |
end try | |
end repeat | |
shut down | |
end tell |
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
class RowTemplateRelationshipAny: NSPredicateEditorRowTemplate { | |
override func predicate(withSubpredicates subpredicates: [NSPredicate]?) -> NSPredicate{ | |
let predicate: NSComparisonPredicate = super.predicate(withSubpredicates: subpredicates) as! NSComparisonPredicate | |
let newPredicate = NSComparisonPredicate(leftExpression: predicate.leftExpression, rightExpression: predicate.rightExpression, modifier: .any, type: predicate.predicateOperatorType, options: predicate.options) | |
return newPredicate | |
} |
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
//: # Swift 3: Base64 encoding and decoding | |
import Foundation | |
extension String { | |
//: ### Base64 encoding a string | |
func base64Encoded() -> String? { | |
if let data = self.data(using: .utf8) { | |
return data.base64EncodedString() | |
} | |
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
// | |
// String+ReadLines.swift | |
// | |
// Created by Dmitry Shmidt on 5/16/18. | |
// | |
import Foundation | |
extension URL{ | |
func readLines() throws -> [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
// | |
// IPAPI+ReactiveKit.swift | |
// Created by Dmitry Shmidt on 5/25/18. | |
// | |
import IPAPI | |
import ReactiveKit | |
extension Service{ | |
@discardableResult open func fetch(query: String? = nil, fields: [Result.Field]? = nil, language: String? = nil) -> Signal<Service.Result, Service.Error> |
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 extractDigits() -> [UInt]{ | |
return components(separatedBy: CharacterSet.decimalDigits.inverted).compactMap(UInt.init) | |
} | |
} |
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 Foundation | |
public extension Array { | |
/** | |
Loops through array by batches | |
- Parameter batchSize: Size of the batch | |
- batch: Current batch elements | |
- currentNo: Current batch number |
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
# https://www.raspberrypi.org/documentation/configuration/security.md | |
sudo apt install ufw | |
sudo ufw allow ssh | |
sudo ufw limit ssh/tcp | |
sudo ufw enable | |
sudo apt install fail2ban | |
sudo service fail2ban restart |
OlderNewer