Skip to content

Instantly share code, notes, and snippets.

@InsanusMokrassar
InsanusMokrassar / KeyValueStore.kt
Last active December 7, 2017 03:28
KeyValueStore for android on kotlin
import android.content.Context
import android.content.SharedPreferences
import com.github.insanusmokrassar.IObjectK.interfaces.IObject
import com.github.insanusmokrassar.IObjectK.realisations.SimpleIObject
import java.io.Serializable
private val cache = HashMap<String, MutableMap<String, KeyValueStore>>()
fun Context.keyValueStore(
name: String = getString(R.string.defaultKeyValueStore)
@InsanusMokrassar
InsanusMokrassar / terminal_launch.sh
Created May 22, 2018 11:09
Shadowsocks launch functions which can be included by `source terminal_launch.sh` or by put this script in auto-start scripts such as `.bashrc`
# Return (echo) last ss-local task
proxy_task() {
echo `ps -u $USER | grep "ss-local"`
}
proxy_status() {
if [ -z "`proxy_task`" ]; then
echo "Disabled"
else
echo "Enabled"
@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>
@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 / 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
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_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
@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 / 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 / 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