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 android.util.Log | |
import io.ktor.util.decodeBase64Bytes | |
import io.ktor.util.encodeBase64 | |
import okhttp3.OkHttpClient | |
import okhttp3.Request | |
import okhttp3.Response | |
import okhttp3.WebSocket | |
import okhttp3.WebSocketListener | |
import okio.ByteString | |
import org.json.JSONArray |
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
curl --location 'https://api.openai.com/v1/chat/completions' \ | |
--header 'Content-Type: application/json' \ | |
-u :$OPENAI_API_KEY \ | |
--data '{ | |
"messages": [ | |
{ | |
"role": "system", | |
"content": "The current date and time is 2023-07-22T13:57:34+02:00. Be very presumptive when guessing the values of function parameters." | |
}, | |
{ |
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
fun RepositoryHandler.enableMirror() { | |
all { | |
if (this is MavenArtifactRepository) { | |
val originalUrl = this.url.toString().removeSuffix("/") | |
urlMappings[originalUrl]?.let { | |
logger.lifecycle("Repository[$url] is mirrored to $it") | |
this.setUrl(it) | |
} | |
} | |
} |
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
[Unit] | |
Description=Docker Application Container Engine | |
Documentation=https://docs.docker.com | |
After=network-online.target docker.socket firewalld.service containerd.service time-set.target | |
Wants=network-online.target containerd.service | |
Requires=docker.socket | |
[Service] | |
Type=notify | |
# the default is not to use systemd for cgroups because the delegate issues still |
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 androidx.lifecycle.LiveData | |
import androidx.lifecycle.MediatorLiveData | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Job | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.launch | |
fun <T> LiveData<T>.debounce(duration: Long = 1000L, coroutineScope: CoroutineScope) = MediatorLiveData<T>().also { mld -> | |
val source = this |
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
class SingleLiveEvent<T> : MutableLiveData<T>() { | |
private val observers = CopyOnWriteArraySet<ObserverWrapper<T>>() | |
@MainThread | |
override fun observe(owner: LifecycleOwner, observer: Observer<T>) { | |
val wrapper = ObserverWrapper(observer) | |
observers.add(wrapper) | |
super.observe(owner, wrapper) | |
} |
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
{ | |
"theme": "light", | |
"autoUpdate": false, | |
"snippet": { | |
"expanded": true, | |
"newSnippetPrivate": false, | |
"sorting": "updated_at", | |
"sortingReverse": true | |
}, | |
"editor" : { |
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 functools | |
def log(func): | |
@functools.wraps(func) | |
def wrapper(*args): | |
print(u"request body: {}".format(args[0])) | |
response = func(*args) | |
print u"response body: {}".format(response) | |
return response |
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
/* | |
* Copyright 2016-2017 JetBrains s.r.o. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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 allows you to very easily flip between languages and country on Android. | |
This will IMMEDIATELY cause the change without even needing to shut down the target testing app. | |
(That is, the currently displayed page will reloaded.) | |
You first need to install this APP on the phone: | |
https://play.google.com/store/apps/details?id=net.sanapeli.adbchangelanguage&hl=en | |
Then to flip copy and paste one of the lines below in a terminal. |
NewerOlder