Skip to content

Instantly share code, notes, and snippets.

View ts95's full-sized avatar
🦉
🍰

Toni Sučić ts95

🦉
🍰
View GitHub Profile
@CypherPoet
CypherPoet / KeyboardFollower.swift
Last active October 29, 2019 08:25
Keyboard follower implemented as an ObservableObject using Swift Combine Publishers
import Combine
import Foundation
import UIKit
final class KeyboardFollower: ObservableObject {
private var subscriptions = Set<AnyCancellable>()
@Published var keyboardHeight: CGFloat = 0.0
@ArtFeel
ArtFeel / CALayer+AnimationPlayback.swift
Last active November 15, 2023 23:06
Persistent Core Animations (Swift 4.2). All you need is `self.layer.makeAnimationsPersistent()` 😎
//
// CALayer+AnimationPlayback.swift
// Created by Philip Vasilchenko on 4/27/18.
//
import UIKit
// Pause animations of layer tree
//
// Technical Q&A QA1673:
@Kdan
Kdan / heterogeneous_decoding.swift
Last active February 13, 2022 21:27
A Playground with an example of decoding a heterogeneous collection directly as a return type.
import Foundation
// MARK: - Model classes
/// The Pet superclass.
class Pet: Codable {
/// The name of the pet.
let name: String
enum CodingKeys: String, CodingKey {
case name
@JacobFierro
JacobFierro / docker.md
Last active January 5, 2024 10:42
Docker Cheatsheet

Docker Cheatsheet

Docker info:

docker info

Containers

List Images:

@regexident
regexident / AnyDiffable.swift
Created March 17, 2017 10:26 — forked from ollieatkinson/AnyDiffable.swift
Implementation of Paul Heckel's Diff Algorithm in Swift 3
public protocol Diffable: Hashable {
var primaryKeyValue: String { get }
}
public struct AnyDiffable: Diffable {
private let _primaryKeyValue: () -> String
@shahdhiren
shahdhiren / P12toPEM.txt
Created September 9, 2016 14:57
Convert P12 file for Push Notification to PEM format
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active May 21, 2024 10:21
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName