Skip to content

Instantly share code, notes, and snippets.

View levochkaa's full-sized avatar
👽

Lev Poznyakov levochkaa

👽
View GitHub Profile
@levochkaa
levochkaa / TaskQueue.swift
Created February 13, 2023 12:42
Blocking Task
// TaskQueue.swift
import Foundation
class TaskQueue {
private actor TaskQueueActor {
private var blocks = [() async -> Void]()
private var currentTask: Task<Void, Never>?
func addBlock(priority: TaskPriority? = nil, block: @escaping () async -> Void) {
@levochkaa
levochkaa / Logger.swift
Created January 14, 2023 22:05
Best Logger in Swift ever (and the easiest to use)
// Logger.swift
import Foundation
import os.log
// swiftlint:disable line_length
func log(_ messages: Any..., file: String = #fileID, function: String = #function, line: Int = #line) {
// actually impossible cases
guard let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String else {
return print("Unable to get App Name")
@levochkaa
levochkaa / CarouselView.swift
Created September 14, 2022 15:54
Easy implementaion of a Snap Carousel in SwiftUI
import SwiftUI
struct CarouselView: View {
@State private var currentCardIndex = 2
@GestureState private var dragOffset: CGFloat = 0
@State private var sampleArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
var body: some View {
HStack(spacing: 0) {