Skip to content

Instantly share code, notes, and snippets.

View RankoR's full-sized avatar
🏠
Working from home

Artem Smirnov RankoR

🏠
Working from home
View GitHub Profile
@RankoR
RankoR / FlowBroadcastReceiver.kt
Created January 31, 2023 13:08
Flow broadcast receiver
package page.smirnov.sample
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
ssh -NR 9091:localhost:9091 user@server
@RankoR
RankoR / Fast 2D DCT 32*32
Last active April 2, 2021 20:59
Fast 2D DCT implementation for 32*32 array, but can be adapted for any fixed dimension. Inspired by the CocoaImageHashing impl for iOS.
package pro.labster.dct
import kotlin.math.cos
import kotlin.math.sqrt
/**
* Around 20x faster than a naive implementation
*/
class DctAlgorithm2DFast : DctAlgorithm {
class Json() : JSONObject() {
constructor(init: Json.() -> Unit) : this() {
this.init()
}
infix fun String.to(value: Json) {
put(this, value)
}
set encoding=utf-8
set mouse=
set tabstop=4
set shiftwidth=4
set expandtab
set number
syntax on
set et
@RankoR
RankoR / Snackbars.kt
Created November 6, 2018 16:08
Extend Espresso to make Snackbar testing easier. Note: this code works only for AndroidX.
import androidx.annotation.StringRes
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.matcher.ViewMatchers
import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.allOf
fun onSnackbar(@StringRes withText: Int): ViewInteraction {
return onView(
CoreMatchers.allOf(
# letsencrypt certonly -a webroot --webroot-path=/opt/web -d domain.com
# crontab -e
30 2 * * 1 letsencrypt renew
35 2 * * 1 service nginx reload
@RankoR
RankoR / .screenrc
Last active May 7, 2022 21:59
.screenrc
altscreen on
term screen-256color
hardstatus off
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
startup_message off
termcapinfo xterm* ti@:te@