Skip to content

Instantly share code, notes, and snippets.

View monosoul's full-sized avatar
🖖
To boldly code what no one has coded before

Andrei Nevedomskii monosoul

🖖
To boldly code what no one has coded before
View GitHub Profile
@monosoul
monosoul / karabiner.json
Last active July 15, 2019 13:53
Karabiner configuration to get Windows-like keymap in IntelliJ idea
{
"description": "ctrl/command swap",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$"
],
"type": "frontmost_application_if"
@monosoul
monosoul / .prompt-colors
Created October 20, 2021 11:12
Nice bash prompt
# using tput commands
FGBLK=$( tput setaf 0 ) # 000000
FGRED=$( tput setaf 1 ) # ff0000
FGGRN=$( tput setaf 2 ) # 00ff00
FGYLO=$( tput setaf 3 ) # ffff00
FGBLU=$( tput setaf 4 ) # 0000ff
FGMAG=$( tput setaf 5 ) # ff00ff
FGCYN=$( tput setaf 6 ) # 00ffff
FGWHT=$( tput setaf 7 ) # ffffff
@monosoul
monosoul / README.md
Last active February 8, 2023 10:46
Use DD agent 1.7.0
@monosoul
monosoul / TracingUtils.kt
Created March 27, 2023 11:18
DataDog Tracing utils for Kotlin coroutines
import datadog.trace.api.DDTags
import io.opentracing.Span
import io.opentracing.Tracer
import io.opentracing.log.Fields
import io.opentracing.tag.Tags
import io.opentracing.util.GlobalTracer
suspend fun <T : Any, O> T.coRunTraced(
methodName: String,
block: suspend T.(Span) -> O,
@monosoul
monosoul / WithMdc.kt
Last active April 14, 2023 15:02
MDC helper function for Kotlin
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.slf4j.MDCContext
import kotlinx.coroutines.withContext
import org.slf4j.MDC
inline fun <T> withMdc(vararg attributes: Pair<String, Any?>, block: () -> T): T {
val oldAttributes = MDC.getCopyOfContextMap() ?: emptyMap()
attributes.forEach { (key, value) ->
value?.apply {
MDC.put(key, toString())
@monosoul
monosoul / get_table_partitions_sizes.sql
Created April 26, 2023 08:33
Get all table/partition sizes
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
LEFT OUTER JOIN pg_inherits I ON (C.relfilenode = I.inhrelid OR C.relfilenode = I.inhparent)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
AND I.inhrelid is null
UNION ALL
@monosoul
monosoul / settings.gradle.kts
Last active May 17, 2023 10:11
DSL for declaring Gradle modules
// usage example
includeTree {
module("app") {
dir("domain") {
module("domain-api")
module("domain-impl")
}
dir("persistence) {
module("persistence-api")
@monosoul
monosoul / default.conf.template
Created August 19, 2023 01:33
Unprivileged nginx with custom UID and templates
server {
listen 8080;
server_name .${REDIRECT_FROM};
return 301 $scheme://${REDIRECT_TO}$request_uri;
}