Skip to content

Instantly share code, notes, and snippets.

View VAndrJ's full-sized avatar

VAndrJ VAndrJ

  • Ukraine
  • 16:02 (UTC +03:00)
View GitHub Profile
//
// ContentView.swift
// TestMapkit
//
// Created by Volodymyr Andriienko on 20.05.2021.
// Copyright © 2021 VAndrJ. All rights reserved.
//
import SwiftUI
import MapKit
//
// Created by Volodymyr Andriienko on 18.05.2021.
// Copyright © 2021 VAndrJ. All rights reserved.
//
#if DEBUG
#if canImport(SwiftUI)
import SwiftUI
@available (iOS 13.0, *)
//
// ViewController.swift
// StackTest
//
// Created by Volodymyr Andriienko on 27.04.2021.
//
// Что здесь происходит:
// r - отправка на чтение (первый таймер).
// w - отправка на запись (второй таймер).
@VAndrJ
VAndrJ / AsyncComposition.swift
Last active April 23, 2021 10:39
Simple drop-in example for macOS command line tool project.
import Foundation
infix operator ~>: MultiplicationPrecedence // Here we can create own group
// Composes two asynchronous functions
func ~> <T, U>(
_ first: @escaping (@escaping (Result<T, Error>) -> Void) -> Void,
_ second: @escaping (T, @escaping (Result<U, Error>) -> Void) -> Void) -> (@escaping (Result<U, Error>) -> Void
) -> Void {
return { result in
class Option {
final int rawValue;
Option(this.rawValue);
Option.fromSet(Set<Option> set) : rawValue = set.rawValue;
Option.fromList(List<Option> set) : rawValue = set.rawValue;
Option operator |(Option option) {
@VAndrJ
VAndrJ / NumberAbbreviation.swift
Created February 12, 2021 09:11
Simple solution for numbers abbreviation to k m b t aa etc.
//
// NumberAbbreviation.swift
//
// Created by Volodymyr Andriienko.
//
import Foundation
public struct NumberAbbreviation {
// MARK: - Add more if needed, for example: (1_000_000_000, 1_000_000_000, "B"), etc.
import Foundation
func checkAsync() async -> [String] {
(0...10).map({ "\($0)" })
}
func checkAsyncAwait() async -> [String] {
await checkAsync()
}
@VAndrJ
VAndrJ / Applyable.swift
Created January 12, 2021 17:43
Reflections about Kotlin's scope functions in Swift
protocol Applyable {}
func with<T, R>(_ lhs: T, _ rhs: (T) throws -> R) rethrows -> R {
return try rhs(lhs)
}
extension Applyable where Self: AnyObject {
@discardableResult
func apply(_ block: (Self) throws -> Void) rethrows -> Self {
@VAndrJ
VAndrJ / UIViewControllerSwiftUIRepresentable.swift
Created January 11, 2021 13:19
Simple extension for Previews of UIView and UIViewController.
#if DEBUG
#if canImport(SwiftUI)
import UIKit
import SwiftUI
@available (iOS 13.0, *)
struct UIViewControllerSwiftUIRepresentable: UIViewControllerRepresentable {
let controller: UIViewController
func makeUIViewController(context: Context) -> UIViewController {
@VAndrJ
VAndrJ / UINavigationBar+LargeTitleView.swift
Created December 6, 2019 20:36
Extension to find UINavigationBar's large title view.
//
// UINavigationBar+LargeTitleView.swift
// DesignInspirations
//
// Created by VAndrJ on 06.12.2019.
// Copyright © 2019 VAndrJ. All rights reserved.
//
public extension UINavigationBar {
var largeTitleView: UIView? {