Skip to content

Instantly share code, notes, and snippets.

@simonjenny
simonjenny / mag.py
Created December 26, 2020 21:52
Get Raspberry Pi Magazines
from bs4 import BeautifulSoup
from urllib.parse import urlparse
import requests, os
def getFile(url, file, path):
if os.path.isfile('{}/{}'.format(path, file)):
print('{} ist bereits vorhanden!'.format(file))
else:
r = requests.get(url)
with open('{}/{}'.format(path, file), 'wb') as f:
@simonjenny
simonjenny / sshlist
Created June 23, 2020 11:01
Easy SSH Dialog based on your SSH Config
#!/bin/bash
DIALOG=${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
ar=()
for i in `cat ~/.ssh/config |grep -w Host| sed -e "s/Host //g" | grep -Ei '[a-z]'`
do
ar+=($i "")
done
$DIALOG --title "SSH Servers" --menu "Bitte wähle ein Server:" 0 0 10 "${ar[@]}" 2> $tempfile
@simonjenny
simonjenny / auto-cert
Last active August 12, 2021 08:49
Automagically create Letsencrypt Certificates for Nginx Virtual Hosts
#!/bin/bash
# Name your config Files like this : DOMAIN.conf eg. example.com.conf
IP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
for filename in /etc/nginx/sites-enabled/*.conf; do
if ! grep -q "Certbot" $filename; then
CONF=$(echo "$filename" | cut -d'/' -f5)
DOMAIN=${CONF%.conf*}
if [[ $(dig +short a "$DOMAIN") == "$IP" ]]; then
@simonjenny
simonjenny / dl.sh
Created February 27, 2020 12:35
Download all Videos in Youtube Playlist as Music Files
#!/bin/bash
/usr/bin/youtube-dl -i -f 'bestaudio[ext=m4a]' --write-thumbnail --embed-thumbnail \
--metadata-from-title "%(title)s" \
--metadata-from-title "%(artist)s" \
--output '/%(playlist_title)s/%(title)s/%(title)s.%(ext)s' \
--download-archive "$1.txt" \
--write-info-json \
-q https://www.youtube.com/playlist?list=$1
@simonjenny
simonjenny / c64.py
Last active August 20, 2021 06:24
Commodore C64 Style Dashboard
# -*- coding: utf-8 -*-
# Download c64 Font : https://www.ffonts.net/Pet-Me-64.font
# Install Efa : https://simonjenny.dev/efa
# STATION="Allschwil, zum Sporn" python c64.py
import time, os, pygame, subprocess
from datetime import datetime
STATION = os.getenv('STATION', 'Basel, Marktplatz')
@simonjenny
simonjenny / rover.py
Created January 9, 2020 10:08
Autonomous Rover and Wiimote Control for ExplorerHat
import explorerhat, time, random
import RPi.GPIO as GPIO
import cwiid
mode = 0
back = explorerhat.analog.three
front = explorerhat.analog.four
speed = 50
wii_connected = False
@simonjenny
simonjenny / rover.py
Created January 9, 2020 10:06
WiiMote Remote for ExplorerHat
import explorerhat, time, random
import RPi.GPIO as GPIO
import cwiid
import os
import sys
speed = 50
wii_connected = False
def connect_wii():
@simonjenny
simonjenny / slideshow.py
Last active May 18, 2023 14:52
Slideshow for Raspberry Pi (or any other Python capable OS)
# -*- coding: utf-8 -*-
import os, pygame, random
pygame.init()
pygame.mouse.set_visible(False)
BACKGROUND = (0,0,0)
INTERVAL = os.getenv('INTERVAL', 60)
IMAGEFOLDER = os.getenv('IMAGEFOLDER', 'images')
@simonjenny
simonjenny / igit
Created March 13, 2019 14:13
Git all in one..
#!/bin/bash
if [ -z "$1" ]
then
echo "Commit Reason is empty"
exit 0
fi
~/Development/./clean.sh
git add .
git commit -m "$1"
git push
@simonjenny
simonjenny / lego.sh
Last active January 9, 2020 12:06
Find Lego building instructions by set number from the command line and open the PDF in the default browser
#!/usr/bin/env bash
ARRAY=()
var=1
rows=$(curl --silent "https://www.lego.com//service/biservice/search?fromIndex=0&locale=en-US&onlyAlternatives=false&prefixText=${1}"|jq -r '.products[0].buildingInstructions[].pdfLocation')
for row in $rows;
do
ARRAY+=(${row})
echo "$((var++)). ${row}"
done
echo -ne "Welche Anleitung soll ich öffnen? "