Skip to content

Instantly share code, notes, and snippets.

View YourFriendCaspian's full-sized avatar
🙃
I'm sure I'll be slow to respond so don't be mad.

yourfriendcaspian YourFriendCaspian

🙃
I'm sure I'll be slow to respond so don't be mad.
View GitHub Profile
@YourFriendCaspian
YourFriendCaspian / Fan_Control.py
Created June 26, 2019 13:32
Raspberry Pi Fan Control Script
#Raspberry Pi Fan Control Script
import RPi.GPIO as IO
from gpiozero import CPUTemperature
import time
minspin = 10
IO.setwarnings(False)
$ cat Makefile
.PHONY: all
.DEFAULT_GOAL := help
.ONE_SHELL:
SHELL = /bin/bash
FOLDER = $(shell basename "$$(pwd)" | cut -d'-' -f3)
help: ## Show the available CLI arguments
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo "[+] Example:"
@YourFriendCaspian
YourFriendCaspian / remove_unwanted_prefix.md
Created May 5, 2019 19:23
Remove unwanted prefixes from filenames

Remove unwanted prefixes from filenames

Remote the prefix 'unwanted' from the beginning of each filename with .jpg suffix.

rename 's/^unwanted//' *.jpg

version: '3.1'
services:
unifi:
container_name: unifi
restart: unless-stopped
image: linuxserver/unifi
volumes:
- /srv/docker/unifi:/config
environment:
- PGID=0
@YourFriendCaspian
YourFriendCaspian / docker-compose.yml.traefik_full
Created April 1, 2019 06:24
Taefik-reverse-proxy-tutorial-for-docker
#Reference: https://www.smarthomebeginner.com/traefik-reverse-proxy-tutorial-for-docker
#Requirement: Set environmental variables: ${$USERDIR}, ${PUID}, ${PGID}, ${TZ}, ${DOMAINNAME}, ${CLOUDFLARE_EMAIL}, ${CLOUDFLARE_API_KEY}, ${HTTP_USERNAME}, ${HTTP_PASSWORD}, etc. as explained in the reference.
version: "3.6"
services:
######### FRONTENDS ##########
# Traefik Reverse Proxy
traefik:
@YourFriendCaspian
YourFriendCaspian / pihole_ip2hostname.py
Created March 31, 2019 17:39
This script changes Pi-Hole so it displays recognizable hostnames instead of IP addresses .
#!/usr/bin/env python3.6
'''
Pihole is great, but the admin interface only displays device details
by IP address which can be confusing. This script changes the display
from IP address to a more recognizable hostname. And as a bonus, attaches
the profile (from fingerbank.org) of the device to the hostname as well -
so instead of something like 192.168.1.101, you see galaxys6-samsung.
Shweet.
Usage notes
@YourFriendCaspian
YourFriendCaspian / code.gs
Created March 30, 2019 07:35 — forked from juzim/code.gs
Google apps script for parsing the URL of the free ebook from the packtpub newsletter
function extractPacktpubUrl() {
try {
var ss = SpreadsheetApp.getActiveSheet();
var label = GmailApp.getUserLabelByName("packt_free_ebook");
var threads = label.getThreads();
if (threads[0] == undefined || threads[0].getMessages()[0] == undefined) {
Logger.log('No valid message found');
traefik:
container_name: traefik
domainname: homedomain.lan
image: traefik
restart: unless-stopped
# Note I opt to whitelist certain apps for exposure to traefik instead of auto discovery
# use `--docker.exposedbydefault=true` if you don't want to have to do this
command: "--web --docker --docker.domain=homedomain.lan --docker.exposedbydefault=false --logLevel=DEBUG"
ports:
- "80:80"
# Cleanup commands
# To stop compose.yml
# docker-compose -f ~/docker/docker-compose.yml down
# docker system prune && docker image prune && docker volume prune
#Run after adding each container
# docker-compose -f ~/docker/docker-compose.yml up -d
version: "3.6"
services:
# Redirect all http traffic to https
server {
listen 80;
return 301 https://$host$request_uri;
}
# Portainer Upstream
upstream portainer {
server YOUR.PI.IP.ADDRESS:9000;
keepalive 32;