Skip to content

Instantly share code, notes, and snippets.

View dettmering's full-sized avatar

Till Dettmering dettmering

View GitHub Profile
@dettmering
dettmering / colorpalette.R
Created October 1, 2013 13:55
R: Cool heatmap color palette
library(RColorBrewer)
brewer.pal(30, "RdYlBu")
@dettmering
dettmering / Dockerfile
Created December 11, 2016 11:14
GSI GD Dockerfile
FROM ubuntu:16.04
MAINTAINER tilldettmering@gmail.com
RUN apt-get update &&\
apt-get install --no-install-recommends -y \
ksh \
xvfb \
wget &&\
apt-get clean -y && rm -rf /var/lib/apt/lists/*
- bundle exec jekyll build 2>&1 | tee output.log
- grep -i "error" output.log > /dev/null ; test $? -ne 0 # fail if there is an error in output.log
@dettmering
dettmering / gist:3767424
Created September 22, 2012 19:03
PHP: Convert UNIX time into relative timestamp
// converts UNIX seconds into relative format
function relativeDate($date) {
$secondsago = time() - $date;
if ($secondsago <= 59) {$timestamp = "less than a minute ago";}
else if ($secondsago <= 119) {$timestamp = floor(($secondsago / 60)) . " minute ago (" . strftime('%R', $date) . ")";}
else if ($secondsago <= 3599) {$timestamp = round(($secondsago / 60)) . " minutes ago (" . strftime('%R', $date) . ")";}
else if ($secondsago <= 7199) {$timestamp = round(($secondsago / 3600),1) . " hours ago (" . strftime('%a %R', $date) . ")";}
else if ($secondsago <= 86400) {$timestamp = round(($secondsago / 3600)) . " hours ago (" . strftime('%a %R', $date) . ")";}
else if ($secondsago <= 345600) {$timestamp = round(($secondsago / 86400)) . " days ago (" . strftime('%a %R', $date) . ")";}
@dettmering
dettmering / gist:0c82a553fa7c51cebdf65fce2de88f92
Created June 22, 2018 14:01
Extract single pages as PNGs from multipage PDFs
gs -dBATCH -dNOPAUSE -sDEVICE=png16m -r600 -dUseCropBox -sOutputFile=item-%03d.png input.pdf
@dettmering
dettmering / rpi-smart-home.sh
Last active September 3, 2018 17:59
Raspi3 Docker Smart Home
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 / ipv6.sh
Created October 24, 2018 15:16
IPv6 iptables config
#!/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 / latex
Last active January 23, 2019 12:51
RUN interactive LaTeX container in current dir
docker run --rm -ti --name=LaTeX -v $PWD:/tex/ dettmering/latex-build latexmk -pdf /tex/bla.tex
@dettmering
dettmering / diff-all.sh
Last active January 25, 2019 13:05
Compare a single page of two PDF files.
#!/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 / rpi-log.sh
Last active February 2, 2019 14:40
Log the RaspberryPi temperature to InfluxDB
#!/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"