Skip to content

Instantly share code, notes, and snippets.

View jkereako's full-sized avatar

Jeff Kereakoglow jkereako

View GitHub Profile
import Foundation
/// Synchronously wait for an asynchronous task.
///
/// Use this is if you need to execute an asynchronous task in a synchronous
/// context _and_ the result from the asynchronous task is needed before
/// execution can proceed.
func synchronouslyWait(for closure: @escaping @Sendable () async -> Void, timeout: TimeInterval = 2) {
let group = DispatchGroup()
@jkereako
jkereako / oauth-rfc.md
Last active April 19, 2024 13:21
OAuth RFCs

I couldn't keep track of all the RFCs related to OAuth. So here they are.

OAuth 2.0 RFCs

  1. [The OAuth 2.0 Authorization Framework][1]
  2. [Proof Key for Code Exchange by OAuth Public Clients][2]
  3. [OAuth 2.0 for Native Apps][3]
  4. [OAuth 2.0 Device Authorization Grant][4]

These RFCs underly the OAuth.

  1. [JSON Web Token (JWT)][5]
@jkereako
jkereako / PrintDataAsString.swift
Last active April 17, 2024 22:07
LLDB commands to print a Data object as a String. It only works if the underlying data is actually a String.
// See: http://stackoverflow.com/questions/11531353/viewing-nsdata-contents-in-xcode#25097265
po String(data: data, encoding: .utf8)
// Objective-C equivalent.
// See: http://stackoverflow.com/questions/11531353/viewing-nsdata-contents-in-xcode#19626815
// p (char *)[buffer bytes]
@jkereako
jkereako / ReCAPTCHAViewController.swift
Created September 8, 2020 13:15
ReCAPTCHA v2 in Swift
import UIKit
import WebKit
final class ReCAPTCHAViewController: UIViewController {
private var webView: WKWebView!
private let viewModel: ReCAPTCHAViewModel
init(viewModel: ReCAPTCHAViewModel) {
self.viewModel = viewModel
@jkereako
jkereako / ios-developer-reading-list.md
Last active January 15, 2024 14:23
This is a list of documents I have read and plan to read. Speaking from experience, if you take the time to pour over these documents and take notes on topics of interest, you will greatly improve your skill.

iOS developer reading list

The best way to learn and master iOS development is to read the official documentation. It can be boring but you can trust its accuracy and the information will be presented without opinion.

Read documents in order where indicated.

Topics

@jkereako
jkereako / Hash.swift
Last active January 12, 2024 17:25
Hashing in Swift
import CryptoKit
/// Hashes a string and returns it as a string.
func hash(_ string: String) -> String {
guard let data = string.data(using: .utf8) else { return "null" }
return SHA256
.hash(data: data)
.map { String(format: "%02x", $0) }
@jkereako
jkereako / resetxc.sh
Last active November 8, 2023 15:09
Reset Xcode
#!/usr/bin/env bash
#
# resetxc
#
# Kills Xcode, deletes all caches and build artifacts and re-opens Xcode
set -Eeuo pipefail
# Print out error messages to STDERR.
function err() {
US-AL
US-AK
US-AZ
US-AR
US-CA
US-CO
US-CT
US-DE
US-FL
US-GA
@jkereako
jkereako / ip.sh
Last active October 18, 2023 13:58
Prints the current SSID name and the local and public IP addresses
#!/usr/bin/env bash
#
# ip
#
# Shows the local and public IP addresses
set -Eeuo pipefail
# Print out error messages to STDERR.
function err() {
@jkereako
jkereako / NetworkClient.swift
Last active October 18, 2023 13:21
Networking
import Foundation
public enum HTTPMethod: String {
case get = "GET"
case post = "POST"
case put = "PUT"
case delete = "DELETE"
}
public enum NetworkError: Error {