Skip to content

Instantly share code, notes, and snippets.

@lub0s
lub0s / ReentrantMutex.kt
Created January 14, 2025 13:10 — forked from elizarov/ReentrantMutex.kt
ReentrantMutex implementation for Kotlin Coroutines
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
package cache
import (
"container/list"
"sync"
)
type Cache[K comparable, V any] interface {
Get(key K) V
Put(key K, value V) V
class HashMap:
def __init__(self, size):
self.hashmap = [None for i in range(size)]
def insert(self, key, value):
self.resize()
index = self.key_to_index(key)
self.hashmap[index] = (key, value)
class HashMap:
def __init__(self, size):
self.hashmap = [None for i in range(size)]
def insert(self, key, value):
self.resize()
index = self.key_to_index(key)
self.hashmap[index] = (key, value)
@lub0s
lub0s / better-git-branch.sh
Created March 25, 2024 09:59 — forked from schacon/better-git-branch.sh
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@lub0s
lub0s / icons.sh
Last active February 12, 2024 13:36
reduce padding for macos topbar icons to prevent notch from hiding them
# 0 - 6. Always reset the session after these:
defaults -currentHost write -globalDomain NSStatusItemSelectionPadding -int 6
defaults -currentHost write -globalDomain NSStatusItemSpacing -int 6
# Revert to the original values
defaults -currentHost delete -globalDomain NSStatusItemSelectionPadding
defaults -currentHost delete -globalDomain NSStatusItemSpacing
@lub0s
lub0s / CircularReveal.kt
Created August 24, 2023 16:19 — forked from darvld/CircularReveal.kt
A circular reveal effect modifier for Jetpack Compose.
package cu.spin.catalog.ui.components
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.updateTransition
import androidx.compose.runtime.State
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset

Automating Daily Reports, because fuck it, really...

Each day at our company, developers are required to document their activities, painstakingly jotting down their daily work and future plans. A monotonous chore that I just really dislike.

So now, there's a scribe for that :

auto-dr-

Code

@lub0s
lub0s / tmux.md
Created November 8, 2022 22:05 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@lub0s
lub0s / compose_offsets.kt
Created April 15, 2022 11:42
Difference in recomposition when using offset modfier in Jetpack Compose
@HiltViewModel
class UpdatingViewModel @Inject constructor() : ViewModel() {
val offset = mutableStateOf(Offset(0f, 0f))
init {
viewModelScope.launch {
while(isActive) {
delay(50)
offset.value = offset.value.copy(x = offset.value.x + 1)