Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env sh
# This script extends the functionality of dmenu_run by allowing the user to
# include custom commands and executables. The custom commands are read from a
# file specified by the environment variable DMENU_RUN_COMMANDS, and the
# executables are read from a directory specified by the environment variable
# DMENU_RUN_BIN.
#
# Environment Variables:
# DMENU_RUN_COMMANDS: Path to a file containing custom commands to be included
@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
@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'
@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'
package main
import (
"fmt"
"math/rand"
"os"
"os/signal"
"syscall"
"time"
)
# Convert mysql database scheme to typeorm entity for nestjs
# echo DESCRIBE some_db.some_table | mysql -some-login-credentials | gawk -f entity-generator.awk
function get_type_name(s) {
if (s ~ /\)$/) {
sub(/\(.+\)$/, "", s)
return s
}
return s
}