Skip to content

Instantly share code, notes, and snippets.

@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`)

Capture a movie on your phone of the object by walking around it. If possible shoot it from different angles e.g. from above looking down, below looking up, side on etc. When you film it, walk around it or move the camera around it in a full 360 revolution (or even a couple of revolutions). You should get something like this (note that the image below is a resized copy of the orignal downrated to 1 fps):

DrinkingFountainSmall

Put the video into an empty folder and then use ffmpeg to extract the frames. You can experiment with different frame rates but generally there will be little value in extracting at 60fps or whatever your phone natively shoots at.

If you are on an iPhone you may need to convert your movie from .HEIC format first:

@veggiemonk
veggiemonk / hash_sha256.go
Created July 3, 2022 12:50
Go Snippets: hashing strings with SHA256 algorithm
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"fmt"
)
// Go Playground https://go.dev/play/p/1EaM_5NQmc5
@veggiemonk
veggiemonk / uuid_numbers.go
Created July 3, 2022 12:23
[experimental] Encode UUID as string of numbers
package main
import (
"fmt"
"math/big"
"strings"
"github.com/google/uuid"
)
@veggiemonk
veggiemonk / install_wireguard.sh
Created September 17, 2020 21:48
automated Install wireguard script for Ubuntu 20.04
@!/usr/bin/env bash
set -xe
sudo apt update && sudo apt install -y wireguard
export CLIENT_PUBLIC_KEY="[INSERT CLIENT PUB KEY HERE]"
export CLIENT_VPN_IP="10.0.0.2" # change this if necessary, the server vpn ip is 10.0.0.1 as defined in the config
export SERVER_NAME="serverwg"
@veggiemonk
veggiemonk / .zshrc
Last active December 5, 2021 20:27
zshrc linux
export PATH=$HOME/bin:/usr/local/bin:$PATH
export ZSH="~/.oh-my-zsh"
ZSH_THEME="robbyrussell"
DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line if pasting URLs and other text is messed up.
DISABLE_MAGIC_FUNCTIONS="true"
@veggiemonk
veggiemonk / download-org-repos.sh
Last active November 16, 2021 13:23
download all repos from github org
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/flyteorg/repos > repos.json
cat repos.json | jq '.[].git_url' | xargs -I REPO git clone REPO
@veggiemonk
veggiemonk / demo.sh
Last active August 31, 2021 14:43
Script for demo of Chaos Engineering with a service mesh
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole=cluster-admin \
--user=$(gcloud config get-value core/account)
# export PATH=$PWD/bin:$PATH
kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml
helm template install/kubernetes/helm/istio --name istio --namespace istio-system \
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_commit\
$git_state\
$git_status\
$docker_context\
$package\