Skip to content

Instantly share code, notes, and snippets.

View arshamalh's full-sized avatar
:octocat:
This Octacat is my pet!

Mohammad Reza Karimi arshamalh

:octocat:
This Octacat is my pet!
View GitHub Profile
@arshamalh
arshamalh / tick_at_time.go
Created August 7, 2025 14:43
Tick at specific times everyday
package main
import (
"errors"
"strconv"
"strings"
"time"
)
var (
@arshamalh
arshamalh / session_based_ticker.go
Last active July 26, 2025 05:23
Session Based Ticker
package main
import (
"fmt"
"time"
)
type SessionBasedTicker struct {
start time.Time
end time.Time
@arshamalh
arshamalh / capedSortedInsert.go
Created July 22, 2025 08:43
Caped sorted insert for already sorted slices
// Inserts new item to a sorted list by still keeping it sorted and keeping the length to at most "max" elements.
func CapedSortedInsert[T any](items []T, item T, max int, cmpValue func(a, b T) int) []T {
insertionIndex := len(items)
for i, val := range items {
if cmpValue(item, val) == 1 {
insertionIndex = i
break
}
}
@arshamalh
arshamalh / docker-compose.yaml
Last active October 15, 2024 09:33
Docker compose file for Jaeger all-in-one with OpenTelemetry collector support
version: '3.8'
services:
jaeger:
image: jaegertracing/all-in-one:1.51 # At least 1.35 if you want to have enabled collector
container_name: jaeger
environment:
- COLLECTOR_ZIPKIN_HOST_PORT=:9411
- COLLECTOR_OTLP_ENABLED=true
ports: # Some ports are optional or deprecated, but we still let them be here as it's a general snippet
- "5775:5775/udp" # agent accept zipkin.thrift over compact thrift protocol (deprecated, used by legacy clients only)
@arshamalh
arshamalh / deploy.yaml
Created August 9, 2023 05:46
Ldap client deployment file for Kubernetes
kind: Deployment
apiVersion: apps/v1
metadata:
name: ldapclient
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: ldapclient
@arshamalh
arshamalh / .zshrc
Last active August 9, 2024 09:15
My .zshrc config file including tools and aliases
autoload -Uz compinit && compinit
eval "$(starship init zsh)"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
if [ $commands[oc] ]; then
source <(oc completion zsh)
compdef _oc oc
fi
@arshamalh
arshamalh / interactiveShell.go
Last active November 2, 2022 08:55
Go simple interactive shell
package main
import (
"fmt"
"time"
)
const (
msg_welcome string = `
Welcome to Dockeroller!
@arshamalh
arshamalh / Dockerfile
Last active September 21, 2023 23:11
Go and UI Multistage Dockerfile
FROM golang:1.21-alpine3.18 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -o main .
FROM node:18-alpine3.15 AS frontend
WORKDIR /ui
COPY ui .
@arshamalh
arshamalh / jwt_interval.go
Created June 10, 2022 21:57
Golang JWT and intervals (using goroutines and channels)
package main
import (
"fmt"
"time"
"github.com/golang-jwt/jwt"
)
func main() {
@arshamalh
arshamalh / keybindings.json
Last active February 23, 2025 11:42
my vscode settings
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "cmd+b",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
{
"key": "cmd+k",
"command": "-workbench.action.terminal.clear",