Skip to content

Instantly share code, notes, and snippets.

View anivaros's full-sized avatar

Vasily Anisimov anivaros

View GitHub Profile
@mecid
mecid / Calendar.swift
Last active September 2, 2025 01:55
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@atomicbird
atomicbird / NSPersistentContainer+extension.swift
Created May 22, 2020 21:39
Back up and restore Core Data persistent stores
//
// NSPersistentContainer+extension.swift
// CDMoveDemo
//
// Created by Tom Harrington on 5/12/20.
// Copyright © 2020 Atomic Bird LLC. All rights reserved.
//
import Foundation
import CoreData
@gtrabanco
gtrabanco / S00-backnifi.sh
Last active February 20, 2023 09:50
Script to do a backup of unifi or protect files with udm
#!/usr/bin/env sh
{ # Ensure all script is loaded
#
# Backup unifi or protect configuration files to a remote server
# You should install first the public key remotely.
#
# To do ssh authentication if you have a Cloud Key Gen2, it is like any other
# debian. Just use "ssh-keygen" and "ssh-copy-id"
#
@networkextension
networkextension / actor_dl_imge.swift
Created June 11, 2021 07:56
actor async/await download imge Swift 5.5
extension UIImage {
@available(iOS 15, *)
var thumbnail: UIImage? {
get async {
let size = CGSize(width: 80, height: 40)
return await self.byPreparingThumbnail(ofSize: size)
}
}
}
enum FetchError:Error{
@gdavis
gdavis / ThreadSafe.swift
Last active June 28, 2025 08:58
ThreadSafe is a property wrapper that can be used to control atomic access to the underlying property while allowing concurrent access to reading the value.
//
// ThreadSafe.swift
// GDICore
//
// Created by Grant Davis on 1/2/21.
// Updated to support `_modify` accessor on 12/5/21.
//
// Copyright © 2021 Grant Davis Interactive, LLC. All rights reserved.
//
import Foundation
@buh
buh / AuthenticationStateExample.swift
Last active December 14, 2023 09:42
Example for a Finite-State Machine
/// The authentication state.
enum AuthenticationState: StateType {
// A list of events.
enum Event {
case userSignIn(email: String, password: String)
case accessTokenReceived(AccessToken)
case userReceived(User)
case userSignedOut
}
import _Concurrency
import Combine
import Dispatch
import Foundation
// MARK: General
struct SomeError: Error {}
extension AnyPublisher {