Skip to content

Instantly share code, notes, and snippets.

import java.nio.charset.StandardCharsets
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
def taskName = "uploadSonatypePublication"
if (rootProject.tasks.names.contains(taskName) == false) {
rootProject.tasks.register(taskName) {
doLast {
@InsanusMokrassar
InsanusMokrassar / generator.main.kts
Last active December 6, 2024 06:19
Folder hierarchy generator
#!/usr/bin/env kotlin
/**
* Generates files and folders as they have been put in the folder. Envs uses common syntax, but
* values may contains {{${'$'}sampleVariable}} parts, where {{${'$'}sampleVariable}} will be replaced with variable value.
* Example:
*
* .env:
* sampleVariable=${'$'}prompt # require request from command line
* sampleVariable2=just some value
* sampleVariable3=${'$'}{sampleVariable}.${'$'}{sampleVariable2}
@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