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 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 / dedict.c
Created March 27, 2018 10:38 — forked from josephg/0dedict.py
Apple dictionaries
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"
#define CHUNK 16384
/*
40 Length of the zlib stream