Skip to content

Instantly share code, notes, and snippets.

View tomczyn's full-sized avatar

Maciej Tomczyński tomczyn

View GitHub Profile
@tomczyn
tomczyn / git.fish
Created March 1, 2025 09:40
git.fish
# Helper functions
function git_current_branch
git branch --show-current
end
function git_main_branch
command git rev-parse --git-dir &>/dev/null || return
for ref in refs/heads/main refs/heads/trunk refs/heads/mainline refs/heads/default refs/heads/master
if command git show-ref -q --verify $ref
echo (string split -r -m1 / $ref)[2]
@tomczyn
tomczyn / HttpClientExtensions.kt
Created March 22, 2023 13:56
Ktor Extensions
import arrow.core.left
import arrow.core.right
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.plugins.auth.Auth
import io.ktor.client.plugins.auth.providers.BearerAuthProvider
import io.ktor.client.plugins.plugin
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.get
import io.ktor.client.request.post
@tomczyn
tomczyn / StateInMerge.kt
Last active November 8, 2023 12:31
StateInMerge - Extension for MutableStateFlow to safely merge flows into single StateFlow for view state
package com.example
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
/**
* Merges the given flows into a new [MutableStateFlow] with the provided initial state,
* scope, and launch strategy.
*
* @param T The type of the state held by the [MutableStateFlow].
@tomczyn
tomczyn / hello_world.kt
Created September 23, 2022 09:29
Hello, world!
fun main() {
println("Hello, world!")
}