Skip to content

Instantly share code, notes, and snippets.

@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
}
# 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 / znvm.zsh
Last active February 16, 2020 14:00
https://github.com/Ajnasz/znvm