Skip to content

Instantly share code, notes, and snippets.

View aornano's full-sized avatar

Alessandro Ornano aornano

View GitHub Profile
@aornano
aornano / Storage.swift
Created July 17, 2018 08:10
A good Swift 4.x example to store generic encodable/decodable objects to file
import Foundation
class Storage {
fileprivate init() { }
enum Directory {
case documents
case caches
}
/// Returns URL constructed from specified directory
static fileprivate func getURL(for directory: Directory) -> URL? {
@aornano
aornano / JSONAny.swift
Last active July 17, 2018 08:06
Swift 4.x Codable and Decodable "Any" class + "NULL" class that can be used with Codable JSON network calls
class JSONAny: Codable {
public let value: Any
public init<T>(_ value: T?) {
self.value = value ?? ()
}
static func decodingError(forCodingPath codingPath: [CodingKey]) -> DecodingError {
let context = DecodingError.Context(codingPath: codingPath, debugDescription: "Cannot decode JSONAny")
return DecodingError.typeMismatch(JSONAny.self, context)
@aornano
aornano / openssl-build.sh
Created January 11, 2018 10:28 — forked from foozmeat/openssl-build.sh
A shell script to build openssl for iOS and Mac. It currently builds: Mac -> i386 & x86_64 // iOS -> armv7, arm64 // iOS Simulator -> i386 & x86_64.
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh