Skip to content

Instantly share code, notes, and snippets.

View varqox's full-sized avatar

Krzysztof Małysa varqox

View GitHub Profile
1026
2.862 4.864
4.979 7.849
7.873 10.831
10.855 12.857
14.772 16.774
18.986 23.633
23.718 26.111
32.790 36.685
36.942 38.944
@varqox
varqox / source.cc
Created October 30, 2025 09:12
C++: type to ptr and name mapping that is unambiguous
#include <iostream>
#include <type_traits>
#include <vector>
#include <utility>
#include <array>
#include <string_view>
#include <cstddef>
#include <unistd.h>
#include <cstdio>
using namespace std;
#!/bin/bash
#set -exuo pipefail
shopt -s expand_aliases
function safe_function {
echo "$@"
echo "sf: ${BASH_LINENO[0]}"
sed -n "${BASH_LINENO[0]},/^}/p" "${BASH_SOURCE[1]}"
}
@varqox
varqox / rust_async_callbacks_common_errors_pitfalls_solution.md
Last active October 1, 2024 11:56
Solution to Rust errors of kinds: "implementation of `Fn` is not general enough" (works with FnMut and FnOnce as well) or "lifetime may not live long enough"

Solution to Rust errors of kinds:

  • implementation of Fn is not general enough (works with FnMut and FnOnce as well)
  • lifetime may not live long enough
use std::future::Future;

trait Callback<Arg, Res> {
    type Output: Future<Output = Res>;
@varqox
varqox / sql.hh
Last active April 8, 2024 21:46
Constructing SQL queries in compile time
#pragma once
// #include <simlib/meta/concated_to_cstr.hh>
#include <array>
#include <cstddef>
#include <utility>
namespace meta {
template <char... chars>
@varqox
varqox / create-combined-sink.sh
Created March 1, 2024 17:29
Select and create combined sink node with Pipewire and set it as default Pulseaudio sink (output)
#!/bin/bash
set -euo pipefail
list_sinks() {
pw-cli list-objects Node | grep -P '^\s+id |^\s+node\.name|^\s+media\.class = "Audio/Sink"' | grep 'media\.class' -B 2 --no-group-separator | paste -sd' \n' | sed 's/^\s*id [0-9]*, type .*node\.name = "\([^"]*\)".*/\1/' | (grep -vP "^($1)$" || true)
}
pactl unload-module module-combine-sink 2> /dev/null
selected_names_regex=''
@varqox
varqox / merge-sim-project.sh
Created February 25, 2024 16:04
Merge 3 git repositories into one having the same (empty) initial commit
#!/bin/bash
set -exuo pipefail
rm -rf sim-project
git init sim-project
cd sim-project
git commit -m 'Initial commit' --allow-empty
INITIAL_COMMIT=$(git rev-parse @)
@varqox
varqox / secure_eduroam.md
Last active October 15, 2025 23:36
How to setup a *secure* eduroam connection for University of Warsaw students on Linux

Introduction

This tutorial covers using NetworkManager with either wpa_supplicant or IWD backend. If you did not heard of IWD, it is propbable your NetworkManager uses wpa_supplicant.

UW authorization server uses DSK-NET CA certificate that is self-signed, so we need to specify it manually.

wpa_supplicant

  1. Download the DSK-NET CA certificate:
curl https://it.uw.edu.pl/pl/uslugi/UslugiInternetWiFiEduroam/dsk_net_ca.crt | sudo tee /etc/dsk_net_ca.crt
@varqox
varqox / backup
Last active October 12, 2021 15:26
Backup script (copy it to root directory of your project and run it every time you want to make a backup)
#!/bin/sh
set -e
cd -P -- "$(dirname -- "$0")" # chdir to script directory
out_file="$HOME/backup/$(echo ${PWD#$HOME/} | sed 's@/@,@g').tar.zst"
((git ls-files -z --cached --recurse-submodules 2> /dev/null &&
git ls-files -z --others --exclude-standard &&
PROJECT_DIR=$PWD git submodule foreach --quiet 'git ls-files -z -o --exclude-standard | while read -d "" x; do echo -n "${PWD#$PROJECT_DIR/}/$x"; echo -ne "\0"; done' &&
@varqox
varqox / system-installation-guide.md
Last active August 30, 2023 11:42
Guide for what to do just after installing a bare Arch Linux to get *my* full-fledged XFCE desktop Arch Linux and some other random Linux stuff

Before rebooting after making fresh Arch installation

  • make sure to install grub using grub-install and configure it properly using grub-mkconfig -o /boot/grub/grub.cfg (for uefi it is not so easy), but before running grub-mkconfig install intel-ucode or amd-ucode
  • install networkmanager vim htop net-tools wireless_tools # net-tools for ifconfig, wireless_tools for iwconfig
  • remember to configure pacman mirrors properly see /etc/pacman.d/mirrorlist
  • reboot

On a fresh Arch installation

  • systemctl enable --now NetworkManager
  • use nmtui to connect to internet
  • install git man-pages procps-ng # procps-ng for pkill