Skip to content

Instantly share code, notes, and snippets.

li2 / gist:f32b90da96e6c1dba1c1e2221c295904
Created January 9, 2024 22:55
Ktor headers case-insensitive, set append
View gist:f32b90da96e6c1dba1c1e2221c295904
headers {
set("header-abc", "abc")
set("header-ABC", "ABC")
append("header-xyz", "xyz")
append("header-XYZ", "XYZ")
2024-01-10 11:53:39.983 [outine#6] INFO io.ktor.client.HttpClient
METHOD: HttpMethod(value=GET)
li2 / MyAndroidApplication.kt
Created August 20, 2023 22:46 — forked from sebaslogen/MyAndroidApplication.kt
Finish all opened activities in my Android app (also across different tasks)
View MyAndroidApplication.kt
class MainApplication : Application() {
private val createdActivities = mutableListOf<WeakReference<Activity>>()
override fun onCreate() {
fun closeAllActivities() {
li2 /
Last active March 28, 2023 23:48
Rfw demo

dart run encode.dart alert.rfwtxt alert.rfw

li2 /
Created May 14, 2021 11:08
AWS IoT FleetProvisioningSample mvn command
mvn exec:java -Dexec.mainClass="identity.FleetProvisioningSample" \
-Dexec.args="--endpoint {yourEndpoint} \
--rootca {yourRootCaPath}.pem \
--cert {yourCertPath}.pem.crt \
--key {yourPrivateKeyPath}.pem.key \
--templateName {yourTemplateName}
--templateParameters {\"serialNumber\":Mac21}" -e -X
li2 / Android Privacy Policy
Last active June 13, 2020 06:47 — forked from alphamu/Android Privacy Policy Template
Privacy policy for Android apps
View Android Privacy Policy
<!DOCTYPE html>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width'>
<title>Privacy Policy</title>
<style> body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; padding:1em; } </style>
<strong>Privacy Policy</strong> <p>
View queryTextChanges.kt
* Return query text changes observable.
* - filter: to filter undesired text like blank text to avoid unnecessary API call.
* - debounce: to ignore the previous items in the given time and only emit the last one, to avoid too much API calls.
* - distinctUntilChanged: to avoid the duplicate API call.
fun EditText.queryTextChanges(): Observable<String> {
return textChanges()
.map { it.toString() }
View ViewTest.kt
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
class ViewTest {
private lateinit var firstColour: Colour
private lateinit var secondColour: Colour
private lateinit var overlappedColour: Colour
View chart.kt
import kotlin.math.roundToInt
* Colour in RGB, with each value between 0 – 255 (e.g. R=255, G=0, B=0 would imply a red chart)
* @throws IllegalArgumentException if one of the parameters [r], [g] and [b] is out of bound [0, 255]
data class Colour(val r: Int, val g: Int, val b: Int) {
init {
li2 /
Created October 29, 2018 02:39 — forked from joinAero/
Android - The bluetooth listener and profile proxy.
package cc.cubone.turbo.core.bluetooth;
* Interface definition for a callback to be invoked when bluetooth state changed.
public interface BluetoothCallback {
* Called when the bluetooth is off.
li2 /
Created October 29, 2018 01:37 — forked from magillus/
RxJava2.0 Broadcast Receiver for getting intent broadcasts as Observable<Intent>
* RxJava based broadcast reciever that registers its local BroadcastReceiver until end of subscription.
* Listens for update and passes Intent to the Stream (Subscriber).
* Copyright 2016 Mateusz Perlak -
* Created on 11/18/16.
public class RxBroadcastReceiver implements ObservableOnSubscribe<Intent> {
protected final WeakReference<Context> contextWeakReference;