Skip to content

Instantly share code, notes, and snippets.

@Ikloo
Ikloo / CodableDateFormatter.swift
Created June 9, 2020 15:39
Date formatter with fractional seconds handling from Codable structs
extension Formatter {
static let iso8601: (regular: ISO8601DateFormatter, withFractionalSeconds: DateFormatter) = {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
return (ISO8601DateFormatter(), formatter)
}()
}
@Ikloo
Ikloo / Debouncer.swift
Last active March 24, 2020 12:24
Deferred funcs calls for Swift
//
// Debouncer.swift
//
// Created by Kirill Budevich on 11/14/19.
// Copyright © 2019 KB. All rights reserved.
//
import Foundation
final public class Debouncer {
@Ikloo
Ikloo / DispatchQueue.swift
Last active March 19, 2019 15:54
DispatchQueue extension
extension DispatchQueue {
static var userInteractive: DispatchQueue { return DispatchQueue.global(qos: .userInteractive) }
static var userInitiated: DispatchQueue { return DispatchQueue.global(qos: .userInitiated) }
static var utility: DispatchQueue { return DispatchQueue.global(qos: .utility) }
static var background: DispatchQueue { return DispatchQueue.global(qos: .background) }
func after(_ delay: TimeInterval, execute closure: @escaping () -> Void) {
asyncAfter(deadline: .now() + delay, execute: closure)
}
}
@Ikloo
Ikloo / Gradientable.swift
Created November 5, 2018 19:48
Gradientable protocol for UIView
// Created by Kirill Budevich.
// Copyright © 2018 Kirill Budevich. All rights reserved.
//
import UIKit
public protocol Gradientable: class {
/// Drawed CAGradientLayer from sublayers, nil if not added
var gradientLayer: CAGradientLayer? { get }
@Ikloo
Ikloo / git-cleanup-remote.md
Last active March 2, 2018 20:40
Delete merged branches remote. Use with git alias. Add this snippet into .gitconfig

git-cleanup-remote

Info

Delete merged branches remote. Use with git alias.


Install

[alias]
	cleanup-remote = "!git branch -r --merged | grep -v '\\*\\|master\\|develop\\|`THE_NAME_OF_THE_BRANCH`' | sed 's/origin\\///' | xargs -n 1 git push --delete origin"
@Ikloo
Ikloo / git-cleanup-locally.md
Last active March 16, 2018 09:21
Delete all branches locally. Use with git alias. Add this snippet into .gitconfig

git-cleanup-locally

Info

Delete merged branches remote. Use with git alias.


Install

[alias]
	cleanup-locally = "!git branch | grep -v '\\*\\|master\\|develop\\|`THE_NAME_OF_THE_BRANCH`' | xargs git branch -D "