Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Cumley ryancumley

View GitHub Profile
@ryancumley
ryancumley / jwt.playground
Created November 19, 2021 04:44
JWT verification and parsing playground
View jwt.playground
import Foundation
import Security
//https://blog.kaltoun.cz/verifying-rsa-jwt-signatures-in-swift/
let rawToken: String = "#id_token=eyJraWQiOiJ5eVFmUVVETnFYNklOVGxLY1wvMVlWaUVhcXJKa3k4KzhvczlJejZyUmVoWT0iLCJhbGciOiJSUzI1NiJ9.eyJhdF9oYXNoIjoiX1ZFSjFtbnlQWGxsZ3NjRWJJcmVfdyIsInN1YiI6ImZiOGY1YmFmLWU0MjUtNGQ5MC1hZDE5LTdkZDZiZWE5ZWVjMSIsImF1ZCI6IjR2ZmtmNWQ0ZTlvOWV0ZjhhOXN2bHVtbjBnIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNjE2NjQ1MzA0LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0yLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMl92a2tTbmxraWwiLCJjb2duaXRvOnVzZXJuYW1lIjoidGVzdDEiLCJleHAiOjE2MTY2NDg5MDQsImlhdCI6MTYxNjY0NTMwNCwiZW1haWwiOiJyeWFuY3VtbGV5K3Rlc3QxcmVudGFkb2xwaGluQGdtYWlsLmNvbSJ9.LAnce4dLrRWc2V5e4YnNUMtaY96IS71zaKz7N48Lb1AO06P2_xeDFFuj18JPfWo9thROvzdnlWS21HyTMHZVJF6m-wy0nkXcc97-VjEIQSNU-UaJjWSZI86WcFku0HVr9_13B2C12K-eDGDhacUQN8or9dyKNNdNdOHAjHWJy4i1GYYzyJRopBQgwBUwpgNLfNOe9HWYSHbVG58-1__WsIndcCKr_Ix5FVjJ7hedBEMBIGZkeFhPVHHEE6MM0enWD3r9bYZ1g-a8CcQ5XAt7IfOzLT25rSaFk1fPUOanMbc2-goulyoq-Dz
@ryancumley
ryancumley / gist:25b5a26ca8c6e3d09ac1
Created December 28, 2014 19:02
Mapping JSON using Swift syntactic sugar in a 'Machine Translation' style from ObjC
View gist:25b5a26ca8c6e3d09ac1
//MARK: FlickrFeedItem and support
class FlickrFeedItem: NSObject {
var title: String?
var link: String?
var media: [String : String]?
var dateTaken: NSDate?
var photoDescription: String?
var published: NSDate?
var author: String?
@ryancumley
ryancumley / gist:d376c680e89a7a145a59
Created December 19, 2014 19:00
Class in closure delegate pattern for UIAlertView
View gist:d376c680e89a7a145a59
/*
Idea for this comes from https://gist.github.com/austinzheng/8fda3f61e1fd06383928#file-main-swift-L19
In an iOS 7.x supporting app which can't use UIAlertController, rather than fork execution paths based on iOS version, we could wire up an old fashioned UIAlertView this way. Still feels more 'block' based and clean to handle, since all the UIAlertViewDelegate stuff is contained within the 'nested-class-in-closure'.
*/
class SampleViewController: UIViewController {
var askTheUserSomethingAlert: UIAlertView
var strongAlertDelegate: UIAlertViewDelegate?