Skip to content

Instantly share code, notes, and snippets.

View dreymonde's full-sized avatar
🇺🇦

Oleg Dreyman dreymonde

🇺🇦
View GitHub Profile
@dreymonde
dreymonde / Timers.swift
Last active July 17, 2023 20:45
"Timers" helper class for Swift with automatic memory management and intuitive API
public final class Timers {
private var timers: [Foundation.Timer] = []
public init() { }
public func clear() {
for timer in timers {
timer.invalidate()
}
@dreymonde
dreymonde / BlurredImageView.swift
Created March 30, 2023 07:14
Custom drop-in UIImageView subclass that makes every image blurred with a specified visual effect. Swift, UIKit
final class BlurredImageView: UIImageView {
init(effect: UIVisualEffect? = UIBlurEffect(style: .regular)) {
super.init(frame: .zero)
blurView.effect = effect
addSubview(blurView)
}
var effect: UIVisualEffect? {
get { blurView.effect }
// THIS IS A UNIVERSAL SWIFT FUNCTION BIULDER
// FOR ARRAYS OF ANY TYPE
// tested on Swift 5.3.1
@_functionBuilder
public enum ArrayBuilder<Element> {
public typealias Expression = Element
public typealias Component = [Element]

How to extract iMessage stickers from a jaibroken iPhone

  1. Jailbreak your iPhone (as of Jan 2021, https://checkra.in is a good option if you have a pre iOS 14 device). I advice you to not use your main device for this
  2. Make sure Cydia is installed on your jailbroken iPhone
  3. Open Cydia (performing any neccessary updates if needed), tap "Search", and install "OpenSSH" (from apt.bingner.com) and "IPA Installer" (from BigBoss). This should install "IPA Installer Console" package as well.
  4. Make sure your iPhone is connected to the same Wi-Fi as your Mac.
  5. On your iPhone, open "Settings" -> "Wi-Fi", then tap on the info button (ℹ) next to the connected wi-fi network, and note down your IP Address. You will use it for SSH connection.
  6. Use this guide to get access to your jailbroken iPhone via SSH with your Mac.

(TL;DR for SSH:)

// Based on Kickstarter-Prelude version
// https://github.com/kickstarter/Kickstarter-Prelude/blob/master/Prelude-UIKit/UIImage.swift
extension UIImage {
/**
- parameter color: A color.
- returns: A 1x1 UIImage of a solid color.
*/
static func pixel(ofColor color: UIColor) -> UIImage {
let lightModeImage = UIImage.generatePixel(ofColor: color, userInterfaceStyle: .light)
struct UserConfirmationRequired {
private let performDestructiveAction: () -> ()
init(destructiveAction: @escaping () -> ()) {
self.performDestructiveAction = destructiveAction
}
func performWithUserConfirmation(alertTitle: String,
alertMessage: String,
{
"links": [
"https://raw.githubusercontent.com/dreymonde/LiveEndpoint/49f4844f13d96ee70ee9679ac3344d946b0aa381/Points/Nau.json",
"https://raw.githubusercontent.com/dreymonde/LiveEndpoint/49f4844f13d96ee70ee9679ac3344d946b0aa381/Points/Unu.json",
"https://raw.githubusercontent.com/dreymonde/LiveEndpoint/49f4844f13d96ee70ee9679ac3344d946b0aa381/Points/Tri.json",
"https://raw.githubusercontent.com/dreymonde/LiveEndpoint/49f4844f13d96ee70ee9679ac3344d946b0aa381/Points/Kvar.json",
]
}
@dreymonde
dreymonde / Completion.swift
Created February 27, 2017 23:26 — forked from amlcurran/Completion.swift
Better completion blocks by using higher order functions
func completion<Result>(onResult: @escaping (Result) -> Void, onError: @escaping (Error) -> Void) -> ((Result?, Error?) -> Void) {
return { (maybeResult, maybeError) in
if let result = maybeResult {
onResult(result)
} else if let error = maybeError {
onError(error)
} else {
onError(SplitError.NoResultFound)
}
}
import Foundation
public struct Synchronized<Value> {
fileprivate let accessQueue: DispatchQueue
fileprivate var value: Value
public init(_ value: Value, queueLabel: String = "\(Value.self)SynchronizedQueue") {
self.value = value
self.accessQueue = DispatchQueue(label: queueLabel)
@dreymonde
dreymonde / mapper-2.swift
Last active March 28, 2019 05:44
Next generation of Mapper, chapter 2
import Foundation
enum IndexPathValue {
case index(Int)
case key(String)
}
protocol IndexPathElement {
var indexPathValue: IndexPathValue { get }
}