Skip to content

Instantly share code, notes, and snippets.

View albertodebortoli's full-sized avatar

Alberto De Bortoli albertodebortoli

View GitHub Profile
@albertodebortoli
albertodebortoli / token_refresh_snippet_1.swift
Created December 3, 2019 11:07
used by 'Lessons learned from handling JWT on mobile' article on Medium
typealias Token = String
typealias AuthorizationValue = String
struct UserAuthenticationInfo {
let bearerToken: Token // the JWT
let refreshToken: Token
let expiryDate: Date // computed on creation from 'exp' claim
var isValid: Bool {
return expiryDate.compare(Date()) == .orderedDescending
}

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@albertodebortoli
albertodebortoli / modular_architecture_consideration_sample_2.swift
Created November 26, 2019 11:00
used by 'A Smart Feature Flagging System for iOS' article on Medium
import JustTweak
public class AppConfiguration: ModuleASettings, ModuleBSettings {
static let tweakManager: TweakManager = {
...
}
@TweakProperty(...)
var isFeatureXEnabled: Bool
@albertodebortoli
albertodebortoli / modular_architecture_consideration_sample_1.swift
Created November 26, 2019 11:00
used by 'A Smart Feature Flagging System for iOS' article on Medium
protocol ModuleASettings {
var isFeatureXEnabled: Bool { get }
}
protocol ModuleBSettings {
var publicApiHost: String { get }
var publicApiPort: Int? { get }
}
@albertodebortoli
albertodebortoli / PropertyWrappers_sample.swift
Created November 26, 2019 10:56
used by 'A Smart Feature Flagging System for iOS' article on Medium
@TweakProperty(fallbackValue: <#default_value#>,
feature: <#feature_key#>,
variable: <#variable_key#>,
tweakManager: tweakManager)
var isFeatureXEnabled: Bool
@TweakProperty(fallbackValue: <#default_value#>,
feature: <#feature_key#>,
variable: <#variable_key#>,
tweakManager: tweakManager)
@albertodebortoli
albertodebortoli / Tweaks_sample.json
Created November 26, 2019 10:47
used by 'A Smart Feature Flagging System for iOS' article on Medium
{
"ui_customization": {
"display_red_view": {
"Title": "Display Red View",
"Description": "shows a red view in the main view controller",
"Group": "UI Customization",
"Value": false
},
...
"red_view_alpha_component": {
@albertodebortoli
albertodebortoli / TweakManager_stack_sample.swift
Last active November 28, 2019 11:19
used by 'A Smart Feature Flagging System for iOS' article on Medium
static let tweakManager: TweakManager = {
// mutable configuration (to override tweaks from other configurations)
let userDefaultsConfiguration = UserDefaultsConfiguration(userDefaults: .standard)
// remote configurations (optional)
let optimizelyConfiguration = OptimizelyConfiguration()
let firebaseConfiguration = FirebaseConfiguration()
// local JSON configuration (default tweaks)
let jsonFileURL = Bundle.main.url(forResource: "ExampleConfiguration", withExtension: "json")!
@albertodebortoli
albertodebortoli / multiple_ssh_setting.md
Created June 9, 2018 19:28 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
$ brew install imagemagick
$ convert UK-iPad*.png -resize 50% -set filename:fname '%t_Resized' +adjoin '%[filename:fname].png'
credits to Oliver Pearmain
@albertodebortoli
albertodebortoli / postal-codes.json
Created February 9, 2018 21:23 — forked from matthewbednarski/postal-codes.json
Global postal codes regex formats
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$" }, { "Note":