Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Faingnaert thomasfaingnaert

View GitHub Profile
@thomasfaingnaert
thomasfaingnaert / onedrive-linux.md
Created Mar 24, 2021
Configure OneDrive in Linux
View onedrive-linux.md
# Change this to the name of your account
ACCOUNT_NAME=Personal

###

CONTAINER_NAME="$(echo "onedrive-${ACCOUNT_NAME}" | tr '[:upper:]' '[:lower:]')"
VOLUME_NAME="${CONTAINER_NAME}-conf"
ONEDRIVE_DATA_DIR="${HOME}/OneDrive${ACCOUNT_NAME}"
View run-in-docker.sh
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
@thomasfaingnaert
thomasfaingnaert / visitor-tree-pretty-print.cpp
Last active Feb 10, 2021
Pretty print tree using Visitors
View visitor-tree-pretty-print.cpp
#include <cassert>
#include <cstdint>
#include <iostream>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
// Visited hierarchy
struct AstBase {
View vim-pairwise-diff.md

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 / extract.md
Created Feb 23, 2020
Extract image from PDF for use in PowerPoint
View extract.md
  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 / bash-control-lsp.sh
Last active Jul 5, 2019
Control LSP server from Bash
View bash-control-lsp.sh
#!/usr/bin/env bash
send()
{
local length=${#1}
printf "Content-Length: $length\r\n" >pipe
printf '\r\n' >pipe
printf ${1//\\/\\\\} >pipe
}
View keep-named-pipe-open.sh
#!/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 / wrap-executable-wrap.md
Created Jul 5, 2019
Wrap executable and write stdout and stderr to file
View wrap-executable-wrap.md

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):

View Virtual webcam.md

Installation

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

Video file

VIDEO=<video-file>
@thomasfaingnaert
thomasfaingnaert / Install Communitheme.md
Last active Apr 6, 2019
Installing Communitheme/Yaru on Ubuntu 18.04 LTS
View Install Communitheme.md
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}