Skip to content

Instantly share code, notes, and snippets.

View jirutka's full-sized avatar
🇺🇦
Слава Україні!

Jakub Jirutka jirutka

🇺🇦
Слава Україні!
View GitHub Profile
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"realm": {
"type": "string"
},
@jirutka
jirutka / qm-replace-disk
Last active May 16, 2023 20:02
Replace disk in the specified VM template in Proxmox with the given image.
#!/bin/sh
# SPDX-FileCopyrightText: 2023 Jakub Jirutka <jakub@jirutka.cz>
# SPDX-License-Identifier: MIT
set -eu
PROGNAME='qm-replace-disk'
VERSION='0.1.0'
# Defaults
DISK='scsi0'
@jirutka
jirutka / iter_chunks_exact.rs
Last active January 5, 2023 16:38
Iterator::array_chunks for stable Rust 1.66
pub(crate) struct ChunksExact<const N: usize, I> {
iter: I,
}
impl<const N: usize, I: Iterator<Item = T>, T> Iterator for ChunksExact<N, I> {
type Item = [T; N];
fn next(&mut self) -> Option<Self::Item> {
assert_ne!(N, 0);
#include <stdbool.h>
typedef char* str;
#define GENERATE_OPTION_TYPES(Option) \
Option(int) \
Option(str)
#define GENERATE_RESULT_TYPES(Result) \
Result(str, int) \
@jirutka
jirutka / radacct-rotate
Created September 21, 2021 21:32
Script for compressing and later removing old FreeRADIUS' radacct log files with "-YYYYMMDD" suffix #freeradius #logrotate
#!/bin/sh
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021 Jakub Jirutka <jakub@jirutka.cz>
#---help---
# Usage: radacct-rotate [options]
#
# Compress and later remove old FreeRADIUS' radacct log files with "-YYYYMMDD"
# suffix.
#
# Options:
@jirutka
jirutka / arch-linux-installation.md
Last active December 13, 2023 01:09
My notes for installing Arch Linux on encrypted Btrfs with UEFI Secure Boot on ThinkPad T14s

Arch Linux Installation

1. Securely erase drive

cryptsetup open --type plain -d /dev/urandom /dev/nvme0n1 to-be-wiped
dd if=/dev/zero of=/dev/mapper/to-be-wiped bs=1M status=progress
cryptsetup close to-be-wiped
wipefs -a /dev/nvme0n1
@jirutka
jirutka / zeme.json
Created May 8, 2021 21:44
Číselník zemí z onlinescitani.cz
{
"poradiCse": [
"004",
"248",
"008",
"012",
"016",
"850",
"020",
"024",
@jirutka
jirutka / array_uniq.sql
Created April 2, 2021 21:14
Example of PostgreSQL trigger function to sort and deduplicate an array
create function array_uniq (a anyarray) returns anyarray
immutable
language sql
as $$
select array_agg(distinct x) from unnest(a) x;
$$;
comment on function array_uniq is
'Sorts and deduplicates elements of an array.';
create function trg_person_roles_normalize () returns trigger
@jirutka
jirutka / trg_check_array_elements_column_uniq.sql
Created April 2, 2021 21:11
PostgreSQL constraint trigger to check if each array element is unique within the table
-------------------------------------------------------------------------------
-- EXAMPLE USAGE
--
-- create table specialization (
-- id bigserial,
-- name text not null,
-- study_plan_codes text[] not null default '{}'
-- )
--
-- create constraint trigger study_plan_codes_unique_check
@jirutka
jirutka / koronavir-fatalni-stret-s-realitou.md
Created August 3, 2020 20:09
Článek „Koronavir – Fatální střet s realitou“ z webu mppraha.cz

Koronavir - Fatální střet s realitou

Problémy při prvním nástupu koronavirové krize by se ještě daly pochopit nedostatkem znalostí a zkušeností osob, které rozhodují o našich osudech. Následující příběh však popisuje reálnou situaci, kterou na vlastní kůži zažil v posledních čtrnácti dnech jeden z našich zaměstnanců bydlící ve Středočeském kraji. Informace jsou pravdivé a identita zaměstnance je nám samozřejmě známa.

11. 7. Můj dospělý syn navštívil s přáteli dnes již bohužel legendární pražský klub, přičemž neporušil žádné platné mimořádné opatření ve vztahu k šíření SARS-CoV-2.

11. 7. – 16. 7. V tomto období neměl žádné příznaky ani zdravotní komplikace, které by indikovaly, že byl nakažen.

16. 7. Objevila se mírná bolest hlavy, prostě nic co by nevyřešil, stejně jako dříve, obyčejný volně prodejný prášek proti bolesti.