Skip to content

Instantly share code, notes, and snippets.

Nuno Gonçalves nunogoncalves

Block or report user

Report or block nunogoncalves

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
nunogoncalves / BetterDecodingError.swift
Last active Mar 23, 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)
View man xccov
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]
View GithubCreds.swift
struct GithubCreds {
static let clientId = "CLIENT ID"
static let clientSecret = "CLIENT SECRET"
}
@nunogoncalves
nunogoncalves / create_credentials_swift_struct.rb
Last active Apr 10, 2018
Ruby script that generates a swift file with credentials
View create_credentials_swift_struct.rb
#!/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 Apr 10, 2018
Local environment variables
View env-vars.sh
export GITHUB_CLIENT_ID=<valid_id>
export GITHUB_CLIENT_SECRET=<valid_secret>
@nunogoncalves
nunogoncalves / gist:f1616daaa05a1f5e03c246606fbe8c63
Created Apr 1, 2018 — 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…
View gist:f1616daaa05a1f5e03c246606fbe8c63
# 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 Jun 3, 2017
Easily apply theme styles to any UIView!
View Theming.swift
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 {
You can’t perform that action at this time.