Skip to content

Instantly share code, notes, and snippets.

@ncipollo
ncipollo / injectable.swift
Last active September 17, 2023 12:42
Injectable
struct Injector {
func inject() -> String {
"testing 123" // simplified inject function
}
}
protocol Injectable {
static func inject(_ injector: Injector) -> Self
}
@ncipollo
ncipollo / compose.kt
Created October 29, 2021 17:42
Paparazzi + Compose
// Mock Hacks
internal object ContextSwizzle {
fun swizzle() {
ByteBuddyAgent.install()
val bridgeContextClass = contextClass()
val buddy = ByteBuddy()
buddy.redefine(bridgeContextClass)
.method(
ElementMatchers.named<MethodDescription>("getSystemService")
.and(ElementMatchers.takesArguments(String::class.java))
@ncipollo
ncipollo / FlowCallAdapterFactory.kt
Created September 16, 2019 22:36
Retrofit call adapter factory for Flow
package org.mtg.api
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import retrofit2.*
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type
class FlowCallAdapterFactory private constructor() : CallAdapter.Factory() {
companion object {