Skip to content

Instantly share code, notes, and snippets.

View mika's full-sized avatar

Michael Prokop mika

View GitHub Profile
@mika
mika / backup_homeassistant.sh
Created April 5, 2024 07:28 — forked from btittelbach/backup_homeassistant.sh
homeassistant remote backup script
#!/bin/zsh
HOST=homeassistant.lan
snapname=$(date +%Y-%m-%d_%T_homeassistant_autosnap)
slugname=$(ssh $HOST "source /etc/profile; ha backups new --name \"${snapname}\" " | tail -n 1 ) || exit 1
[[ -z $slugname ]] && exit 2
echo $slugname | grep -q "slug: " || exit 3
slugname=$(echo $slugname | cut -c 7-)
snapfilename=backup/${slugname}.tar
@mika
mika / qnap_recovery.md
Created April 13, 2022 16:28 — forked from jkirk/qnap_recovery.md
Access QNAP encrypted HDD with GNU/Linux Debian

QNAP HDD Recovery Test (encrypted)

Removed HDD-2 from NAS (while running) and plugged into a Sharkoon USB-Bay and tried to recover data.

Tried to assemble all existing volumes:

  % sudo mdadm --assemble --scan
  mdadm: /dev/md/9 has been started with 1 drive (out of 24).
  mdadm: /dev/md/256 has been started with 1 drive (out of 2).
@mika
mika / PVE-HP-ssacli-smart-storage-admin.md
Created May 28, 2021 09:28 — forked from mrpeardotnet/PVE-HP-ssacli-smart-storage-admin.md
HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

Why use HP Smart Storage Admin CLI?

You can use ssacli (smart storage administrator command line interface) tool to manage any of supported HP Smart Array Controllers in your Proxmox host without need to reboot your server to access Smart Storage Administrator in BIOS. That means no host downtime when managing your storage.

CLI is not as convenient as GUI interface provided by BIOS or desktop utilities, but still allows you to fully manage your controller, physical disks and logical drives on the fly with no Proxmox host downtime.

ssacli replaces older hpssacli, but shares the same syntax and adds support for newer servers and controllers.

Installation

@mika
mika / falsehoods-programming-time-list.md
Created May 4, 2020 13:29 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@mika
mika / debian-10-packer.json
Created April 8, 2020 09:59 — forked from arnaudmorin/debian-10-packer.json
Install new cloud-init on Debian 10 using packer
{
"builders": [
{
"type": "openstack",
"username": "xxx",
"password": "yyy",
"identity_endpoint": "https://auth.cloud.ovh.net/v3/",
"region": "DE1",
"tenant_id": "zzz",
"image_name": "debian10-arnaud",
@mika
mika / psql_internals_cheatsheet.sql
Created June 15, 2019 10:19 — forked from azet/psql_internals_cheatsheet.sql
PostgreSQL internals SQL collection
# long running queries:
SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes';
## active queries and killing them:
@mika
mika / diskchecker.pl
Created May 14, 2019 08:00 — forked from bradfitz/diskchecker.pl
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]
@mika
mika / 99-disable-wireless-when-wired
Created April 12, 2019 15:02 — forked from cengiz-io/99-disable-wireless-when-wired
Script should be placed under `/etc/NetworkManager/dispatcher.d/` with a name like `99-disable-wireless-when-wired`. Make sure 1) root owns it 2) it's mod is 755
#!/bin/sh
IFACE=$1
ACTION=$2
ntfy () {
sudo -u cengiz \
DISPLAY=:0 \
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
notify-send "$1" "$2"
@mika
mika / upgrade.sh
Created October 19, 2018 15:56 — forked from zeha/upgrade.sh
#!/bin/bash
set -x
puppet agent --disable "update Debian"
service keepalived stop
apt-get install udev acl
sed -i'' -e 's/jessie/stretch/g' /etc/apt/sources.list.d/*
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
apt-get update
apt-get install apt dpkg deborphan # openjdk-8-jre-headless