Skip to content

Instantly share code, notes, and snippets.

Till Dettmering dettmering

Block or report user

Report or block dettmering

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dettmering
dettmering / drawio-export-pdf.sh
Created Jul 11, 2019
draw.io: Export all .drawio files in folder to PDF and PNG while preserving history. Very useful as a post-commit hook.
View drawio-export-pdf.sh
#!/bin/bash
rm -f *.pdf
rm -f *.png
COMMIT=$(git rev-parse HEAD)
for f in *.drawio
do
/Applications/draw.io.app/Contents/MacOS/draw.io --export --all-pages --output $f.pdf $f
@dettmering
dettmering / gist:3767366
Created Sep 22, 2012
Python: Read CSV file into array
View gist:3767366
def readcsv(filename):
ifile = open(filename, "rU")
reader = csv.reader(ifile, delimiter=";")
rownum = 0
a = []
for row in reader:
a.append (row)
rownum += 1
@dettmering
dettmering / docx2pdf.scpt
Created Apr 17, 2019
Apple Script to convert DOCX into PDF
View docx2pdf.scpt
on run {input, parameters}
tell application id "com.microsoft.Word"
activate
repeat with aFile in input
open aFile
set theOutputPath to ((aFile as text) & ".pdf")
tell active document
save as it file name theOutputPath file format format PDF
close saving no
end tell
@dettmering
dettmering / ping.1m.py
Created Jan 30, 2019
BitBar plugin for showing host availability
View ping.1m.py
#!/usr/local/bin/python3
import os
hosts = [
'google.com',
'microsoft.com'
]
header = []
@dettmering
dettmering / rpi-log.sh
Last active Feb 2, 2019
Log the RaspberryPi temperature to InfluxDB
View rpi-log.sh
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))
serial=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2)
host="localhost:8086"
@dettmering
dettmering / diff-all.sh
Last active Jan 25, 2019
Compare a single page of two PDF files.
View diff-all.sh
#!/bin/bash
FILE_A=$1
FILE_B=$2
PAGE_COUNT_A=$(pdfinfo $FILE_A | grep Pages | awk '{print $2}')
PAGE_COUNT_B=$(pdfinfo $FILE_B | grep Pages | awk '{print $2}')
if [ $PAGE_COUNT_A -eq $PAGE_COUNT_B ];
then
@dettmering
dettmering / latex
Last active Jan 23, 2019
RUN interactive LaTeX container in current dir
View latex
docker run --rm -ti --name=LaTeX -v $PWD:/tex/ dettmering/latex-build latexmk -pdf /tex/bla.tex
@dettmering
dettmering / ipv6.sh
Created Oct 24, 2018
IPv6 iptables config
View ipv6.sh
#!/bin/bash
# ip6tables single-host firewall script
# Define your command variables
ipt6="/sbin/ip6tables"
# Flush all rules and delete all chains
# for a clean startup
$ipt6 -F
@dettmering
dettmering / rpi-smart-home.sh
Last active Sep 3, 2018
Raspi3 Docker Smart Home
View rpi-smart-home.sh
docker run -d -u $(id -u):$(id -g) \
--name=hass --net=host --restart=always \
-v /home/pi/hass:/config \
-v /etc/localtime:/etc/localtime:ro \
homeassistant/raspberrypi3-homeassistant:latest
docker run -d --restart=always -v /home/pi/homegear/etc:/etc/homegear:Z -v /home/pi/homegear/lib:/var/lib/homegear:Z -v /home/pi/homegear/log:/var/log/homegear:Z -e TZ=Europe/Berlin -e HOST_USER_ID=$(id -u) -e HOST_USER_GID=$(id -g) --net=host --name homegear homegear/rpi-homegear:stable
docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer --no-auth
@dettmering
dettmering / gist:0c82a553fa7c51cebdf65fce2de88f92
Created Jun 22, 2018
Extract single pages as PNGs from multipage PDFs
View gist:0c82a553fa7c51cebdf65fce2de88f92
gs -dBATCH -dNOPAUSE -sDEVICE=png16m -r600 -dUseCropBox -sOutputFile=item-%03d.png input.pdf
You can’t perform that action at this time.