Skip to content

Instantly share code, notes, and snippets.

View adewes's full-sized avatar

Andreas Dewes adewes

View GitHub Profile
@adewes
adewes / track_temperature.sh
Last active February 28, 2024 16:33
Temperature Tracking Script
#!/bin/bash
# logs the temperature every minute
# sends a message if it is too high or low or if it can't be measured
# also sends a message at a given time every day
#sensor ID (must be a DS18B20 sensor)
SENSOR_ID="28-011453d372aa"
# hour when to send the message
REF_HOUR="17:00"
# maximum temperature
@adewes
adewes / README.md
Last active March 8, 2024 21:58
Borg Backup - Shell script to create regular backups (can e.g. be called hourly by cron).

Borg Backup Script

This is a little helper script to regulary back up your data using the Borg backup tool. I wrote this as I was frustrated with Deja-Dup, which does not allow me to exclude directories by pattern, hence I ended up with backups that were very large and took a really long time to create because they contained many directories with non-essential files (e.g. node modules or Python virtual environments). Borg backup is a simple tool that offers everything that Deja-Dup does and is easier to customize.

  • Put the script in your home folder and make it executable.
  • Call it regularly using e.g. cron (put e.g. "0 * * * * [your username] /home/[your username]/make_backup.sh" in your /etc/crontab - this will call the script every hour). Please note that the script will perform its own checking to see
@adewes
adewes / contracts.py
Created July 12, 2017 14:55
Contracts in Python
import functools
import inspect
class Validated(type):
"""
Base meta-class for our validation classes.
"""
def __getitem__(self, type):
@adewes
adewes / Makefile
Created November 12, 2015 10:28
The build watcher: Automatically rebuild Pelican content as files change.
# Changes gather, and now my watch begins.
# It shall not end until my death.
# I shall live and die at my post.
# I am the process in the darkness.
# I am the watcher on the files.
# I am the shield that guards the realms of the build dir.
watch:
@which inotifywait || (echo "Please install inotifywait";exit 2)
@while true ; do \
@adewes
adewes / find_circular_dependencies.py
Last active September 16, 2015 16:48
Finding circular dependencies in your SQLAlchemy data scheme
from collections import defaultdict
dependencies = defaultdict(set)
#use your metadata object here
for t in metadata.sorted_tables:
for fkey in t.foreign_key_constraints:
dependencies[t.name].add(fkey.referred_table.name)
@adewes
adewes / README.md
Last active February 13, 2024 16:39
Ebay Ads - Bot. Because who wants to write messages by hand...

To use this bot:

  • Download ads_bot.py and requirements.txt.
  • Type pip install -r requirements.txt to install the requirements.
  • Fill out the required information in the Python file.
  • Ideally, create a (free) Slack account and set up a web hook to receive notifications from the bot.
  • Run the script :)
  • Relax and be ready to answer incoming calls :D
@adewes
adewes / eight_queens.sql
Last active February 18, 2024 03:07
Eight Queens Problem Solved using Common Table Expressions
WITH RECURSIVE
positions(i) as (
VALUES(0)
UNION SELECT ALL
i+1 FROM positions WHERE i < 63
),
solutions(board, n_queens) AS (
SELECT '----------------------------------------------------------------', cast(0 AS bigint)
FROM positions
UNION
### Keybase proof
I hereby claim:
* I am adewes on github.
* I am dewes (https://keybase.io/dewes) on keybase.
* I have a public key whose fingerprint is 3BCA 20E5 94D4 910B 070E 25D6 8E2F D9A8 CBA7 BA57
To claim this, I am signing this object:
@adewes
adewes / export.py
Created April 9, 2014 17:11
Python: Dictionary Value Exporter
def export(d,key):
"""
Exports a set of values from a nested dict.
Example usage:
d = {
'name' : 'test',
'remote_servers' :
@adewes
adewes / hacker_school_effect.ipynb
Created March 11, 2014 04:34
The Hacker School Effect
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.