Skip to content

Instantly share code, notes, and snippets.

View rinekri's full-sized avatar
💛
Enjoying

Ilya Nekrasov rinekri

💛
Enjoying
View GitHub Profile
import io.ktor.utils.io.core.String
private const val BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
private val BASE64_INVERSE_ALPHABET = IntArray(256) { BASE64_ALPHABET.indexOf(it.toChar()) }
fun String.encodeBase64(): String = String(encodeBase64ToByteArray())
fun String.encodeBase64ToByteArray(): ByteArray = encodeToByteArray().encodeBase64()
fun ByteArray.encodeBase64ToString(): String = String(encodeBase64())
fun String.decodeBase64(): String = String(decodeBase64ToByteArray())

Build "Sources for Android 29" so you can comfortably browse the Android API source in Android Studio.

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base
@dimsuz
dimsuz / ObservableLceFilterDelay.kt
Last active September 2, 2024 09:22
RxJava2 operator which adjusts items of an LCE (loading-content-error) stream so that L (loading) and C/E (content/error) items are not emitted close to each other. This is a reactive state alternative to Android's ContentLoadingProgressBar: https://developer.android.com/reference/android/support/v4/widget/ContentLoadingProgressBar.html
package com.dimsuz.lcefilterdelay
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.Observer
import io.reactivex.Scheduler
import io.reactivex.disposables.Disposable
import io.reactivex.exceptions.Exceptions
import io.reactivex.internal.disposables.DisposableHelper
import io.reactivex.internal.fuseable.SimpleQueue
@zmts
zmts / tokens.md
Last active April 20, 2026 12:07
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
git rm -r --cached .
git add .
git commit -m "Re index done"
@JakeWharton
JakeWharton / Truss.java
Last active May 7, 2025 11:16
Extremely simple wrapper around SpannableStringBuilder to make the API more logical and less awful. Apache 2 licensed.
import android.text.SpannableStringBuilder;
import java.util.ArrayDeque;
import java.util.Deque;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */
public class Truss {
private final SpannableStringBuilder builder;
private final Deque<Span> stack;
@lifuzu
lifuzu / invoke_curl.groovy
Created April 18, 2014 19:19
using groovy to invoke curl
// Define cURL process with correct arguments.
def proc = "curl -o log/${day.format('yyyy-MM-dd')}.log "
+ "http://servername/import-data/${day.format('yyyy-MM-dd')}"
.execute()
// cURL uses error output stream for progress output.
Thread.start { System.err << proc.err }
// Wait until cURL process finished and continue with the loop.
proc.waitFor()