Skip to content

Instantly share code, notes, and snippets.

View adrianbiro's full-sized avatar

Adrián Bíro adrianbiro

View GitHub Profile
@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 / 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 / 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 / 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('/')