Skip to content

Instantly share code, notes, and snippets.

@vilhelmen
vilhelmen / gadm_41_discard_subdata.sh
Created January 28, 2023 01:18
GADM 4.1 importer
#!/bin/bash
# You probably don't care about States, cities, counties, etc.
cat <<EOF
BEGIN;
DROP TABLE IF EXISTS gadm.adm_1;
DROP TABLE IF EXISTS gadm.adm_2;
DROP TABLE IF EXISTS gadm.adm_3;
@vilhelmen
vilhelmen / unifi_install.sh
Last active August 15, 2021 09:55
Pfsense unifi installer stuff
#!/bin/sh
ABI=`/usr/sbin/pkg config abi`
# Modify /usr/local/etc/pkg/repos/pfSense.conf to include FreeBSD data:
# FreeBSD: {
# url: "pkg+https://pkg.freebsd.org/${ABI}/latest",
# mirror_type: "srv",
# signature_type: "fingerprints",
# fingerprints: "/usr/share/keys/pkg/",
@vilhelmen
vilhelmen / zone.sh
Last active February 10, 2018 04:19
DDWRT caching Cloudflare DNS updater script without jffs
#!/bin/sh
# This assumes we are the only one who updates this record
# Doesn't need jffs to work.
# Base64 encode (use 64-char breaks) this and load into startup script
# Decode with openssl (busybox is missing uudecode???) to the filesystem and chmod +x
# Add script target location to cron
ZONE_ID='WWWWW'
API_KEY='XXXXX'
@vilhelmen
vilhelmen / email-alert.sh
Last active June 27, 2016 21:12
Email alert service for systemd
#!/bin/sh
LOG_DATA=$(mktemp --suffix='.log')
journalctl -o short --since -30min -u ${2} > ${LOG_DATA}
echo "Service ${2} has failed on ${1}. Log attached." | mutt -F mutt.cfg -s "${1} SERVICE FAILURE ALERT" -a ${LOG_LOC} $(cat recipients.cfg)
#!/bin/zsh
# see documentation at http://linux.die.net/man/1/zshexpn
# A: finds the absolute path, even if this is symlinked
# h: equivalent to dirname
#local __GIT_PROMPT_DIR=${0:A:h}
local gitstatus="${0:A:h}/gitstatus"
#export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_USE_PYTHON:-"python"}