Skip to content

Instantly share code, notes, and snippets.

View JUSTINMKAUFMAN's full-sized avatar

Justin Kaufman JUSTINMKAUFMAN

View GitHub Profile
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / Shared.kt
Last active April 28, 2019 17:55
Shared RIB Interface ('ChangePassword' Example)
// --------------------------------------------------------------------
// *** Shared ***
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// View.kt
// --------------------------------------------------------------------
/**
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / CrashViewController.swift
Last active September 2, 2019 18:37
Crash when mutating [UIColor] in a struct on a UIView prior to adding that view as a UIViewController's subview
import UIKit
/**
This code *consistently* crashes when built with
the following Xcode 10.2.1 build settings:
`Swift Version` = `5` (i.e. default)
`Enable Testability` = `NO`
`Optimization Level` = `-Owholemodule`
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / SSE.swift
Created July 1, 2019 17:12
Swift SSE EventSource Server for Vapor
import Foundation
import NIO
import Vapor
/**
SSE EventSource server implementation for Swift Vapor 3
Usage:
```
// Create a route for all incoming SSE connection
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / SerializationVariableFields.kt
Last active September 9, 2019 01:26
Kotlinx Serialization with Variable Fields
// What is the best way to handle deserialization of JSON
// when one of the fields can be encoded with any of
// several different names (e.g. 'judgeContent and
// 'mentorContent', which all deserialize to the
// `Contribution.content` property of `User.user_contributions`)?
@Serializable data class UserData(val name: String)
@Serializable
data class User(
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / SpeechTransformer.swift
Last active February 21, 2020 15:26
State of the art real-time verbal output transformer written in Swift
//
// SpeechTransformer.swift
// SpeechTransformer
//
// Created by Justin Kaufman 2/2/20.
// Copyright © 2020 Justin Kaufman. All rights reserved.
//
import Foundation
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / BannerConfigurator
Last active March 7, 2020 03:23
BannerConfigurator
BannerConfigurator
------------------
Parse form into JSON payload.
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / FunctionWrapper.swift
Created August 23, 2021 16:31
Function Wrapper Concept
/// Implementation
typealias AnyFunction = ((Any?, ((Any?) -> (Any?))?) -> (Any?))
@functionWrapper
struct Logging {
let value: AnyFunction
@discardableResult
func wrappedFunction(_ arguments: Any?, _ completion: ((Any?) -> (Any?))? = nil) -> Any? {
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / XCFramework.kts
Created November 3, 2021 18:53
Kotlin Multiplatform Build Gradle Task for iOS/macOS Universal Framework
/**
* Kotlin Multiplatform Universal XCFramework Task
*
* Description:
* If your project needs to target *all* possible
* iOS and macOS variants (including Apple Silicon
* hardware, ARM64 iPhone simulators, and so on),
* this task will build the frameworks, lipo those
* that can be combined into a single binary, and
* place them where Xcode expects to find them in
@JUSTINMKAUFMAN
JUSTINMKAUFMAN / index.html
Created February 1, 2023 19:55
[Test] the window height when the keyboard is open
<div class="size">Window inner width : <span id="js-width" class="value"></span> px</div>
<div class="size">Window inner height : <span class="important"><span id="js-height" class="value"></span> px</span></div>
<p>Tap on the text field below to open the keyboard on mobile devices.</p>
<div class="form">
<label for="field">Text field</label>
<input id="field" type="text"/>
</div>