Skip to content

Instantly share code, notes, and snippets.

View rvflash's full-sized avatar

Hervé Gouchet rvflash

View GitHub Profile
@rvflash
rvflash / slices_chunk.go
Created November 20, 2023 17:03
Generic slices chunk in Go
// Package slices defines various functions useful with slices of any type.
package slices
import "math"
// Chunk splits a slice into uniform chunks of the requested size.
func Chunk[V any](x []V, size int) [][]V {
n := len(x)
if n == 0 || size <= 0 {
return nil
@rvflash
rvflash / k8s.md
Last active July 20, 2023 15:44
Kubernetes
@rvflash
rvflash / openpgp_armored.go
Created May 24, 2021 13:40
Command line to convert a private OpenPGP key in its representation in armor.
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
"golang.org/x/crypto/openpgp"
@rvflash
rvflash / curl-override-hostname.sh
Created December 12, 2018 11:04
Override the hostname (ip force)
#!/usr/bin/env bash
curl -sL -w "%{http_code} %{url_effective} (%{time_total})\\n" -H 'Host: example.com' "http://localhost:8080/" -o /dev/null
@rvflash
rvflash / top20-linux-resources-by-process.sh
Last active November 7, 2018 09:39
Returns a top 20 sortered list of used ressources by process
#!/usr/bin/env bash
# Returns a top 20 sortered list of used ressources by process.
for x in `ps -eF| awk '{ print $2 }'`
do echo `ls /proc/$x/fd 2> /dev/null | wc -l` $x `cat /proc/$x/cmdline 2> /dev/null`
done | sort -n -r | head -n 20
@rvflash
rvflash / curl-header-with-follow-redirect.sh
Created July 9, 2016 20:54
Display request headers with command line curl and follow redirects
#!/usr/bin/env bash
declare -- url="$1"
if [[ -z "$url" ]]; then
echo "Missing url"
exit 1
fi
# @example https://goo.gl/
curl -sLD - "$url" -o /dev/null