Skip to content

Instantly share code, notes, and snippets.

View ryancumley's full-sized avatar

Ryan Cumley ryancumley

View GitHub Profile
@ryancumley
ryancumley / jwt.playground
Created November 19, 2021 04:44
JWT verification and parsing 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
//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
/*
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?