Skip to content

Instantly share code, notes, and snippets.

Michael Herrmann mherrmann

View GitHub Profile
@mherrmann
mherrmann / digistore_query_valid.py
Created Mar 25, 2020
digistore python validate thank you page
View digistore_query_valid.py
from hashlib import sha512
from urllib.parse import parse_qs, unquote
def is_digistore_query_valid(qs, thankyou_page_key):
qs_dict = {key: unquote(value[0]) for key, value in parse_qs(qs).items()}
expected_sha = qs_dict.pop('sha_sign')
sha_string = ''
for key, value in sorted(qs_dict.items()):
sha_string += f'{key}={value}{thankyou_page_key}'
m = sha512()
View CLA.md

Contributor License Agreement

In order to clarify the intellectual property license granted with Contributions from any person or entity, Michael Herrmann ("Michael") requires a Contributor License Agreement ("CLA") to be signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as Michael's protection; it does not change your rights to use your own Contributions for any other purpose.

You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Michael. Except for the license granted herein to Michael and recipients of software distributed by Michael, You reserve all right, title, and interest in and to Your Contributions.

  1. Definitions.
    "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Michael. For legal entities, the entity making a Contribution and all other entities that control, are
@mherrmann
mherrmann / hiddenfiles_osx.py
Created Oct 5, 2016
Determine if a file is hidden on OS X
View hiddenfiles_osx.py
from ctypes import CFUNCTYPE, POINTER, c_uint8, c_void_p, c_long, addressof, \
byref, CDLL, cdll, c_char_p
from ctypes.util import find_library
def is_hidden(path):
if not isinstance(path, bytes):
path = path.encode('utf-8')
with AutoRelease() as autorelease:
url = autorelease(CFURLCreateFromFileSystemRepresentation(
None, path, len(path), False
@mherrmann
mherrmann / timer.py
Last active Dec 15, 2015
Measure the time taken by some Python code
View timer.py
from collections import OrderedDict
from time import time
class Timer(object):
"""
Measure the time taken by some Python code, incl. its subtasks:
>>> with Timer('parent') as timer:
... sleep(0.5)
... with timer.child('child') as child:
You can’t perform that action at this time.