Skip to content

Instantly share code, notes, and snippets.

View Radiokot's full-sized avatar
🐍

Oleg Koretsky Radiokot

🐍
View GitHub Profile
@Radiokot
Radiokot / rounded_corners_progress_drawable.xml
Created October 27, 2023 08:55
Android horizontal progress bar with rounded corners
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<!-- 1 dp padding makes the background thinner -->
<shape>
<corners android:radius="1dp" />
@Radiokot
Radiokot / BitMatrixDrawable.kt
Last active September 29, 2023 10:19
A scalable ZXing QR code drawable, which supports tint and transparency. Unlike a 515x515 bitmap commonly used in Android QR guides, the drawable is always sharp.
import android.content.res.ColorStateList
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.ColorFilter
import android.graphics.Paint
import android.graphics.PixelFormat
import android.graphics.RectF
import android.graphics.drawable.Drawable
import androidx.annotation.ColorInt
import com.google.zxing.common.BitMatrix
@Radiokot
Radiokot / KindleMyClippings.kt
Created May 1, 2023 11:56
Read and parse Kindle MyClippings.txt in reverse order. Kotlin, Apache commons ReversedLinesFileReader
import org.apache.commons.io.input.ReversedLinesFileReader
import org.junit.Test
import java.io.File
class KindleMyClippings {
class Clipping(
val bookDetails: String,
val date: String,
val content: String,
) {
@Radiokot
Radiokot / own-ca.md
Last active February 24, 2024 12:23
Become a Certificate Authority and issue certificates for your server and clients

Become a Certificate Authority and issue certificates for your server and clients

This guide will be helpful if you want to issue SSL certificates for your server and clients, and use them on devices without bothering with browser security warnings.

When following the guide, you'll get the output files with .crt, .key and .csr extensions, while in other OpenSSL guides you may find command examples using .pem files. Don't worry, the file contents is the same: server.crt = server-cert.pem, ca.key = ca-key.pem and so on.

Requirements:

@Radiokot
Radiokot / EdgeMinimalGoogleSearch.reg
Created November 8, 2022 09:11
Windows group policy for Edge that: 1. Disables search engines discovery; 2. Sets Google minimal search (without tracking and statistic query parameters) as default and the only one search engine
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Edge]
"ManagedSearchEngines"="[ { \"allow_search_engine_discovery\": false }, { \"is_default\": true, \"keyword\": \"google.com\", \"name\": \"Google\", \"search_url\": \"https://www.google.com/search?q={searchTerms}\", \"image_search_url\": \"https://www.google.com/searchbyimage/upload\", \"image_search_post_params\": \"encoded_image={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight}\" } ] "
@Radiokot
Radiokot / EnEmDashes.ahk
Created December 30, 2021 11:01
Mac-like en and em dashes for Windows (AutoHotKey)
; Alt + minus = En dash
!-::
Send {U+2013}
return
; Alt + Shift + minus = Em dash
+!-::
Send {U+2014}
return
@Radiokot
Radiokot / MacLikeLangSwitch.ahk
Last active December 30, 2021 11:01
Mac-like language switch for Windwos (AutoHotKey)
; Mac-like language switch (Replace Win+Space with Ctrl+Win+Space)
#SPACE::
Send ^#{SPACE}
Return
; Disable single left Windows key press
LWin & vk07::Return
LWin::Return
@Radiokot
Radiokot / ScrollingHeaderNestedScrollView.kt
Created April 16, 2021 10:18
A NestedScrollView that first scrolls itself and then the RecyclerView child. Useful for collapsing header without coordinator layout
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.core.widget.NestedScrollView
import androidx.recyclerview.widget.RecyclerView
/**
* A [NestedScrollView] that first scrolls itself and then the [RecyclerView] child.
* Useful for collapsing header without coordinator layout
*/
@Radiokot
Radiokot / ArduinoSerialToGarminTcx.kt
Created March 10, 2021 20:32
Convert Arduino speedometer serial output to the Garmin TCX file for Strava
data class RecordPoint(
val speedMph: Int,
val distanceIncrementMm: Int,
val localTime: Date,
)
@Test
fun arduinoToTcx() {
//----- CHANGE ME-------
val startDay = "2021-03-10"
@Radiokot
Radiokot / speeddial.json
Last active July 23, 2022 16:07
SpeedDial homepage
{"dials":[{"id":1,"title":"Google","url":"http://google.com","thumbnail":"https://radiokot.com.ua/Radiokot/speeddial/google.jpg","ts_created":1443342591,"visits":1432,"visits_morning":260,"visits_afternoon":505,"visits_evening":544,"visits_night":123,"position":0,"idgroup":0},{"id":2,"title":"Strava","url":"https://www.strava.com/dashboard","thumbnail":"https://radiokot.com.ua/Radiokot/speeddial/stava.png","ts_created":1443312919,"visits":754,"visits_morning":943,"visits_afternoon":1462,"visits_evening":2358,"visits_night":483,"position":1,"idgroup":0},{"id":3,"title":"Погода","url":"https://www.meteoprog.ua/ru/weather/Dnipropetrovsk/","thumbnail":"https://radiokot.com.ua/Radiokot/speeddial/weather.jpg","ts_created":1443312835,"visits":83,"visits_morning":123,"visits_afternoon":353,"visits_evening":334,"visits_night":41,"position":2,"idgroup":0},{"id":5,"title":"Deezer","url":"https://www.deezer.com/","thumbnail":"https://radiokot.com.ua/Radiokot/speeddial/music.jpg","ts_created":1443312580,"visits":13,"visit