Skip to content

Instantly share code, notes, and snippets.

View longvudai's full-sized avatar

Long Vu longvudai

View GitHub Profile
@longvudai
longvudai / json.swift
Created August 5, 2022 13:08 — forked from mbuchetics/json.swift
Decoding arbitrary JSON with the new Decoder in Swift 4
enum JSON: Decodable {
case bool(Bool)
case double(Double)
case string(String)
indirect case array([JSON])
indirect case dictionary([String: JSON])
init(from decoder: Decoder) throws {
if let container = try? decoder.container(keyedBy: JSONCodingKeys.self) {
self = JSON(from: container)
import Foundation
final class PersistenceSyncManager {
private let fileManager: FileManager = .default
private let sharedContainer: URL
private let sharedTargetPath: String = "YOUR-SHARED-FOLDER"
private var contentContainerURL: URL { sharedContainer.appendingPathComponent(sharedTargetPath) }
static let shared = PersistenceSyncManager()
import Firebase
import FirebaseAuth
extension FirebaseApp {
private static var didConfigForAppExtension = false
static func configureFirebaseForAppExtension(
extensionPlistName: String,
accessGroup: String,
force: Bool = false
import UIKit
/*:
DateComponentsFormatter: A formatter that creates string representations of quantities of time.
*/
let dateComponentsFormatter = DateComponentsFormatter()
/*:
A DateComponentsFormatter can be configured with an array of NSCalendarUnits. These components are then used in the output.
@longvudai
longvudai / SplitViewController.swift
Created February 3, 2022 08:01 — forked from max-potapov/SplitViewController.swift
UITabBarController inside Master View of UISplitViewController
//
// SplitViewController.swift
// Gist
//
// Created by Maxim Potapov on 17/12/2017.
// Copyright © 2017 Maxim Potapov. All rights reserved.
//
import UIKit
@longvudai
longvudai / UIFont+Helpers.swift
Created June 30, 2021 03:53 — forked from shaps80/Font.swift
A set of UIFont helpers that matches the equivalent SwiftUI Font API.
import UIKit
public extension UIFont {
enum Leading {
case loose
case tight
}
private func addingAttributes(_ attributes: [UIFontDescriptor.AttributeName: Any]) -> UIFont {
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@longvudai
longvudai / Person.swift
Last active March 18, 2020 18:10
ARC-medium
class Person {
let name: String
init(name: String) {
self.name = name
print("\(name) is being initialized")
}
deinit {
@longvudai
longvudai / MyController.swift
Created December 4, 2018 19:42
set preferredStatusBarStyle when view controller is presented
// in myViewController
class MyViewController: UIViewController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override func awakeFromNib() {
super.awakeFromNib()
modalPresentationCapturesStatusBarAppearance = true //allow this VC to control the status bar appearance
@longvudai
longvudai / UITabBarController+UINavigationController.swift
Last active December 4, 2018 19:43
preferredStatusBarStyle() to work within UINavigationController and UITabBarController
extension UITabBarController {
open override var childForStatusBarStyle: UIViewController? {
return selectedViewController
}
}
extension UINavigationController {
open override var childForStatusBarStyle: UIViewController? {
return visibleViewController
}