Skip to content

Instantly share code, notes, and snippets.

@InsanusMokrassar
InsanusMokrassar / RequestAccessToAllFilesContract.kt
Created May 15, 2021 16:41
Android contract to request permission for all files access getting
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Environment
import android.provider.Settings
import androidx.activity.result.contract.ActivityResultContract
import androidx.annotation.RequiresApi
@RequiresApi(Build.VERSION_CODES.R)
object RequestAccessToAllFilesContract : ActivityResultContract<Unit, Boolean>() {
@InsanusMokrassar
InsanusMokrassar / GetMe.kt
Created February 10, 2021 18:45
Examples of TelegramBotAPI library work
suspend fun main(vararg args: String) {
val botToken = args.first()
val bot = telegramBot(botToken)
println(bot.getMe())
}
@InsanusMokrassar
InsanusMokrassar / changelog_parser.sh
Last active October 16, 2020 15:37
Changelog parser and gradle github release script
#!/bin/bash
function parse() {
version="$1"
while IFS= read -r line && [ -z "`echo "$line" | grep -e "^#\+ $version"`" ]
do
: # do nothing
done
@InsanusMokrassar
InsanusMokrassar / http-to-https.conf
Created September 8, 2020 11:36
NGinx auto redirect to https
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
@InsanusMokrassar
InsanusMokrassar / BroadcastFlow.kt
Created September 1, 2020 07:12
Hybrid of BroadcastChannel and Flow
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
@Suppress("FunctionName")
fun <T> BroadcastFlow(
internalChannelSize: Int = Channel.BUFFERED
): BroadcastFlow<T> {
val channel = BroadcastChannel<T>(internalChannelSize)
return BroadcastFlow(
@InsanusMokrassar
InsanusMokrassar / fix_reset_session_after_lock
Created October 8, 2019 05:48
Elementary OS reset session after screen lock or suspend fix
#!/bin/bash
rm ~/.config/monitors.xml*
exit 0
version: "3.4"
services:
grafana:
image: grafana/grafana
container_name: grafana
restart: always
volumes:
- "/path/host/grafana:/var/lib/grafana:rw"
environment:
@InsanusMokrassar
InsanusMokrassar / fix_keyboard
Last active May 24, 2020 06:26
In Elementary OS sometimes stortcuts (like Super + T) is not working. I have created this script as temporal resolve of this problem until it will be resolved by Elementary OS developers
#!/bin/bash
function send_notification() {
notify-send -u low -i keyboard -c system "Shortcuts fixer" "$1"
}
function assert_success() {
"${@}"
local status=${?}
if [ ${status} -ne 0 ]; then
@InsanusMokrassar
InsanusMokrassar / NginxSSL.conf
Created February 27, 2019 06:36
This gist contains template for Nginx server configuration with ssl and reverse proxy
server {
server_name $HOST_NAME;
ssl_certificate $PATH_TO_PUBLIC_CERTIFICATE_PART;
ssl_certificate_key $PATH_TO_PRIVATE_CERTIFICATE_PART;
listen 443 ssl;
keepalive_timeout 60;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@InsanusMokrassar
InsanusMokrassar / defaults.xml
Created September 4, 2018 02:27
Android default resources
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Default colors -->
<color name="shadowBackgroundColor">#80aaaaaa</color>
<color name="positiveColor">#aa4caf50</color>
<color name="warningColor">#aaf2fd02</color>
<color name="negativeColor">#aaff0000</color>