Skip to content

Instantly share code, notes, and snippets.

View osipxd's full-sized avatar
I may be slow to respond.

Osip Fatkullin osipxd

I may be slow to respond.
View GitHub Profile
osipxd / !
Last active May 18, 2024 15:56
Paper versions links
osipxd / .editorconfig
Last active May 16, 2024 22:36
EditorConfig for Android projects with mapping to IntelliJ IDEA's config
root = true
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
osipxd / setLocale.kt
Last active April 15, 2024 12:15
Set locale in Android application
import android.content.ComponentCallbacks
import android.content.Context
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import java.util.Locale
private const val LANGUAGE_RU = "ru"
osipxd / ImmutableList.kt
Last active March 28, 2024 00:19
Transparent wrapper making lists Immutable for compose.
/** Wrapper over the given [list] for Compose to mark this list as [Immutable]. */
value class ImmutableList<T>(private val list: List<T>) : List<T> by list
/** Returns empty list marked as [Immutable]. */
inline fun <T> immutableListOf(): ImmutableList<T> = ImmutableList(emptyList())
/** Returns a new [Immutable] list of given [elements]. */
osipxd /
Last active March 25, 2024 15:55
Script preparing Android project cache for GitLab CI
#!/usr/bin/env bash
set -eu
function get_gradle_slug() {
local dist
dist=$(source gradle/wrapper/ && echo "${distributionUrl?:}")
osipxd /
Last active February 7, 2024 19:01
Print current Mac wattage (with accuracy up to minute)
#!/usr/bin/env bash
set -euo pipefail
function extract_float_field() {
ioreg -rw0 -c AppleSmartBattery |
grep BatteryData |
sed -E "s/.*\"$field\"=([0-9]+).*/\1/" |
xargs -I % lldb --batch --source-quietly --one-line "print/f %" | # Convert IEEE-754 float
osipxd /
Last active January 24, 2024 04:08
Редактирование номера телефона SIM-карты на Android

Что нужно?

  • Root
  • ADB (или любое приложение Terminal на телефоне)



Подключитесь к телефону через ADB и в открывшейся консоли переключитесь в режим Super User:

osipxd / 1. Автоматизации и инфраструктура вместо рутины и бойлерплейта.md
Last active October 20, 2023 13:04
Автоматизации и инфраструктура вместо рутины и бойлерплейта

Автоматизации и инфраструктура вместо рутины и бойлерплейта

Материалы к докладу на митап red_mad_robot 15.12.2022

YouTube | Презентация

1. Качество кода

osipxd / MakeDebuggableTask.kt
Last active March 6, 2023 11:18
The task to add debuggable=true to obfuscated Android builds
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
/** Adds `android:debuggable="true"` to the manifest. */
abstract class MakeDebuggableTask : DefaultTask() {
osipxd / DataStoreNullableSerializer.kt
Last active November 21, 2022 10:17
Base Serializer class to store nullable values in DataStore
import androidx.datastore.core.DataStore
import androidx.datastore.core.Serializer
abstract class NullableSerializer<T : Any> : Serializer<T?> {
override val defaultValue: T? = null
final override suspend fun readFrom(input: InputStream): T? {