Skip to content

Instantly share code, notes, and snippets.

View Dean151's full-sized avatar

Thomas Durand Dean151

View GitHub Profile
@Dean151
Dean151 / CryptoKitLottery.swift
Last active June 25, 2019 15:36
Generate Lottery Numbers using CryptoKit
// Written by Thomas Durand (c)2019 ; all right reserved
// See https://www.thomasdurand.fr/swift/cryptokit/2019/06/25/generating-lottery-numbers-with-cryptokit.html for more context
/// Represent one `k among n` operation
struct Draw {
/// The number of number to draw (ie k)
let draw: UInt
/// The range of numbers to draw within (ie n)
let among: ClosedRange<Int>
@Dean151
Dean151 / ReusableView.swift
Created November 19, 2016 22:39
Reusable view mechanism with Swift3 and Protocol Oriented Programming
//: Playground - noun: a place where people can play
import XCPlayground
import UIKit
protocol ReusableView {
/// The index of the current view to compare when this view is visible
var index: Int { get }
/// A static method that will be used to instanciate a new ReusableView when needed