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 / docker-cleanup.rst
Created June 25, 2020 12:03
Docker cleanup

DOCS: also refer to https://docs.docker.com/config/pruning/

HINT: add the --force option to the cmdlines to not prompt for confirmation (e.g. for usage inside scripts)

Get rid of all stopped containers (list via docker ps --filter status=exited):

% docker container prune

Get rid of all stopped container older than 12 hours:

@mika
mika / gist:e30b4e99c338f5d80d7681407708609b
Created May 25, 2018 11:14
zsh with extended vcs_info for git
## customize vcs_info
zstyle ':vcs_info:git*:*' check-for-changes true
zstyle ':vcs_info:git*:*' unstagedstr '|U'
zstyle ':vcs_info:git*:*' stagedstr '|≠'
# enable hooks, requires Zsh >=4.3.11
if [[ $ZSH_VERSION == 4.3.<11->* || $ZSH_VERSION == 4.<4->* || $ZSH_VERSION == <5->* ]] ; then
# hook for untracked files
+vi-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' ]] && \
@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 / 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 / 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 / kids_at_the_computer.md
Last active April 28, 2020 22:12
Bringing Kids to the Computer
@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",
dget http://deb.debian.org/debian/pool/main/b/bpftrace/bpftrace_0.9.2-2.dsc
cd bpftrace-0.9.2
dch -l ~bpo10+ -D buster-backports "Rebuild for buster-backports."
dpkg-buildpackage -uc -us -S -d
sudo cowbuilder --build --basepath /var/cache/pbuilder/base-buster-amd64.cow ./bpftrace_0.9.2-2\~bpo10+1.dsc
dget http://deb.debian.org/debian/pool/main/b/bpfcc/bpfcc_0.11.0-1.dsc
cd bpftrace-0.9.2
dch -l ~bpo10+ -D buster-backports "Rebuild for buster-backports."
dpkg-buildpackage -uc -us -S -d
@mika
mika / gist:c2a0df79f9fcf59c96f99adb9d3eac83
Created August 11, 2017 08:14 — forked from benwalton/gist:1777718
Clean up emails in the queue. usage ./postfix-delete.pl email@example.com
#!/usr/bin/perl
$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!";
@data = qx</usr/sbin/postqueue -p>;
for (@data) {
if (/^(\w+)(\*|\!)?\s/) {
$queue_id = $1;
}
if($queue_id) {