Skip to content

Instantly share code, notes, and snippets.

View nunogoncalves's full-sized avatar

Nuno Gonçalves nunogoncalves

View GitHub Profile
import UIKit
class ViewController: UIViewController {
let tableView: UITableView = {
let tv = UITableView(frame: .zero, style: .plain)
tv.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
return tv
}()
@nunogoncalves
nunogoncalves / ScreenshotServiceDelegate.swift
Created March 19, 2020 19:42
ScreenshotServiceDelegate
func screenshotService(
_ screenshotService: UIScreenshotService,
generatePDFRepresentationWithCompletion completionHandler: @escaping (Data?, Int, CGRect) -> Void
) {
...
}
@nunogoncalves
nunogoncalves / BetterDecodingError.swift
Last active January 26, 2024 08:37
Better Decoding Error Messages
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)
xccov(1) xccov(1)
NAME
xccov - view Xcode coverage data in human-readable or machine-parseable format.
SYNOPSIS
xccov view [--only-targets | --files-for-target target_name | --functions-for-file name_or_path]
struct GithubCreds {
static let clientId = "CLIENT ID"
static let clientSecret = "CLIENT SECRET"
}
@nunogoncalves
nunogoncalves / create_credentials_swift_struct.rb
Last active April 10, 2018 22:22
Ruby script that generates a swift file with credentials
#!/usr/bin/ruby
file_content = <<-CREDS_FILE_STRING
struct GithubCreds {
static let clientId = "#{ENV['GITHUB_CLIENT_ID']}"
static let clientSecret = "#{ENV['GITHUB_CLIENT_SECRET']}"
}
CREDS_FILE_STRING
@nunogoncalves
nunogoncalves / env-vars.sh
Last active April 10, 2018 22:30
Local environment variables
export GITHUB_CLIENT_ID=<valid_id>
export GITHUB_CLIENT_SECRET=<valid_secret>
@nunogoncalves
nunogoncalves / gist:f1616daaa05a1f5e03c246606fbe8c63
Created April 1, 2018 20:31 — forked from kzap/gist:5819745
If you want to give only Travis-CI access to a private key or secret file in your repository, you will need to encrypt it, but rather than storing the entire encrypted file in an environment variable, just store the a secret password in a secure environment variable that you will use to encrypt and decrypt your private key file. The encryption o…
# generate your private key, put the public key on the server you will be connecting to
ssh-keygen -t rsa -f ./my_key
# generate the password/secret you will store encrypted in the .travis.yml and use to encrypt your private key
cat /dev/urandom | head -c 10000 | openssl sha1 > ./secret
# encrypt your private key using your secret password
openssl aes-256-cbc -pass "file:./secret" -in ./my_key -out ./my_key.enc -a
# download your Travis-CI public key via the API. eg: https://api.travis-ci.org/repos/travis-ci/travis-ci/key
@nunogoncalves
nunogoncalves / Theming.swift
Created June 3, 2017 10:09
Easily apply theme styles to any UIView!
Make the following possible!
MarvelTheme.TextStyle.CommicSans.apply(to: label)
MarvelTheme.ColorStyle.dangerColor.apply(to: label)
// ============================== StylableView protocol ==============================
// Adds a consistent styling API to any UIView.
// The example here allows for any UIView subclass to have a way of setting its font type.
protocol StylableView {

Videos