Skip to content

Instantly share code, notes, and snippets.

Michael Floering hangtwenty

Block or report user

Report or block hangtwenty

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
hangtwenty /
Last active Oct 9, 2019 — forked from joseluisq/
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits:

git log --graph --oneline --decorate $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

hangtwenty /
Last active Mar 28, 2019
Note on Python TIA (Test Impact Analysis)


What could I try for doing Test Impact Analysis for Python projects?


There are a few libraries out there you could try. Here are some entrypoints:

hangtwenty /
Last active Mar 11, 2019
blog draft: continuous learning is the keystone habit of software development. oh, and the other part: you have to get over yourself!

I've self-educated as a developer; now almost 10 years into it, it's worked out for me. But why? What was the deciding factor?

Looking back, I think I can see the inflection point.

I had a mentor who helped me use interactive approaches, and test-driven development. This led to a test-driven mindset.

The core of this mindset is the empirical attitude: that you can know nothing without testing. I learned to iterate in a more directed way. And by always beginning with failing tests,

hangtwenty / _preserve_ipython_history_TLDR.diff
Last active Apr 18, 2019
preserve ipython history between docker-compose runs (for local/development usage). diff is only approximately two lines
View _preserve_ipython_history_TLDR.diff
diff --git a/local.yml b/local.yml
index b587373..73684bf 100644
--- a/local.yml
+++ b/local.yml
@@ -3,6 +3,7 @@ version: '2'
+ ipython_data_local: {}
hangtwenty / owasp-risk-rating.html
Created Sep 20, 2017 — forked from ErosLever/owasp-risk-rating.html
This is a quick and dirty OWASP Risk Rating Calculator. (demo: )
View owasp-risk-rating.html
<!-- access this at: -->
width: 1200px;
table {
width: 98%;
font-size: small;
text-align: center;
hangtwenty /
Last active Sep 21, 2019
simple HOWTO docstring to paste at top of test packages/modules, i.e. on teams less familiar with pytest
""" Tests for `foo` package.
uses pytest. pytest resources:
* Docs:
* Book!
also uses `responses`, for mocking HTTP exchanges with `requests` library:
hangtwenty /
Last active Sep 21, 2019 — forked from kissgyorgy/
Python: Remove punctuation from string (quickly)
import re, string
table = string.maketrans("","")
regex = re.compile('[%s]' % re.escape(string.punctuation))
def test_re(s): # From Vinko's solution, with fix.
return regex.sub('', s)
def test_trans(s):
hangtwenty /
Last active Sep 6, 2017
(OLD; newer version is here: ) I wanted to "ensure" strings had been sanitized (avoid running redundantly). This is ONLY ONE type of sanitization, removing control chars (BESIDES NEWLINES), because that is what my current project needed. But I thought the design could be…
""" throw your strings to SanitizedString and "ensure" they have been sanitized, such as removing control characters.
SanitizedString will avoid running redundantly, by checking type of the input (good for Very Big Strings)
>>> hello = SanitizedString(chr(0) + "hello")
>>> assert hello == "hello"
>>> assert chr(0) not in hello
>>> assert SanitizedString(hello) == hello
at time of writing there is only one sanitization filter in use:
hangtwenty / logging.yml
Last active Feb 2, 2018 — forked from OrangeTux/log.yml
A starter config I like for development/non-production Python logging. (in production I use syslog etc instead). Replace filenames as needed - by hand in YAML, or in your setup code.
View logging.yml
version: 1
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
format: "%(levelname)-8s %(asctime)s %(name)s %(filename)s:%(lineno)s | %(funcName)s | %(message)s"
format: "%(levelname)-8s %(asctime)s %(name)s %(pathname)s:%(lineno)s | %(funcName)s | %(message)s"
hangtwenty /
Last active Oct 19, 2018
fix that pesky "ImportError: No module named packaging.version" problem. Or more generally, if you need to fix pip using pip, just make sure you do "python -m pip" instead of straight-up "pip".

It can come up while installing anything really. I'm not sure exactly which versions of pip are affected, I know I had 1.5.6 and it was affected.

These examples are grabbed from my system level Python, but of course you should use a virtualenv.

  Running install for simplegeneric
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Library/Python/2.7/site-packages/setuptools/", line 12, in <module>
        import setuptools.version
You can’t perform that action at this time.