Skip to content

Instantly share code, notes, and snippets.

View Lavmint's full-sized avatar
💭
Casually looking for a job :)

Alěkśéj Avěrkin Lavmint

💭
Casually looking for a job :)
  • Samara, Russia
View GitHub Profile
@Lavmint
Lavmint / CoreData.swift
Last active November 17, 2018 15:50
Nice CoreData usage
import CoreData
enum db {
static let todoist: DAO = {
let container = NSPersistentContainer(name: "Todoist")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
guard let err = error else { return }
fatalError(err.localizedDescription)
})
return DAO(container: container)
@Lavmint
Lavmint / EncodableOptional.swift
Created November 11, 2018 04:15
Encode optionals to requests with Encodable
import Foundation
enum EncodableOptional<Wrapped>: ExpressibleByNilLiteral {
case none
case some(Wrapped)
init(nilLiteral: ()) {
self = .none
}
}
@Lavmint
Lavmint / jwt.swift
Created September 3, 2019 16:08
JWT Swift5 + Common Crypto
import Foundation
import CommonCrypto
public func jwt(payload: [String: Any], secret: String) -> String? {
guard let data = try? JSONSerialization.data(withJSONObject: payload, options: []) else {
return nil
}
return jwt(payload: data, secret: secret)
}
@Lavmint
Lavmint / Swift UI FAQ.md
Last active September 7, 2021 07:58
Swift UI FAQ

Swift UI FAQ

Данный документ актуален по состоянию на стабильный XCode 11.1

NavigationView

Не освобождается память после pop

На iPhone из NavigationView осуществляется push переход через NavigationLink в destination. После возврата pop, видим что память, которую занимал detination, не освободилась.

@Lavmint
Lavmint / EditingView+MultilineTextField.swift
Last active September 22, 2021 14:05
SwiftUI EditingView + MultilineTextField
import SwiftUI
import Combine
struct ContentView: View {
struct _State {
var text = ""
}
@State var state = _State()
@Lavmint
Lavmint / TipsView.swift
Last active February 21, 2020 12:33
Tips/Hints example
import SwiftUI
import Combine
struct ContentView: View {
struct _State {
var source: CGRect?
var content: CGRect?
var isArrow: Bool {
return source != nil
import Foundation
import SwiftUI
struct FocusView: View {
let path: Path
let backgroundColor: Color
init(path: Path, backgroundColor: Color = Color.black.opacity(0.3)) {
self.path = path
@Lavmint
Lavmint / Podfile.rb
Last active October 30, 2020 19:42
Example of generating xcframeworks from cocoapods in Podfile
# Uncomment the next line to define a global platform for your project
require 'find'
platform :ios, '13.0'
install! 'cocoapods', :integrate_targets => false
use_frameworks!
target 'StockQuotes' do
# Pods for StockQuotes
@Lavmint
Lavmint / Eyebrow.swift
Created October 30, 2020 19:58
Attempt to generate xcframeworks
//
// File.swift
//
//
// Created by Alexey Averkin on 28.10.2020.
//
import Foundation
func main() {
@Lavmint
Lavmint / ApplePayProvider.swift
Last active March 14, 2021 16:21
Apple pay template (not tested)
import Foundation
import Combine
import PassKit
enum Request {
static var applePay: PaymentRequestBuilder {
return PaymentRequestBuilder()
}
}