This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import getpass | |
from pasaffe_lib.readdb import PassSafeFile # should come with apt-get install pasaffe | |
pspass = getpass.getpass('pspass: ') | |
pf = PassSafeFile('/path/to/file.psafe3', pspass) | |
pf.get_all_folders() | |
# [['Folder 1'], ['Folder 2'], …] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
from itertools import islice | |
from find_conversations import read | |
class Census: | |
def __init__(self, represent=None): | |
self.data = {} | |
self.represent = represent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
ETIKETT_PDF="dp-electroreturn_versandetikett.pdf" | |
OUT_PDF="${ETIKETT_PDF%.pdf}-multiplied.ps" | |
if ! [[ -e "$ETIKETT_PDF" ]]; then | |
echo please download it from https://www.deutschepost.de/de/e/electroreturn.html | |
else | |
pdftops "$ETIKETT_PDF" \ | |
&& pstops "0R(0,.5h)+0R(.5w,.5h)+0L(1w,.5h)+0L(.5w,.5h)" "${ETIKETT_PDF%.pdf}.ps" "${OUT_PDF%.pdf}.ps" \ | |
&& ps2pdf "${OUT_PDF%.pdf}.ps" \ | |
&& echo generated "$OUT_PDF" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_best(choice=range(1, 1080)): | |
'''Find best integer fit for the shorter side of Golden Ratio | |
Best fit has a integer-valued longer side with the smallest error to the real Golden Ratio | |
:param choice list(int): choioce of integers | |
>>> get_best() | |
(1.2018646489717657e-06, 305) | |
''' | |
return min((((x*(5**0.5)/2) % 1)/x, x) for x in choice) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
[[ -n "$GOPATH" ]] || GOPATH="$HOME/gocode/bin" | |
PUP="$GOPATH/pup" | |
if ! [[ -e "$PUP" ]]; then | |
echo 'please install pup with' | |
echo 'GOPATH="$HOME/gocode" go get github.com/ericchiang/pup' | |
exit 1 | |
fi | |
# Aldi-Sued |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# see https://askubuntu.com/questions/276234/need-application-script-alerting-when-system-memory-is-running-out/346779#346779 | |
# add crontab -e the following: | |
# * * * * * DISPLAY=:0.0 /path/to/memwarn.bash | |
#Minimum available memory limit, MB | |
if [[ -n "$1" ]]; then | |
THRESHOLD="$1" | |
else | |
THRESHOLD=400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
expect_at = 2**22 | |
plants = expect_at * ['wind'] + ['solar'] + expect_at * ['biogas'] | |
repetitions = 100 | |
def where_is_eafp(target): | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Tool(name): | |
data = { | |
'name': name, | |
'size': 0, | |
'color': 0xffee88, | |
} | |
def get_color(): | |
return data['color'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import datetime | |
current_balance = 450 | |
desired_buffer_days = 30 | |
planned_charge_period_days = 365.25/6 | |
past_charges = [ | |
(datetime.date(2019, 6, 30), 525), | |
(datetime.date(2019, 7, 22), 1250), | |
(datetime.date(2019, 12, 1), 500), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
dumplings = (352, 175) # Kartoffel Knödel 4000400130570 | |
a5 = (210, 148) | |
def min_mod(x1, x2, n1_max): | |
def mod_for_n1(n1): | |
return (x1*n1) % x2 | |
return min((mod_for_n1(n1), n1) for n1 in range(1, n1_max)) |
OlderNewer