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 / .bash_profile
Created June 16, 2023 17:43 — forked from hakusaro/.bash_profile
My Raspberry Pi's .bash_profile. Differences from original are purely aesthetic - no need for weather, and I like things to be lined up nicely when I ssh into my RPi.
#!/bin/bash
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
@kibotu
kibotu / WebViewClient
Last active February 13, 2023 03:27
Android WebView: resource interception and replacement by local resource
mWebView.setWebViewClient(new WebViewClient() {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
if (url.contains("creditcard_cvc.jpg")) {
Log.v("WebView", "Replacing [" + url + "] with [R.raw.tmp_replacement]");
ContentResolver contentResolver = getActivity().getContentResolver();
return new WebResourceResponse(contentResolver.getType(Uri.parse(url)), "UTF-8", getResources().openRawResource(R.raw.tmp_replacement));
}
return super.shouldInterceptRequest(view, url);
@kibotu
kibotu / viewutils.java
Created May 29, 2016 13:25
Change Status Bar color during runtime on android
public static void changeStatusBarColor(final int color) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return;
final Window window = getActivity().getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(color);
}
@kibotu
kibotu / README.md
Created January 26, 2023 08:14
gradle supply chain attack checksum check
@kibotu
kibotu / MyMapFragment.kt
Created December 26, 2016 17:09
Android: Fixing vertical/horizontal scrolling for nested maps.
/**
* @see [nested scrolling workaround](http://stackoverflow.com/a/17317176)
*/
private fun fixMapScrolling() {
transparentImage.setOnTouchListener { v, event ->
when (event.action) {
MotionEvent.ACTION_DOWN -> {
// Disallow ScrollView to intercept touch events.
scrollView.requestDisallowInterceptTouchEvent(true)
@kibotu
kibotu / GUIDE.md
Last active November 3, 2022 14:04
magic mirror steps

Magic Mirror

Introduction

I'm assembling two magic mirrors for me and my girlfriend. Based on this video tutorial: https://www.youtube.com/watch?v=fkVBAcvbrjU.

However with a slight twist. I'm also installing a webcam and microphone so we can use both mirrors for video conferences.

And finally I'm going to add voice control support using google assistant.

@kibotu
kibotu / AndroidManifest.xml
Last active October 14, 2022 11:26
Network Security Config Android
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<!-- https://developer.android.com/training/articles/security-config -->
<application android:networkSecurityConfig="@xml/network_security_config" />
</manifest>
@kibotu
kibotu / code.gs
Created July 16, 2018 15:04
Google Document Script for insert at cursor: current date and last updated date
/* opened. Use it to add custom menus to Google Docs that allow the user to run
* custom scripts. For more information, please consult the following two
* resources.
*
* Extending Google Docs developer guide:
* https://developers.google.com/apps-script/guides/docs
*
* Document service reference documentation:
* https://developers.google.com/apps-script/reference/document/
*/
@kibotu
kibotu / TimestampConvert.java
Created January 26, 2018 12:40
Timestamp converter, RFC 822, RFC 850, ANSI C's Asctime(), iso8601
/**
* Utilities for converting to/from the HTTP 1.&nbsp;0 timestamp formats.
* They are:
* <pre>
* <ul>
* <li>Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123</li>
* <li>Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036</li>
* <li>Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format</li>
* <li>2016-09-19T15:22:21+02:00 ; iso8601() format</li>
import android.graphics.Canvas
import android.graphics.Rect
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
/**
* Created with Android Studio
* User: Sergey Petrov s.a.petrov.spb@gmail.com