Skip to content

Instantly share code, notes, and snippets.

View utf18's full-sized avatar
🚚

Benjamin utf18

🚚
  • Freelancer
  • Germany
View GitHub Profile
@utf18
utf18 / gist:baa6a636d5b20f46c21735315943d32f
Created August 11, 2023 07:12
keycloak_access_token_script
#!/bin/bash
# Keycloak configuration
KEYCLOAK_URL="https://keycloak.example.com/auth"
REALM="your_realm_name"
CLIENT_ID="your_client_id"
CLIENT_SECRET="your_client_secret"
REDIRECT_URI="http://your_app_redirect_uri"
# Step 1: Construct authorization URL
@utf18
utf18 / script-template.sh
Created December 16, 2020 14:34 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
ssh user@server "df -h" | grep -i /dev/sdaX
ssh root@remoteserver 'tcpdump -c 1000 -nn -w - not port 22' | wireshark -k -i -
vim scp://user@remoteserver//etc/hosts
@utf18
utf18 / wc-go-files
Created November 20, 2018 09:50
count lines for go files in osx
wc -l $(find . -name '*.go')
docker images |grep -v REPOSITORY|awk '!/<none>/{print $1,$2}' | uniq
whoseport () {
lsof -i ":$1" | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} LISTEN
}
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
package main
import (
"fmt"
"os"
"path/filepath"
"regexp"
)
out, err := exec.Command("ls", "-la").Output()
if err != nil {
log.Infof("error is %v", err)
}
fmt.Printf("output of ls is %s\n", out)
jq '.terms.OnDemand | .. | .priceDimensions? | select (. != null) |map_values (.)| map (. + {sku: .rateCode|split(".")[0]}) | .[] '
jq '[.products| to_entries | .[].value | select (.attributes.operatingSystem == "Linux" and .attributes.location=="EU (Frankfurt)"
and .attributes.instanceType == "m4.2xlarge" and .attributes.preInstalledSw == "NA") | {key: .sku, value: .}]|from_entries' current.json > gen.json