Skip to content

Instantly share code, notes, and snippets.

@szz
szz / upsmon_slack_alerter
Created April 6, 2023 15:19
Send an alert via Slack if a UPS event happens. It is usable with nut/upsmon.
#!/bin/bash
# Send an alert via Slack if a UPS event happens. It is usable with nut/upsmon.
# licence: CC0
# Slack notifier sctipz to use with nut
# configure upsmon.conf like this:
# NOTIFYMSG ONLINE "1 UPS %s on line power :electric_plug:"
# NOTIFYMSG ONBATT "0 UPS %s on battery :battery:"
@szz
szz / koronavirus.gov.hu site data extractor
Last active March 26, 2021 08:19
fixing gender parsing
class koronaVirusGovHuParser
{
constructor() {
this.cellSeparator = "\t";
this.newLine = "\n";
this.deathCasePageSelector = '.view-elhunytak .views-table > tbody:nth-child(2)';
this.knownCases = new Map();
this.__initTextOutput();
}
@szz
szz / doci
Created May 28, 2020 23:20
get the prefered interactive shell in a given docker conatiner
#!/bin/bash
SHELL_PREFERENCE=("bash zsh sh")
if [ -z "$1" ]; then
echo "No conatiner name supplied"
exit 255
fi
FOUND_CONTAINERS=$(docker container ls --format 'table {{.Names}}\t{{.ID}}' | grep -v "CONTAINER ID" | grep -w ${1})
EXIT_CODE=$?
// put it into a bookmark and use it whenever it needs
// currently: totalcar
javascript:(function(){
$("img[src*='/assets/images/common/adblock/']")[0].parentElement.parentElement.parentElement.remove();
document.querySelector("body").style.overflow = "visible";
})();
function ppmt_sum(rate, number_of_periods, present_value, number_of_sum_period)
{
var sum = 0;
var remain_rounds = number_of_sum_period;
while (remain_rounds > 0)
{
sum += this._my_ppmt(rate, remain_rounds, number_of_periods, present_value) ;
remain_rounds--;
}
@szz
szz / temperature_of_disks
Last active March 9, 2017 10:13
temperature of physical disks #ubuntu
lshw -short -c disk | awk '/disk/ {print $2}' | xargs hddtemp | awk -F\: '/°C/ {print $1 ":"$3}'
@szz
szz / gist:6218264
Created August 13, 2013 06:03
list top 50 404's in descending order.
awk '$9 == "404" {print $7}' access.log |sort|uniq -c|sort -rn| head -n 50