Skip to content

Instantly share code, notes, and snippets.

@thomasfaingnaert
thomasfaingnaert / Dell XPS 13 9350 - Fedora Firewalld Fix.md
Created February 2, 2018 20:38
Dell XPS 13 9350 - Fedora Firewalld Fix
@thomasfaingnaert
thomasfaingnaert / Install Communitheme.md
Last active April 6, 2019 13:08
Installing Communitheme/Yaru on Ubuntu 18.04 LTS
sudo snap install communitheme
sudo update-alternatives --install /usr/share/gnome-shell/theme/gdm3.css gdm3.css /snap/communitheme/current/share/gnome-shell/theme/Communitheme/gnome-shell.css 15
sudo sed -ie '/^\[User\]$/,/^\[/ s/^\(XSession=\).*$/\1ubuntu-communitheme-snap/' /var/lib/AccountsService/users/${USER}

Installation

sudo apt install linux-headers-$(uname -r)
sudo apt install v4l2loopback-dkms
sudo modprobe v4l2loopback exclusive_caps=1

Video file

VIDEO=
@thomasfaingnaert
thomasfaingnaert / wrap-executable-wrap.md
Created July 5, 2019 09:19
Wrap executable and write stdout and stderr to file

Without timestamps:

#!/usr/bin/env bash

exec > >(tee -ai ~/app-stdout.log) 2> >(tee -ai ~/app-stderr.log >&2)
app $*

With timestamps (requires ts from moreutils):

@thomasfaingnaert
thomasfaingnaert / keep-named-pipe-open.sh
Last active July 5, 2019 09:54
Keep named pipe open
#!/usr/bin/env bash
mkfifo pipe # Created named pipe
program <pipe & # Start program
exec 3>pipe # Open file descriptor 3, writing to the named pipe
# Write to pipe using printf, echo, cat, ...
exec 3>&- # Close the named pipe (file descriptor 3)
@thomasfaingnaert
thomasfaingnaert / bash-control-lsp.sh
Last active July 5, 2019 10:30
Control LSP server from Bash
#!/usr/bin/env bash
send()
{
local length=${#1}
printf "Content-Length: $length\r\n" >pipe
printf '\r\n' >pipe
printf ${1//\\/\\\\} >pipe
}
@thomasfaingnaert
thomasfaingnaert / extract.md
Created February 23, 2020 16:53
Extract image from PDF for use in PowerPoint
  1. Open PDF in InkScape. Use Poppler/Cairo import.
  2. Ungroup all using CTRL + A and CTRL + SHIFT + G.
  3. Select what you want to keep and delete the rest using ! and DELETE.
  4. Autoresize the canvas using CTRL + SHIFT + R.
  5. Save as .EMF file.
@thomasfaingnaert
thomasfaingnaert / vim-pairwise-diff.md
Last active February 2, 2021 13:11
Vim pairwise diff

Oneliner to diff a set of files pairwise in different tabs with Vim:

gvim -R -c 'for i in range(1, argc() - 1) | if i % 2 == 1 | rightbelow vertical diffsplit | next | diffthis | else | tabedit | next | endif | endfor' a b c d
@thomasfaingnaert
thomasfaingnaert / visitor-tree-pretty-print.cpp
Last active February 10, 2021 15:08
Pretty print tree using Visitors
#include <cassert>
#include <cstdint>
#include <iostream>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
// Visited hierarchy
struct AstBase {
@thomasfaingnaert
thomasfaingnaert / run-in-docker.sh
Created February 7, 2021 14:40
Run command in Docker
function run_in_docker()
{
docker run --rm -i -u "$(id -u):$(id -g)" $DOCKER_IMAGE bash -s
}
# Usage:
run_in_docker <<EOF || echo "Failed!"
set -e
echo "Do something in container..."
EOF