Skip to content

Instantly share code, notes, and snippets.

View veggiemonk's full-sized avatar

Julien Bisconti veggiemonk

View GitHub Profile
@veggiemonk
veggiemonk / atomic_test.go
Created November 10, 2024 13:08
quick benchmark for atomic
package main
import (
"sync"
"sync/atomic"
"testing"
)
type atom struct {
value atomic.Int64
@veggiemonk
veggiemonk / bash_aliases
Created July 6, 2024 19:05
bash aliases
alias c="clear"
alias path='echo -e ${PATH//:/\\n}' # print $PATH 1 per line
alias ports="sudo lsof -PiTCP -sTCP:LISTEN"
alias vim=nvim
alias v=nvim
alias ez="v ~/.zshrc && source ~/.zshrc"
alias es="v ~/.ssh/config"
alias eg="v ~/.gitconfig"
@veggiemonk
veggiemonk / go_resources.md
Last active September 3, 2023 19:02
Resources about Go (Golang)

Go Resources

Now and then, people ask me how to learn Go. Note that this is just my opinion, do what works for you.

The best book to learn Go and how to think in Go: https://www.gopl.io/

Don't worry about learning generics, learn the mindset and the standard library, it will save you hours of pain later.

Must read:

@veggiemonk
veggiemonk / readme.md
Created May 16, 2023 13:28
starting a fake kubernetes cluster without docker or VMs

Testing kubernetes manifests without a cluster or cluster

The start.sh script is using kwok and Go.

To delete the cluster: kowkctl delete cluster --name fake

@veggiemonk
veggiemonk / badge.go
Created April 27, 2023 09:17
utility to download badge for go test coverage
func badgedl(pct float64) error {
color := ""
switch {
case pct < 50:
color = "orange"
case pct < 60:
color = "yellow"
case pct < 70:
color = "yellowgreen"
case pct < 80:
@veggiemonk
veggiemonk / gencert.go
Created February 5, 2023 01:53
Generate a self-signed certificate in Go
package main
import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
@veggiemonk
veggiemonk / main.go
Created December 29, 2022 11:41
simple docker client
package main
import (
"context"
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
@veggiemonk
veggiemonk / kant_dark.icls
Created December 25, 2022 11:44
IntelliJ / Goland dark theme - based on https://github.com/abrookins/kant
This file has been truncated, but you can view the full file.
<scheme name="Kant Dark" version="142" parent_scheme="Darcula">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2022-12-24T19:40:03</property>
<property name="ide">GoLand</property>
<property name="ideVersion">2022.3.1.0.0</property>
<property name="modified">2022-12-24T19:40:11</property>
<property name="originalScheme">Kant Dark</property>
</metaInfo>
<option name="LINE_SPACING" value="1.2" />
@veggiemonk
veggiemonk / assert.go
Last active December 17, 2022 00:09
go testing framework with generics
package testutils
import "testing"
func equal[T comparable](a, b T) bool {
return a == b
}
func Equal[T comparable](t *testing.T, expected, actual T) {
if !equal(expected, actual) {
@veggiemonk
veggiemonk / jwt_function.sh
Created November 2, 2022 14:02
JWT with jq
# extract jwt token info
function jwtd () {
if [[ -x $(command -v jq) ]]; then
jq -R 'split(".") | .[0],.[1] | @base64d | fromjson' <<< "${1}"
echo "{\"Signature\": \"$(echo "${1}" | awk -F'.' '{print $3}')\"}"
fi
}
# Show the experiation date
# NOTE: on a mac, it needs coreutils for the date (use with `gdate`)