Skip to content

Instantly share code, notes, and snippets.

View mdouchement's full-sized avatar
♨️
❨╯°□°❩╯︵┸━┸

mdouchement mdouchement

♨️
❨╯°□°❩╯︵┸━┸
View GitHub Profile
@mdouchement
mdouchement / boot-docker.sh
Last active March 9, 2024 22:06
Restore Docker on TrueNAS SCALE 23 and above (no Kubernetes)
#!/usr/bin/env bash
# Using Docker on TrueNAS SCALE 23+ (no Kubernetes)
#
# Don't setup Apps via the TrueNAS Web GUI (don't choose a pool for Apps when asked).
# Make a dedicated docker dataset on one of your data pools.
#
# Store this script somewhere else on your pool (not in the Docker dataset).
# Download binaries archive from https://download.docker.com/linux/static/stable/x86_64/ and unarchive them in a `docker' folder in the same directory.
# Make a daemon.json file in the same directory with the following contents:
@mdouchement
mdouchement / steam-link.md
Last active December 29, 2023 08:49
Steam Link SSH & how to disable Bluetooth
@mdouchement
mdouchement / lehmer.go
Last active September 11, 2020 17:48
Lehmer random bytes slice generator
package main
import (
"fmt"
"time"
)
func main() {
seed := uint64(time.Now().UnixNano())
p := make([]byte, 128)
@mdouchement
mdouchement / Dockerfile
Created October 6, 2019 14:22
Custom Dockerfile for github.com/root-gg/plik
# build stage
FROM golang:1.13-alpine as build-env
MAINTAINER mdouchement
# Set the locale
ENV LANG c.UTF-8
# Install build dependencies
RUN apk upgrade
RUN apk add --update --no-cache \
@mdouchement
mdouchement / gvm_disable_gopath_handling.go
Last active September 25, 2018 13:15
Disable GVM GOPATH handling
// This Go script will disable annoying GVM GOPATH management.
// Based on https://github.com/e-nikolov/gvm repository
//
// MIT License
package main
import (
"bytes"
"fmt"
@mdouchement
mdouchement / camelcase.go
Created November 16, 2017 16:58
Golang camelcase / camelize
package main
import (
"fmt"
"unicode"
)
func main() {
for _, v := range []string{"target_prob1", "target_prob_1", "_target_prob_1", "target_prob_1_"} {
fmt.Printf("%s => %s\n", v, ToCamel(v))
@mdouchement
mdouchement / .gitrc.sh
Last active December 19, 2018 11:18
Git aliases from ZSH (without zsh)
alias gco='git checkout'
alias gb='git branch'
alias gd='git diff'
alias glgg='git log --graph --max-count=10'
alias glgga='git log --graph --decorate --all'
alias gst='git status'
alias gss='git status --short'
alias ga='git add'
alias gc='git commit'
alias ggpull='git pull origin $(git rev-parse --abbrev-ref HEAD)'
@mdouchement
mdouchement / gzip_bug.go
Last active June 19, 2017 15:24
Golang gzip reader does not returns the right error.
package main
import (
"bytes"
"compress/gzip"
"errors"
"fmt"
"io"
)
@mdouchement
mdouchement / go.md
Last active January 25, 2017 10:45
Useful Golang packages

Static Build

CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' *.go

Objects

  • structs
    • Various utilities to work with Go (Golang) structs.
    • map[string]interface{} struct conversion.
  • github.com/fatih/structs
@mdouchement
mdouchement / rate_limiter.go
Created July 10, 2016 15:34
Goroutine rate limiter
package main
import (
"fmt"
"sync"
"time"
)
// limiter is a counting semaphore for limiting concurrency in action function.
var limiter = make(chan struct{}, 4)