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 | |
/// Thread-safe Swift dependency injector | |
/// | |
/// **Using Injector** | |
/// 1. Call `Injector.setup()` early in the application lifecycle. | |
/// 2. In dependency classes, conform to one of `Injectable`, `Singleton`, `WeakSingleton`, `EagerSingleton`. | |
/// 3. In application code, construct dependencies using property injection like: | |
/// ``` | |
/// private let logger: TTLogger = inject() |
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
// Image+Trim.swift | |
// | |
// Copyright © 2020 Christopher Zielinski. | |
// https://gist.github.com/chriszielinski/aec9a2f2ba54745dc715dd55f5718177 | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is |
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
func showMessageResetApp(){ | |
let exitAppAlert = UIAlertController(title: "Restart is needed", | |
message: "We need to restart the app on your first login to the app.\n Please reopen the app after this.", | |
preferredStyle: .alert) | |
let resetApp = UIAlertAction(title: "Close Now", style: .destructive) { | |
(alert) -> Void in | |
// home button pressed programmatically - to thorw app to background | |
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil) | |
// terminaing app in background |
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
#!/bin/bash | |
# Completely stops & unloads Checkpoint, then uninstalls. | |
#/Library/Application\ Support/Checkpoint/Endpoint\ Connect/uninstall --uninstall | |
VPN_SITE_ADDRESS="secure.contoso.com" | |
# !!! Script expects a flat DMG file, such as one created using JAMF's Composer! | |
CHECKPOINT_INSTALLER_URL="https://s3-us-west-2.amazonaws.com/my-cool-bucket/checkpoint-endpointVPN-versionDERP.dmg" | |
CHECKPOINT_INSTALLER_VOLUME="endpointVPN-835017303" | |
REMOVE_PATHS=( "/Applications/Endpoint Security VPN.app" \ | |
"/Library/Application Support/Checkpoint/" \ |
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
#!/bin/bash | |
# Инструкция | |
# | |
# Для начала надо попросить у техподдрежки, чтобы сменили способ 2FA с приложения Multifactor на Google Authenticator. | |
# Во время настройки Google Authenticator сделайте скриншот QR кода и сохраните его в виде картинки. | |
# На сайте webqr.com можно расшифровать QR код и получить secret для генерации OTP. | |
# Пример: otpauth://totp/Luna:username?secret=TQPNWO37ZC6J6RG22MLSOIKQR5&algorithm=SHA256 | |
# | |
# В приложении "Связка ключей" на macOS необходимо вручную создать две записи с паролями: |
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
const FileManager = (()=>{ | |
function pwd() { | |
return $.NSFileManager.defaultManager.currentDirectoryPath.js | |
} | |
function cd(path='~') { | |
if (path==='') path = '.' | |
let p = $(path).stringByStandardizingPath | |
let r = $.NSFileManager.defaultManager |
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
ObjC.import('stdlib') | |
ObjC.import('CoreGraphics'); | |
// Move mouse cursor to specified position | |
function moveMouse(x, y) { | |
var pos = $.CGPointMake(x, y); | |
var event = $.CGEventCreateMouseEvent(null, $.kCGEventMouseMoved, pos, $.kCGMouseButtonLeft); | |
$.CGEventPost($.kCGHIDEventTap, event); | |
} |
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
#if DEBUG | |
import SwiftUI | |
protocol UIViewControllerRepresentableHelper: UIViewControllerRepresentable { | |
var configuration: (UIViewControllerType) -> () { get set } | |
} | |
extension UIViewControllerRepresentableHelper { | |
func makeUIViewController(context: Context) -> UIViewControllerType { UIViewControllerType() } | |
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { configuration(uiViewController) } |
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
#!/bin/zsh | |
############ | |
### zsh script to clear xcode caches and project | |
### | |
### Works from Xcode 9.3 to Xcode 11.6 | |
### | |
### last date I tested: (7/24/2020) | |
### | |
### Move this script to /usr/bin/local so this will be the default usage: | |
### cd myXcodeWorkspace/ |
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 AVFoundation | |
class ViewController: UIViewController { | |
// Duplicate players to handle optional cross-fading. | |
let playerQueue = [AVPlayer(), AVPlayer()] | |
var timeObserverToken: Any? |
NewerOlder