Skip to content

Instantly share code, notes, and snippets.

View killerbees19's full-sized avatar
🐢
I may be slow to respond.

Christian killerbees19

🐢
I may be slow to respond.
View GitHub Profile

Slimming Down Raspbian Stretch Lite

Notes for slimming down a fresh installation of Raspbian Stretch Lite. This guide does not strip Raspbian of basic functionality such as Bluetooth and mDNS.

Instructions

Install a fresh Raspbian Stretch Lite image into the SD card ([source][1]).

$ unzip -p 2018-04-18-raspbian-stretch-lite.zip | dd bs=4M of=/dev/sdX conv=fsync

@killerbees19
killerbees19 / 90-libvirt-usb.rules
Created April 9, 2020 14:28
Execute libvirt commands via udev after plugging-in USB devices
# Start VM...
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_VENDOR_ID}=="abcd", ENV{ID_MODEL_ID}=="1234", RUN+="/etc/libvirt/custom/usb-udev-helper.sh start example-vm"
# Attach USB device to VM...
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_VENDOR_ID}=="dcba", ENV{ID_MODEL_ID}=="4321", RUN+="/etc/libvirt/custom/usb-udev-helper.sh attach-device other-vm /etc/libvirt/custom/usb-device.xml"
ACTION=="remove", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_VENDOR_ID}=="dcba", ENV{ID_MODEL_ID}=="4321", RUN+="/etc/libvirt/custom/usb-udev-helper.sh detach-device other-vm /etc/libvirt/custom/usb-device.xml"
@killerbees19
killerbees19 / README.md
Last active October 7, 2023 18:57
SIMPLE BIDIRECTIONAL SYNC WITH HARDLINKS
mkdir ~/.sync
chmod -c 0700 ~/.sync

editor ~/sync.php
chmod +x ~/sync.php

~/sync.php
@killerbees19
killerbees19 / logrotate.conf
Last active November 8, 2020 06:17
Munin plugin to monitor Nginx TLS versions
/var/log/nginx/misc/ssl.log {
daily
missingok
rotate 0
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
@killerbees19
killerbees19 / covid19_at
Created July 12, 2020 12:29
Munin plugins for COVID-19
#!/bin/bash
set -euf -o pipefail
if [[ "${1:-}" == "autoconf" ]]
then
echo "no"
exit
fi
basename=$(basename "$0")
@killerbees19
killerbees19 / gist:5ba80bc0f043f2e7bdbc075f284eaf5f
Created July 23, 2020 14:27 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
<?php
// Hint: Use negative $base to round everything up!
function formatByteNumber(float $number, int $base = 1024, int $decimals = 0, string $dec_point = '.' , string $thousands_sep = ','): string
{
if(!in_array(($a = abs($base)), [1000, 1024], true))
{
throw new InvalidArgumentException('Invalid base: ' . $base);
}
@killerbees19
killerbees19 / pre-commit
Created September 20, 2020 05:24
Git pre-commit hook: PHP Lint Check
#!/bin/bash
git diff --cached --name-status --diff-filter=d \
| awk '{print $(NF)}' | grep -Ei '\.(php)$' \
| while IFS= read -r file
do
msg=$(git show ":$file" | php -l 2>&1)
# shellcheck disable=SC2181
if [ $? -ne 0 ]
then
@killerbees19
killerbees19 / termux-su.sh
Created March 25, 2021 19:56 — forked from gwenhael-le-moine/termux-su.sh
run termux programs as root..
#!/data/data/com.termux/files/usr/bin/sh
# sudo for Termux
# For security reasons some environent variables are reset by su
# So need to set LD_LIBRARY_PATH again
# root's HOME is set to termux's home/.suroot. You can add bashrc there
ROOT_HOME=$HOME/.suroot
#/data/data/com.termux/files/usr/bin/sh
/data/data/com.termux/files/home/.shortcuts/termux-su.sh \
'/data/data/com.termux/files/home/.shortcuts/termux-su.sh "am stop-user 10"'
# Get UID: pm list users
# termux-su.sh: https://gist.github.com/killerbees19/7aa8f4af2eed34d8addc1f399459f1b1
# Double "su" trick: https://www.reddit.com/r/LineageOS/comments/8txt08/failed_to_run_settings_and_am_command/e1b2tj1/
# https://github.com/termux/termux-app/issues/1209