Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Jan Rabe kibotu

🎯
Focusing
View GitHub Profile
View AppBarLayoutViewHolder.kt
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 Mar 28, 2021
Geiger counter
View geigercounter.py
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 Mar 24, 2021
cURL pushes for firebase cloud messaging (fcm) and huawei cloud messaging (hcm)
View fcm_push.sh
#!/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 Mar 17, 2021
navigation slide up / down
View slide_in_down.xml
<?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 Mar 10, 2021
Extracting app version from version-properties.gradle
View extract_app_version.sh
#!/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 Feb 24, 2021
working with quantities in kotlin.
View quantities.kt
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)
View FragmentArgumentDelegate.kt
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 Feb 9, 2021
Prevent MacBook from automatically starting apple music when connecting non apple ear phones.
View unluad.sh
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist
View StaticTests.kt
private object Buddy {
@JvmStatic
fun name(): String = "John"
@JvmStatic
fun hello(name: String) = name
}
class StaticTests {
@kibotu
kibotu / build.gradle
Created Dec 31, 2020
bundle into asset folder android dependencies
View build.gradle
android.applicationVariants.all { variant ->
task "listDependencies${variant.name.capitalize()}"() {
outputs.upToDateWhen { false }
doLast {
println "Depdencies for ${variant.name.capitalize()}\n"
final String filePath = "${project.rootDir}/app/src/main/assets/dependencies.txt"
def assetFolder = new File("${project.rootDir}/app/src/main/assets/")
if (!assetFolder.exists())