Skip to content

Instantly share code, notes, and snippets.

@NikolayKul
NikolayKul / tasks.json
Created August 3, 2019 23:30
Tasks for Visual Studio Code to run/debug Godot scenes/scripts
{
"version": "2.0.0",
"tasks": [
{
"label": "Run game",
"type": "shell",
"command": "PATH_TO_YOUR_GADOT_EXEC", // <----
"args": [
"--path",
"${workspaceFolder}",
@NikolayKul
NikolayKul / CallExt.kt
Last active June 21, 2018 11:17
An extension for Retorfit's Call<T> to wrap it into a suspended fun
suspend fun <T> Call<T>.await(): T = suspendCancellableCoroutine { cont ->
cont.invokeOnCompletion { cancel() }
enqueue(object : Callback<T> {
override fun onFailure(call: Call<T>, t: Throwable) {
cont.resumeWithException(t)
}
override fun onResponse(call: Call<T>, response: Response<T>) {
if (response.isSuccessful) {
cont.resume(response.body()!!)
/*
Related SO question: https://stackoverflow.com/questions/47990179/round-corners-itemdecoration/48003946
*/
public class AttachmentMediaCornersDecoration extends RecyclerView.ItemDecoration {
private final float radius;
private final RectF defaultRectToClip;
private final List<Integer> allowedViewTypes = Arrays.asList(
AttachmentImageViewItem.VIEW_TYPE,
AttachmentVideoViewItem.VIEW_TYPE,
AttachmentBlurViewItem.VIEW_TYPE);
@NikolayKul
NikolayKul / Converters.kt
Created May 4, 2018 13:32
Android Room @TypeConverter example in Kotlin
/*
Singleton that contains all `@TypeConverter`s of the app.
Mark all inner converters with `@JvmStatic` so Room can use them as regular static functions
*/
object Converters {
@TypeConverter
@JvmStatic
fun convertDateFrom(value: Date?): Long? = value?.time