Skip to content

Instantly share code, notes, and snippets.

View arthurdapaz's full-sized avatar
📱
Tweaking iOS and CI/CDs

Arthur da Paz arthurdapaz

📱
Tweaking iOS and CI/CDs
View GitHub Profile
@arthurdapaz
arthurdapaz / Injector.swift
Created July 7, 2022 11:41 — forked from kevinmbeaulieu/Injector.swift
Thumbtack Swift Dependency Injector
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()
@arthurdapaz
arthurdapaz / Image+Trim.swift
Created March 10, 2022 02:29 — forked from msnazarow/Image+Trim.swift
[Swift 5] NSImage/UIImage Crop/Trim Transparency
// 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
@arthurdapaz
arthurdapaz / closeAppElegantly.swift
Created January 12, 2022 01:46 — forked from yoni-g/closeAppElegantly.swift
How to exit an iOS app without it looking like a crash? - Swift
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
#!/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/" \
@arthurdapaz
arthurdapaz / luna-vpn.sh
Created January 5, 2022 22:36 — forked from modestman/luna-vpn.sh
Подключение к Endpoint Security VPN с помощью bash скрипта
#!/bin/bash
# Инструкция
#
# Для начала надо попросить у техподдрежки, чтобы сменили способ 2FA с приложения Multifactor на Google Authenticator.
# Во время настройки Google Authenticator сделайте скриншот QR кода и сохраните его в виде картинки.
# На сайте webqr.com можно расшифровать QR код и получить secret для генерации OTP.
# Пример: otpauth://totp/Luna:username?secret=TQPNWO37ZC6J6RG22MLSOIKQR5&algorithm=SHA256
#
# В приложении "Связка ключей" на macOS необходимо вручную создать две записи с паролями:
@arthurdapaz
arthurdapaz / FileManager.js
Created July 16, 2021 01:33 — forked from uchcode/FileManager.js
JXA - FileManager
const FileManager = (()=>{
function pwd() {
return $.NSFileManager.defaultManager.currentDirectoryPath.js
}
function cd(path='~') {
if (path==='') path = '.'
let p = $(path).stringByStandardizingPath
let r = $.NSFileManager.defaultManager
@arthurdapaz
arthurdapaz / MoveMouse.js
Created July 16, 2021 01:29 — forked from deanishe/MoveMouse.js
JXA: Move mouse to centre of frontmost window
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);
}
#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) }
@arthurdapaz
arthurdapaz / xclean.sh
Created July 25, 2020 00:43
Safely Reset Xcode from 9.3 to 11.6. Clean, clear module cache, Derived Data and Xcode Caches.
#!/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/
@arthurdapaz
arthurdapaz / AVPlayerCrossFade.swift
Created February 26, 2020 15:47 — forked from michaelevensen/AVPlayerCrossFade.swift
Handles cross-fading between two individual AVPlayers, creates a smooth, undulating loop between two AVPlayerItem's.
import UIKit
import AVFoundation
class ViewController: UIViewController {
// Duplicate players to handle optional cross-fading.
let playerQueue = [AVPlayer(), AVPlayer()]
var timeObserverToken: Any?