Skip to content

Instantly share code, notes, and snippets.

@adrianbiro
adrianbiro / name_from_url.py
Created April 19, 2022 09:58
While splitting a string by slashes in order to extract the last part as a name, a problem occurs in the case that string eg. URL ends with a slash. Here is a solution.
#!/usr/bin/python3
*_, name = url.split('/')
if not name:
*_, name, _ = url.split('/')
@adrianbiro
adrianbiro / getconference_attendance.sh
Last active June 15, 2022 13:28
Generate attendance at the conference for the report as a CSV file.
#!/bin/bash
#for i in {1..100};
#do
# curl https://randomuser.me/api/ >> conference_attendance.json
#done
curl https://randomuser.me/api/?results=700 >> conference_attendance.json
echo '"Lastname","Forename","Age","City","Country"' > conference.csv
jq -rC '[.results[] | select(.dob.age > 21) | {person: [.name.last, .name.first, .dob.age, .location.city, .location.country]}] | sort_by(.name.last) | reverse | .[] | add | @csv' conference_attendance.json >> conference.csv
@adrianbiro
adrianbiro / csv_to_tsv.sh
Last active May 28, 2022 07:55
This removes lines marked with the hash from the CSV file, cleane-up quotes and generates the TSV file. Then You can easily read this, in plain text editor.
awk -F"," '{gsub("\"", "", $0); gsub(",", "\t", $0); if ($1 !~ /#\s.*/) print }' report.csv > clean_report.tsv
@adrianbiro
adrianbiro / sum_clenske.sh
Last active June 1, 2022 09:05
Spocita ti to clenske a ignoruje prazdne riadky.
awk -F',' 'NF>1{printf("%s\t%d\n", $1, ($2 + $3))}' clenske_prispevky.csv \
| pr --columns=3 --double-space --number-lines --first-line-number=1 \
--date-format=%Y-%m-%d --header='Zostatok clenske prispevky' > Zostatok_clenske.txt
@adrianbiro
adrianbiro / Place this to the .bashrc
Created June 16, 2022 10:57
Bash competition for go
#!/bin/bash
function completego()
# Bash completion for go
{
local wordlist; wordlist=$(go help | awk 'NR==9, NR==26{ printf "%s%s", $1, sp = NR==26? "\n": " "}')
complete -W "${wordlist}" go
}
completego
@adrianbiro
adrianbiro / setupclamavdb.sh
Last active August 27, 2022 14:38
setup clamav db
#!/bin/bash
trap "sudo systemctl enable --now clamav-freshclam.service" EXIT
sudo systemctl stop clamav-freshclam.service
sudo freshclam
@adrianbiro
adrianbiro / extendLVM_LUSK.md
Last active September 16, 2022 07:31
Extend LVM LUKS

Extend LVM LUKS

link

LVM

$ lsblk
$ wipefs -a /dev/sdb
  # quick wipe target device
$ pvcreate /dev/sdb
$ pvs
$ vgs

find /usr -name sysexits.h

/*
 *  SYSEXITS.H -- Exit status codes for system programs.
 *
 *	This include file attempts to categorize possible error
 *	exit statuses for system programs, notably delivermail

Decimal

$1000$ kB kilobyte

$1000^2$ MB megabyte

$1000^3$ GB gigabyte

$1000^4$ TB terabyte

  • 1xx (Informational): The request was received, continuing process
  • 2xx (Successful): The request was successfully received, understood, and accepted
  • 3xx (Redirection): Further action needs to be taken in order to complete the request
  • 4xx (Client Error): The request contains bad syntax or cannot be fulfilled
  • 5xx (Server Error): The server failed to fulfill an apparently valid request

RFC 9110 HTTP Semantics