Skip to content

Instantly share code, notes, and snippets.

@schuerg
schuerg / i3-cheat-sheet.md
Last active August 18, 2021 15:03 — forked from JeffPaine/i3-cheat-sheet.md
[i3/sway cheatsheet] List of key bindings for i3wm/swaywm #linux #tiling-wm #desktop #cheat-sheet
@schuerg
schuerg / socopy-daemon.service
Created January 27, 2019 23:33
[Use local clipboard over SSH] Forward local clipboard over SSH using socat #linux #clipboard #ssh #socat #networking
[Unit]
Description=Daemon for copying to (a remote) clipboard over a TCP socket
After=graphical-session.target
StartLimitBurst=5
[Service]
; %h gets expanded to the current user's home dir
; See https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers
ExecStart=%h/.local/bin/socopy-daemon
Type=simple
@schuerg
schuerg / github-latest-release.sh
Created January 27, 2019 23:07
[Get latest GitHub release] Echo the release assets of a given GitHub repo to stdout #github #bash #linux
#!/usr/bin/env bash
#
# Echo the release assets of a given GitHub repo to stdout.
# First parameter is the repo in the form neovim/neovim
# It uses the latest release by default.
# An other release can be selected by the release id as second parameter.
#
# Example usage:
# github-latest-release neovim/neovim | grep "linux"
#
@schuerg
schuerg / reboot-to.sh
Created January 27, 2019 22:36
[Reboot to specific OS] Reboot the machine to a specific boot target (Grub entry) #linux #bash #grub #interactive
#!/usr/bin/env bash
# Reboot the machine to a specific boot target (Grub entry).
# The boot target is interactivly selected with fzf.
#
# Simon Schürg
# Search for grub.cfg
GRUB_CFG=$(find /boot -name grub.cfg 2> /dev/null)
if [[ -z ${GRUB_CFG} ]]; then
@schuerg
schuerg / sources.list
Created January 25, 2019 13:27
[Debian apt sources] sources.list with main contrib and non-free enabled #debian #linux
# Official Debian repositories
# https://wiki.debian.org/SourcesList
deb http://deb.debian.org/debian stretch main contrib non-free
deb-src http://deb.debian.org/debian stretch main contrib non-free
deb http://deb.debian.org/debian-security/ stretch/updates main contrib non-free
deb-src http://deb.debian.org/debian-security/ stretch/updates main contrib non-free
deb http://deb.debian.org/debian stretch-updates main contrib non-free
@schuerg
schuerg / default_http.conf
Last active January 27, 2019 23:21
Nginx config for Let's Encrypt renewal challenges
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com *.example.com blub.example.com;
# No redirect to HTTPS for Let's Encrypt renewal challenges
location ~ /.well-known {
root /var/www/html;
allow all;
@schuerg
schuerg / crontab
Last active January 27, 2019 23:21
[Crontab template header] Crontab header for remembering crontab syntax. #linux #cron
# Do every X intervals: */X
# For multiple values use commas: 3,12,47
# Dump output: >/dev/null 2>&1
# Aliases: @reboot, @yearly, @monthly, @weekly, @daily, @hourly
# Crontab generator: https://crontab-generator.org/
SHELL=/bin/sh
# If empty "", then no mail is sent
MAILTO=""
CRON_TZ=Europe/Berlin
@schuerg
schuerg / set_ini.py
Last active January 27, 2019 23:17
[Set INI-file value] Sets a value in an INI-file from command line. #python #ini #config
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This script sets a value in an INI-file.
# It uses Python 3 configparser
# https://docs.python.org/3/library/configparser.html
# Simon Schürg
import argparse
import configparser
@schuerg
schuerg / render_jinja2.py
Last active January 27, 2019 23:16
[Render Jinja2 template from terminal] Renders a given Jinja2 template and saves it as a new file. #python #jinja2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This script renders a given Jinja2 template and saves it as a new file.
#
# Simon Schürg
import argparse
import os
from pathlib import Path
@schuerg
schuerg / dhcp-discover.py
Last active January 27, 2019 23:19
[DHCP server discovery] Scan the local network for rogue DHCP servers. #dhcp #networking #python #scapy #rogue-dhcp
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Rogue DHCP server discovery
# Simon Schürg
import scapy.all as scapy
import re
import requests