Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Ajnasz / jwtdecode.sh
Created April 12, 2024 06:15
jwt decode shell script
#!/bin/sh
# Decode JWT token
# Usage: echo <jwt_token> | jwtdecode
# requires jq and base64
while read input; do
echo $input | cut -d . -f 1,2 | tr '.' '\n' | \
while read str;do
echo "$str"==== | fold -w 4 | sed '$ d' | tr -d '\n' | base64 --decode | jq
# SED Commands to replace HTML entities to characters
# Usage:
# sed -f htmlentities.sed file.html > newfile.html
# Replace entities in all html files
# sed -i -f htmlentities.sed file.html **/*.html
# ASCII printable characters
s/&#32;/ /g
s/&#33;/!/g
@Ajnasz
Ajnasz / packagepinpoint.sh
Last active June 2, 2023 09:39
pinpoint package versions in package.json, getting versions from package-lock.json
jq < package.json '.dependencies | to_entries[]|select(.value|startswith("^"))|.key' | \
xargs -I {} jq --arg v {} '.dependencies[$v]|{($v): .version}' package-lock.json | \
jq 'to_entries[]|.key+" "+.value' | \
xargs -P 1 -I {} sh -c 'key=$(echo {} | cut -f 1 -d " ");value=$(echo {} | cut -f 2 -d " ");jq --arg k $key --arg v $value ".dependencies[\$k]=\$v" package.json> package.tmp.json && mv package.tmp.json package.json'
[skin]
description=Ajnasz Blue Theme. Midnight Commander skin from Ajnasz.
[Lines]
horiz=─
vert=│
lefttop=┌
righttop=┐
leftbottom=└
rightbottom=┘
@Ajnasz
Ajnasz / rand.sh
Created October 7, 2022 07:32
shell function to generate random number from shell using /dev/urandom
#!/bin/sh
# function to generate random number from shell using /dev/urandom
# https://unix.stackexchange.com/questions/268952/using-dev-random-dev-urandom-to-generate-random-data
rand() {
bytes=${1:-1}
od -vAn -N$bytes -tu2 < /dev/urandom | sed 's/\s\+//g'
}
function getDateFields(plainDateTime, locale='en-US') {
const formatter = new Intl.DateTimeFormat(locale, {
year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
weekday: 'long',
timeZoneName: 'short',
dayPeriod: 'short',
hour12: false,
});
.\" Automatically generated by Pandoc 2.9.1.1
.\"
.TH "http" "7" "June 2022" "" ""
.hy
.SH NAME
.PP
http - descripe HTTP status codes
.SH DESCRIPTION
.SS 100 Continue
.PP
#compdef meta
#autoload
local -a _meta_commands
_meta_commands=(
'info:General Information'
'onboard:Onboard a user device locally or using a Single Sign-on (SSO) method.'
'ssp:Perform actions available from the Proofpoint self-service portal (SSP).'
'profile:Manage Proofpoint Agent user profiles'
'connect:Connect to the Proofpoint NaaS with the selected device profile'
#!/bin/sh
IN=LVDS-0;
setoff() {
for display in `xrandr | awk '/ disconnected/ {print $1}'`; do
echo "maybe disabling $display";
xrandr --output $display --off;
done;
}