Skip to content

Instantly share code, notes, and snippets.

View blakelee's full-sized avatar

Blake Oliveira blakelee

  • Self-Employed
  • Seattle, WA
  • 21:54 (UTC -07:00)
View GitHub Profile
@blakelee
blakelee / IosAppleAuthentication.kt
Created May 10, 2025 19:29
iOS Apple Login Kotlin
class IosAppleAuthentication(
private val supabase: SupabaseClient
) : AppleAuthentication {
override suspend fun login() {
val token = getToken()
supabase.auth.signInWith(IDToken) {
provider = Apple
idToken = token
}
}
@blakelee
blakelee / IosGoogleAuthentication.kt
Created May 10, 2025 19:28
iOS Google Login Kotlin
class IosGoogleAuthentication(
private val supabaseClient: SupabaseClient,
private val application: UIApplication
) : GoogleAuthentication {
override suspend fun login() {
val token = getToken()
supabaseClient.auth.signInWith(IDToken) {
provider = Google
idToken = token
}
@blakelee
blakelee / RxJava debounce text+enter.kt
Created November 14, 2024 19:00
A sample of how to use RxJava to debounce a user typing text while also prioritizing a user pressing enter and cancelling whatever inflight debounce there was prior.
val textSubject = PublishSubject.create<String>()
val enterPressed = PublishSubject.create<String>()
val debouncedInput = textSubject.debounce(500, TimeUnit.MILLISECONDS)
.takeUntil(enterPressed)
.repeat()
val debounce = Observable.merge(
debouncedInput.map { AnnotatedString(it, SpanStyle(Color.Red)) },
enterPressed.map { AnnotatedString(it, SpanStyle(Color.Blue)) }
@blakelee
blakelee / DeferredQueue.kt
Last active September 7, 2023 06:59
A utility class for managing a queue of suspended tasks in an ordered manner with an optional "idle" callback can be invoked when the queue becomes empty.
/**
* A utility class for managing a queue of suspended tasks (represented by Deferred objects) within
* a given CoroutineScope. Tasks are executed in an ordered manner, and an "idle" callback can be
* invoked when the queue becomes empty.
*
* @param coroutineScope The CoroutineScope in which tasks will be executed.
* @param R The type of result produced by the tasks.
*/
class DeferredQueue<R>(private val coroutineScope: CoroutineScope) {
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@blakelee
blakelee / sortBySwapWithA.kt
Created June 14, 2019 21:35
Sort By swapWithA
fun main() {
val arr = ('a'..'z').shuffled().toTypedArray()
var aPos = arr.indexOf('a')
fun swapWithA(char: Char) {
val charPos = arr.indexOf(char)
arr[charPos] = 'a'
arr[aPos] = char
aPos = charPos
program QuickPlay;
type
states = (MAIN, PREFIGHT, POSTFIGHT, NONE);
var
cur: states;
client: TSCARClient;
w, h: Integer;
prev_x, prev_y: Integer;