Skip to content

Instantly share code, notes, and snippets.

View riemers's full-sized avatar
💭
Looking forward to the sun..

Erik-jan Riemers riemers

💭
Looking forward to the sun..
View GitHub Profile
@riemers
riemers / grabum.sh
Last active October 14, 2019 22:16
Grab all Empires & Puzzles images from the wiki (since those are nice)
for ((i=1;i<=2240;i++)); # change 2240 if page id's of the wiki has increased
do
URL=$(curl -s "https://empiresandpuzzles.fandom.com/api/v1/Articles/AsSimpleJson?id=$i" | jq '..|.src?'|grep Hero_Card|sed -r 's/\/revision\/latest\/.*/\"/g')
if [[ "$URL" != "" ]]
then
URLLOWER=$(echo ${URL,,}|sed -r 's/_-_hero_card//g'|sed 's/_/ /g')
echo "curl ${URL} > \"${URLLOWER##*/}"
fi
unset URL
done
#!/bin/bash
# Set your paths below. Script can be run from any folder as long as your the right user and the drive is mounted.
# You can either include or exclude the database, incase you have mysql or simply don't want to backup a big file.
# Do check the storage on your drive.
BACKUP_FOLDER=/media/hassbackup/
BACKUP_FILE=${BACKUP_FOLDER}hass-config_$(date +"%Y%m%d_%H%M%S").zip
BACKUP_LOCATION=/home/homeassistant/.homeassistant
INCLUDE_DB=false
@riemers
riemers / dropbox.py
Last active May 22, 2020 02:15
Python uploader for dropbox (original found at https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=164166)
import os
import subprocess
from subprocess import Popen, PIPE
#The directory to sync
syncdir="/home/homeassistant/.homeassistant/"
#Path to the Dropbox-uploaded shell script
uploader = "/home/homeassistant/.homeassistant/extraconfig/shell_code/dropbox_uploader.sh"
#If 1 then files will be uploaded. Set to 0 for testing
@riemers
riemers / .profile
Last active August 29, 2015 14:16
Ansible: Make a new server ready for consumption. Since not everybody uses amazon or api related services for their setup. This assumes you have a new server (just the root password and can still ssh in with it) and want to add it to your pool of servers (read addserver.yml what it does). Just add below .profile to your current homedir where you…
PBLOC=~/projects/somewhere/addserver.yml
addserver() {
if [[ -z "$1" ]]; then
echo "[e] You need to give an IP for this to work. Dont use ssh-agent, since it will have precedence"
else
echo "[i] Running setup for new server, be ready to type in your root password"
echo "[i] Removing and re-adding the known_hosts file"
ssh-keygen -f "${HOME}/.ssh/known_hosts" -R $1
ssh-keyscan -t rsa -H $1 >> ~/.ssh/known_hosts
ansible-playbook ${PBLOC} -u root -i "newserver," --extra-vars="hosts=newserver ansible_ssh_host=$1" -k