Skip to content

Instantly share code, notes, and snippets.

View kibotu's full-sized avatar
🎯
Focusing

Jan Rabe kibotu

🎯
Focusing
View GitHub Profile
@kibotu
kibotu / BaseDialogFragment.kt
Last active July 29, 2021 14:47
BaseDialogFragment
/**
* https://github.com/exozet/AndroidCore/blob/master/core/src/main/java/com/exozet/android/core/extensions/Dialog%2BExtenions.kt
*/
abstract class BaseDialogFragment : DialogFragment() {
/**
* Current dialog layout.
*/
@get:LayoutRes
@kibotu
kibotu / Lifecycle+Extensions.kt
Last active June 4, 2021 08:47
Lifecycle.waitForLifecycleResumeEvent
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun Lifecycle.waitForLifecycleResumeEvent() = suspendCancellableCoroutine<Unit> { continuation ->
val observer = object : LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
fun onResume() {
removeObserver(this)
continuation.resume(Unit) {
// it.printStackTrace()
}
}
@kibotu
kibotu / AppBarLayoutViewHolder.kt
Created April 14, 2021 16:31
AppBarLayoutViewHolder
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.appbar.AppBarLayout
import java.io.Closeable
class AppBarLayoutViewHolder(appBarLayout: AppBarLayout) : Closeable {
var expandable: Boolean = true
set(value) {
field = value
layout?.setExpanded(value)
@kibotu
kibotu / geigercounter.py
Last active March 28, 2021 14:23
Geiger counter
import time
import datetime
import RPi.GPIO as GPIO
from collections import deque
counts = deque()
usvh_ratio = 0.00812037037037 # This is for the J305 tube
geigerChannel = 7
@kibotu
kibotu / fcm_push.sh
Last active January 29, 2024 20:27
cURL pushes for firebase cloud messaging (fcm) and huawei cloud messaging (hcm)
#!/bin/sh
set -o errexit
set -o nounset
set -o xtrace
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
@kibotu
kibotu / slide_in_down.xml
Created March 17, 2021 15:13
navigation slide up / down
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0%p"
android:toYDelta="100%p" />
</set>
@kibotu
kibotu / extract_app_version.sh
Last active March 10, 2021 07:10
Extracting app version from version-properties.gradle
#!/usr/bin/env bash
echo ">> Step: Extracting app version from versions.properties. <<"
if [ -f "version-properties.gradle" ]; then
APP_VERSION_RAW=$(grep "appVersion *=" version-properties.gradle)
else
echo "Could not detect version-properties.grade file, aborting..."
exit 1
fi
@kibotu
kibotu / quantities.kt
Created February 24, 2021 08:43
working with quantities in kotlin.
val a = listOf("a", "b", "c", "d")
val b = listOf("d", "e", "f", "a")
println("a=$a b=$b") // a=[a, b, c, d] b=[d, e, f, a]
println("combined ${a + b}") // combined [a, b, c, d, d, e, f, a]
println("union ${a.union(b)}") // union [a, b, c, d, e, f]
val ab = a.toMutableList()
ab.retainAll(b)
println("a retainAll b $ab") // a retainAll b [a, d]
val ba = b.toMutableList()
ba.retainAll(a)
@kibotu
kibotu / FragmentArgumentDelegate.kt
Last active February 15, 2021 16:09
Delegate Properties
import android.os.Binder
import android.os.Bundle
import android.os.Parcelable
import android.view.View
import androidx.core.app.BundleCompat
import androidx.fragment.app.Fragment
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
/**
@kibotu
kibotu / unluad.sh
Created February 9, 2021 12:25
Prevent MacBook from automatically starting apple music when connecting non apple ear phones.
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist