Skip to content

Instantly share code, notes, and snippets.

View vitsky91's full-sized avatar
🏠
Working from home

Vitalii Sydorskyi vitsky91

🏠
Working from home
View GitHub Profile
@vitsky91
vitsky91 / Linked List
Created May 2, 2023 13:14
Linked List - Swift Enums
indirect enum LinkedListNode {
case head(value: Int, node: LinkedListNode)
case node(value: Int, next: LinkedListNode)
case tail(value: Int)
}
let linkedList = LinkedListNode
.head(value: 0, node:
.node(value: 1, next:
.node(value: 2, next:
@vitsky91
vitsky91 / README.md
Created March 23, 2023 10:22 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@vitsky91
vitsky91 / 1apple-app-site-association.markdown
Last active February 10, 2023 12:45 — forked from mat/Readme.markdown
apple-app-site-association —with examples

“apple-app-site-association” file

One file for each domain, both www.example.com and example.com need separate files:

{
    "applinks": {
        "apps": [],
        "details": {
 "9JA89QQLNQ.com.apple.wwdc": {
@vitsky91
vitsky91 / BiometricAuth.swift
Created August 25, 2022 08:54
BiometricAuth
import LocalAuthentication
class BiometricAuth {
var context = LAContext()
var error: NSError?
func auth(_ completion: @escaping (_ success: Bool) -> ()) {
// Get the supported biometry
@vitsky91
vitsky91 / ResultsExtension.swift
Created June 21, 2022 11:26 — forked from ohetzendorfer/ResultsExtension.swift
Realm results extension for transforming to array
import RealmSwift
extension Results {
func toArray() -> [T] {
return self.map{ $0 }
}
}
@vitsky91
vitsky91 / RealmService.swift
Created June 21, 2022 11:25 — forked from ohetzendorfer/RealmService.swift
Collection of realm operations. Requires ResultsExtension.swift
import RealmSwift
internal struct RealmService {
private static var realm: Realm? {
do {
return try Realm()
} catch let error as NSError {
print(error)
return nil
@vitsky91
vitsky91 / UIColor+Extension.swift
Last active February 18, 2022 11:29
Extension for UIColor: - init from String hex, - get hex String from Color, - init from Int values, - create image from UIColor
import UIKit
extension UIColor {
/// Creates image from color
/// - Parameter size: size of returned image
/// - Returns: UIImage
func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
return UIGraphicsImageRenderer(size: size).image { rendererContext in
self.setFill()
@vitsky91
vitsky91 / DateHelper.swift
Created February 18, 2022 11:14
Extend Date for convenient using
import Foundation
public extension Date {
// MARK: - Convert from String
/*
Creates a new Date based on a string of a specified format. Supports optional timezone and locale.
*/
init?(fromString string: String, format: DateFormatType, timeZone: TimeZoneType = .local, locale: Locale = Foundation.Locale.current, isLenient: Bool = true) {
@vitsky91
vitsky91 / StringToBezierPath.swift
Created February 18, 2022 11:12
Convert String to UIBezierPath using Swift
import UIKit
import CoreText
import XCPlayground
let font = UIFont(name: "HelveticaNeue", size: 46)! // Choose font
var allPathes = [CGPath]()
var unichars = [UniChar]("i".utf16) //Insert text
var glyphs = [CGGlyph](repeating: 0, count: unichars.count)
let gotGlyphs = CTFontGetGlyphsForCharacters(font, &unichars, &glyphs, unichars.count)