Skip to content

Instantly share code, notes, and snippets.

View dellisd's full-sized avatar
🗺️

Derek Ellis dellisd

🗺️
View GitHub Profile
@dellisd
dellisd / h3.json
Created July 23, 2023 20:41
Kotlin Jupyter Geospatial Library Descriptors
{
"description": "H3-java",
"properties": [ { "name": "v", "value": "4.1.1" } ],
"link": "https://github.com/uber/h3-java",
"dependencies": [ "com.uber:h3:$v" ],
"imports": [
"com.uber.h3core.H3Core",
"com.uber.h3core.util.LatLng"
]
}
external class GeolocationCoordinates {
val latitude: Double
val longitude: Double
val altitutde: Double
val accuracy: Double
val altitudeAccuracy: Double
val heading: Double
val speed: Double
}
@dellisd
dellisd / Test.kt
Created June 9, 2022 16:37
Explicit Backing Fields
class Test {
val names: List<String>
field: MutableList<String> = mutableListOf<String>()
fun doThing() {
names.add("Hello!")
}
}
fun main() {
@dellisd
dellisd / AppComponent.kt
Created December 21, 2021 01:53
Compose for Web + kotlin-inject
@Component
abstract class AppComponent {
@Provides
protected fun test(): Test = Test("Inject")
abstract val application: Application
}
import kotlinx.coroutines.runBlocking
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.koin.core.context.startKoin
import org.koin.dsl.module
class SharedAny(private val provider: suspend () -> Any) {
private var any: Any? = null
suspend operator fun <R> invoke(block: (Any) -> R): R {
/**
* Like a progress indicator, but drawn as an arc.
*
* @param progress The progress to indicate, or how much of the arc should be shaded, as a percentage
* @param color The color of the arc
* @param width The width of the stroke used to draw the arc
*/
@Composable
fun ProgressArc(
progress: Float,
@dellisd
dellisd / Resource.kt
Last active December 28, 2023 11:33
Kotlin Multiplatform test resources
// Common
const val RESOURCE_PATH = "./src/commonTest/resources"
expect class Resource(name: String) {
val name: String
fun exists(): Boolean
fun readText(): String
}
fun main() {
val k = readLine()!!.toInt()
for (i in 0 until k) {
val s = readLine()!!
val t = readLine()!!
var offset = 0
var answer = true
t.forEachIndexed { index, c ->
@dellisd
dellisd / MainActivity.java
Last active May 9, 2018 19:36
How to check for night mode without using AppCompat.DayNight theme
package ca.llamabagel.daynight;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {