Skip to content

Instantly share code, notes, and snippets.

View toke's full-sized avatar

Thomas Kerpe toke

View GitHub Profile
@toke
toke / Vagrantfile
Last active October 27, 2017 13:15
Ansible Issue 30753 (https://github.com/ansible/ansible/issues/30753) Testcase using Vagrant against Debian Wheezy
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "debian/wheezy64"
config.vm.provision :ansible do |ansible|
ansible.playbook = "playbook.yml"
end
end
@toke
toke / fw_block.sh
Last active April 24, 2023 09:36
Simple spamhaus ipset firewall block
#!/usr/bin/bash
## Run every 24h via cron
## Old entries will time out later automatically
(
cd /var/lib/firewall
wget -qN 'http://www.spamhaus.org/drop/drop.txt'
ipset create -exist spamhaus_drop hash:net counters timeout 90000 comment
@toke
toke / hostname.socket
Last active June 2, 2017 07:57
Basic hostname systemd "service"
[Unit]
Description=Hostname Socket
[Socket]
ListenStream=101
Accept=true
[Install]
WantedBy=sockets.target
[
{
"id": "github",
"execute-command": "/home/toke/webhooks/hooks/github.sh",
"command-working-directory": "/home/toke/go",
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "head_commit.id"
@toke
toke / 85-dock.rules
Last active March 22, 2017 19:32
Target variant of systemd udev dock hook for dell laptop
SUBSYSTEMS=="usb", SYMLINK="delldock", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="2513", ENV{DEVTYPE}=="usb_device", TAG+="systemd", ENV{SYSTEMD_WANTS}="dock.target"
@toke
toke / 85-dock.rules
Created March 22, 2017 19:26
Dell dock udev, systemd hook stuff for linux
SUBSYSTEMS=="usb", SYMLINK="delldock", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="2513", ENV{DEVTYPE}=="usb_device", TAG+="systemd", ENV{SYSTEMD_WANTS}="dock.service"
@toke
toke / at-work.target
Last active March 22, 2017 14:57
Example on how to context switch with systemd - assuming toggling of a target unit.
[Unit]
Description=Laptop at work or in work context
Conflicts=at-home.target
After=graphical.target
@toke
toke / lock.bash
Last active March 13, 2017 20:59
Simple i3 lock screen
#!/usr/bin/env bash
icon="$HOME/Pictures/lock.png"
tmpbg='/tmp/screen.png'
(( $# )) && { icon=$1; }
scrot "$tmpbg"
convert "$tmpbg" -scale 10% -scale 1000% "$tmpbg"
convert "$tmpbg" "$icon" -gravity center -composite -matte "$tmpbg"
@toke
toke / ac-check.bash
Created March 13, 2017 09:26
AC Power script for shell scripting
#!/usr/bin/env bash
set -e
function usage() {
cat << EOF
$0 - Returns exit code 1 when on battery power
Backup is only run when on AC power (see --no-ac-check option).
Example usage: "$0 && backup.sh" in cron job
@toke
toke / pacman-backup.bash
Last active March 13, 2017 09:29
Pacman package database backup script. I use this on my laptop. Combined with ac-check.bash
#!/usr/bin/env bash
set -e
OUTDIR="${HOME}/backup/pacman/$(hostname --short)"
function usage() {
cat << EOF
$0 - backup pacman package database