This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from "react"; | |
type GestureType = | |
| "swipeUp" | |
| "swipeDown" | |
| "swipeLeft" | |
| "swipeRight" | |
| "tap" | |
| "pinch" | |
| "zoom"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
@propertyWrapper | |
struct SimpleUserDefault<T> { | |
let userDefaults: UserDefaults | |
let key: String | |
let defaultValue: T | |
init( | |
userDefaults: UserDefaults = UserDefaults.standard, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@_functionBuilder struct SwitchExpression { | |
static func buildBlock<T>(_ content: T) -> T { | |
return content | |
} | |
static func buildEither<T>(first: T) -> T { | |
return first | |
} | |
static func buildEither<T>(second: T) -> T { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension LoginViewController: WKNavigationDelegate { | |
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { | |
if let url = webView.url, url.absoluteString.contains("/index.action") { | |
let store = WKWebsiteDataStore.default().httpCookieStore | |
store.getAllCookies { cookies in | |
if let sessionIdCookie = cookies.first(where: { cookie in | |
cookie.name == "JSESSIONID" | |
}) { | |
HTTPCookieStorage.shared.setCookies(cookies, for: webView.url, mainDocumentURL: nil) | |
self.callback(ConfluenceSessionCookie(jSessonId: sessionIdCookie)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class AmplitudeController { | |
static let shared = AmplitudeController() | |
private let amplitudeInstance = Amplitude.instance() | |
private var globalProperties: [String: Any] = [:] | |
func initialise() { | |
self.amplitudeInstance.initializeApiKey("bda1f35c62f39a02dc6d4cbf416f9bb8") | |
self.globalProperties = [ | |
"appVersion": AppEnvironment.version, | |
"buildNumber": AppEnvironment.buildNumber, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.cinterop.memScoped | |
import kotlinx.cinterop.allocArrayOf | |
import kotlinx.cinterop.addressOf | |
import kotlinx.cinterop.usePinned | |
import platform.Foundation.NSData | |
import platform.Foundation.create | |
import platform.posix.memcpy | |
public fun ByteArray.toData(): NSData = memScoped { | |
NSData.create(bytes = allocArrayOf(this@toData), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect(issue.createdAt).to(equal( | |
Helper.date(["$date": NSNumber(value: value1)]) | |
)) | |
expect(followers).to(containExactUnorderedElements([ | |
Follower( | |
followerUid: "a", | |
followerType: .group | |
), | |
Follower( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
// Note: There are some issues with using these modifiers inside of ButtonStyles on macOS. Please see https://twitter.com/noahsark769/status/1288256379640139776?s=20 for more info. | |
struct ConditionalContent<TrueContent: View, FalseContent: View>: View { | |
let value: Bool | |
let trueContent: () -> TrueContent | |
let falseContent: () -> FalseContent | |
@ViewBuilder var body: some View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following is a code sample based on https://twitter.com/noahsark769/status/1264681181435420672?s=20 | |
// It's not really done, but putting it here for the benefit of the community. Maybe at some point soon I'll open source | |
// this into a proper library. | |
// | |
// What it does: Defines a ConstraintSystem SwiftUI view which allows you to specify autolayout constraints between views. | |
// | |
// Caveats: | |
// - Only works for AppKit/NSView/NSViewRepresentable, not UIKit yet | |
// - Only works on the first render (update(nsView) implementation is empty) | |
// - The constraint identifiers must be strings, it would be nice to make them generic over some type that is Hashable, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://noahgilmore.com/blog/nesting-property-wrappers | |
import Cocoa | |
protocol Appendable { | |
func appending(string: String) -> Self | |
} | |
extension String: Appendable { | |
func appending(string: String) -> String { |
NewerOlder