Skip to content

Instantly share code, notes, and snippets.

@AkselMeola
AkselMeola / main.go
Last active May 25, 2023 15:10
ErrGroup example
package main
import (
"fmt"
"golang.org/x/sync/errgroup"
"strconv"
"time"
)
func main() {
package main
import (
"bytes"
"encoding/json"
"fmt"
"sort"
)
type Data struct {
@AkselMeola
AkselMeola / main_test.go
Last active November 22, 2022 18:24
Benchmark investigation samples for rbac
// go test -bench Benchmark -benchmem
//
// goos: linux
// goarch: amd64
// pkg: RbacInvestigation
// cpu: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
// BenchmarkKeyMatchUrl-4 84588968 12.81 ns/op 0 B/op 0 allocs/op
// BenchmarkRegexMatchUrl-4 193255 5285 ns/op 2321 B/op 22 allocs/op
// BenchmarkRegexMatchOption-4 177576 6507 ns/op 3949 B/op 27 allocs/op
// BenchmarkOptionMatchOption-4 7389206 206.0 ns/op 48 B/op 1 allocs/op
@AkselMeola
AkselMeola / main.go
Last active October 11, 2022 19:22
Golang Progress monitor
package main
import (
"fmt"
"math"
"time"
)
type Progress struct {
current float64
@AkselMeola
AkselMeola / sample
Last active September 6, 2022 09:40
Template merge PR command
# It expects that you have github client. If not just remove ther "gh pr .." line.
# It expects bash. Not sure how it will work on other shells.
# It expects the current folder to be same as the calc worker repo name e.g. "qmt-poland-motor-link4"
# If merge fails you need to solve them manually.
BRANCH="feature/updates-merge-from-template" && \
git checkout master; git fetch --all && \
git pull && \
git fetch template && \
@AkselMeola
AkselMeola / fluentd-deployment
Created April 27, 2022 06:31
Fluentd sample
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-var-log-pods
labels:
type: local
spec:
storageClassName: local-path
accessModes:
- ReadOnlyMany
@AkselMeola
AkselMeola / phpdates.php
Last active August 16, 2016 16:46
Why is there a month difference?
<?php
/**
* Case A
*/
$a_start = new DateTime('2016-04-01', new DateTimeZone('Europe/Tallinn')); // Results in 2016-04-01 00:00:00.000000
$a_end = (new DateTime('2016-06-30', new DateTimeZone('Europe/Tallinn')))->add( new DateInterval('P1D') ); // Results in 2016-07-01 00:00:00.000000