Skip to content

Instantly share code, notes, and snippets.

View da-h's full-sized avatar
🐧
btw I use arch

David Hartmann da-h

🐧
btw I use arch
  • Mainz
  • 11:34 (UTC +02:00)
View GitHub Profile
@da-h
da-h / annotate-missing-git-tags
Last active October 5, 2019 06:42
annotate git commits by their corresponding version
#/bin/bash
branch=master
versionfile=src/module/__init__.py
for commit in $(git rev-list $branch --reverse)
do
version=$(git show $commit:$versionfile | sed -n -e "s/^__version__ = \"\([0-9]\+\(\.[0-9]\)\+\)\"/\1/p")
echo $version
git tag -a v$version $commit -m "Release, v$version"
done
@da-h
da-h / welford.py
Last active March 18, 2019 14:00 — forked from alexalemi/welford.py
Python Welford Algorithm
# adaption of https://gist.github.com/alexalemi/2151722
# by da-h
# minor changes
import numpy as np
class Welford(object):
""" Implements Welford's algorithm for computing a running mean
and standard deviation as described at:
http://www.johndcook.com/standard_deviation.html
@da-h
da-h / curldyndns.sh
Last active March 13, 2019 18:50
DynDNS with Curl and dig.
#!/bin/bash
DNS="
firstdns.com
seconddns.com
"
SERVER=dyndns.xxx/nic/update
USERNAME=xxx
PASSWORD=xxx
@da-h
da-h / humansort.py
Last active January 14, 2019 08:27
Human Sorting
import re
def natural_keys(text):
return [ int(c) if c.isdigit() else c for c in re.split('(\d+)',text) ]
# example
my_list =['Hello1', 'Hello12', 'Hello29', 'Hello2', 'Hello17', 'Hello25']
my_list.sort(key=natural_keys)
print(my_list)
#!/bin/bash
# needs https://github.com/wmutils/core for wattr
eval $(xdotool getmouselocation --shell)
IFS=" " read -a window <<< $(wattr whxy $(bspc query -N -n focused))
north=$(( Y - window[3]))
west=$(( X - window[2]))
width=${window[0]}
height=${window[1]}