Skip to content

Instantly share code, notes, and snippets.

View piotrpersona's full-sized avatar
🎯
Focusing

Piotr Persona piotrpersona

🎯
Focusing
View GitHub Profile
@piotrpersona
piotrpersona / telescope.lua
Created May 20, 2023 05:50
telescope + diffview
git_commits = {
mappings = {
i = {
[null] = function()
null
local selected_entry = action_state.get_selected_entry()
local value = selected_entry.value
null
vim.api.nvim_win_close(0, true)
vim.cmd(null)
# git aliases
alias gc="git commit -sm"
alias gca="git commit -asm"
alias ga="git add"
alias gaa="git add ."
alias gp="git push"
alias gpa="git push -u origin (git rev-parse --abbrev-ref HEAD) --tags"
alias gm="git merge"
alias gch="git checkout"
alias gb="git branch"
@piotrpersona
piotrpersona / main.go
Created May 23, 2022 21:03
Options pattern
package main
import (
"fmt"
)
type engineOption func(e *Engine)
func WithFuel(fuel float64) engineOption {
return func(e *Engine) {
go install github.com/psampaz/go-mod-outdated@latest
go list -u -m -json all | go-mod-outdated -direct -update
package main
import (
"context"
"fmt"
"time"
)
func ctxSafe(ctx context.Context) {
for {
@piotrpersona
piotrpersona / main.go
Created January 5, 2022 16:03
Custom constraint golang 1.18 generics
package main
import (
"fmt"
)
type Contstraint[I, O any] interface {
Process(in I) (out O)
}
@piotrpersona
piotrpersona / docker-compose.yaml
Last active March 9, 2022 12:42
kafka docker-compose setup
version: "3.9"
services:
example-app:
image: example-app
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:19092". # this setting is important: LISTENER_DOCKER_INTERNAL://kafka:19092
KAFKA_TOPIC: "topic-name"
KAFKA_SCHEMA_REGISTRY_URL: "http://kafka-schema-registry:8081"
ports:
- "8002:8002"
@piotrpersona
piotrpersona / main.go
Created December 12, 2020 07:36
Golang multiserver
package main
import (
"context"
"fmt"
"net/http"
)
func shutdown(ready chan bool) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
git ls-files -z | xargs -0n1 git blame -w | ruby -n -e '$_ =~ /^.*\((.*?)\s[\d]{4}/; puts $1.strip' | sort -f | uniq -c | sort -n