Skip to content

Instantly share code, notes, and snippets.

View Achimh3011's full-sized avatar

Achim Herwig Achimh3011

  • Munich, Germany
View GitHub Profile
from pathlib import Path
from typing import List, Callable, Optional, Sequence
class Functor():
def __init__(self, start: int) -> None:
self.start = int(start)
def __call__(self, data: List[int]) -> int:
return self.start + len(data)

Keybase proof

I hereby claim:

  • I am achimh3011 on github.
  • I am achimh (https://keybase.io/achimh) on keybase.
  • I have a public key whose fingerprint is 8976 B42E 4BA4 3230 3A66 9480 9420 58FF D2DA 4EAA

To claim this, I am signing this object:

@Achimh3011
Achimh3011 / post-merge.py
Last active August 29, 2015 14:16
Check whether the newly pulled revisions are marked with a special keyword
#!/usr/bin/env python3
import subprocess
import sys
PATTERN = 'MY-SPECIAL-COMMIT-MARKER'
with subprocess.Popen(['git', 'reflog'], stdout=subprocess.PIPE) as proc:
lines = proc.stdout.readlines()
new, old = [l.decode().split()[0] for l in lines[:2]]
@Achimh3011
Achimh3011 / check_version.py
Created February 8, 2012 07:13
Python version elucidation
import sys
try:
major, minor = sys.version_info.major, sys.version_info.minor
except AttributeError:
major, minor = sys.version_info[:2]
if major < 2 or major == 2 and minor < 7:
sys.stderr.write("You need at least Python 2.7 to run this program, but you only have %d.%d.\n"%(major,minor))
sys.exit(1)
else: # only for testing this
sys.stderr.write("You have Python %d.%d.\n"%(major,minor))