Skip to content

Instantly share code, notes, and snippets.


Nuno Gonçalves nunogoncalves

View GitHub Profile
nunogoncalves / BetterDecodingError.swift
Last active Oct 3, 2020
Better Decoding Error Messages
View BetterDecodingError.swift
import Foundation
enum BetterDecodingError: CustomStringConvertible {
case dataCorrupted(_ message: String)
case keyNotFound(_ message: String)
case typeMismatch(_ message: String)
case valueNotFound(_ message: String)
case any(_ error: Error)
nunogoncalves / CreditCardValidation.swift
Last active Sep 17, 2020
Credit card validation in Swift 3
View CreditCardValidation.swift
import UIKit
import PlaygroundSupport
enum CreditCardType {
case visa
case visaElectron
case mastercard
View ScreenshotserviceViewControllerDelegate.swift
import UIKit
class ViewController: UIViewController {
let tableView: UITableView = {
let tv = UITableView(frame: .zero, style: .plain)
tv.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
return tv
View ScreenshotServiceDelegate.swift
func screenshotService(
_ screenshotService: UIScreenshotService,
generatePDFRepresentationWithCompletion completionHandler: @escaping (Data?, Int, CGRect) -> Void
) {
nunogoncalves / enums_multiple_values.swift
Last active Nov 3, 2019
Workaround to have kind of multiple values enums
View enums_multiple_values.swift
//: Playground - noun: a place where people can play
import UIKit
enum VehicleType : RawRepresentable {
struct Vehicle : Equatable {
let name: String
let wheels: Int
nunogoncalves / Dates.swift
Last active Feb 7, 2019
Date Operations in swift 3 //Date() + 1.days
View Dates.swift
//See the bottom of this file to check what you can do with this
let calendar = Calendar(identifier: .gregorian)
struct CalendarComponentAmount {
let component: Calendar.Component
let amount: Int
infix operator +: AdditionPrecedence
nunogoncalves / ZoomableImageView.swift
Last active Jan 17, 2019
Basic zoomable image view
View ZoomableImageView.swift
// ZoomableImageView.swift
// ZoomableImage
// Created by Nuno Gonçalves on 01/04/17.
// Copyright © 2017 Nuno Gonçalves. All rights reserved.
import UIKit
View man xccov
xccov(1) xccov(1)
xccov - view Xcode coverage data in human-readable or machine-parseable format.
xccov view [--only-targets | --files-for-target target_name | --functions-for-file name_or_path]
nunogoncalves /
Last active Apr 10, 2018
Local environment variables
export GITHUB_CLIENT_ID=<valid_id>
export GITHUB_CLIENT_SECRET=<valid_secret>
View GithubCreds.swift
struct GithubCreds {
static let clientId = "CLIENT ID"
static let clientSecret = "CLIENT SECRET"
You can’t perform that action at this time.