Articles in the Trucs et astuces category

Ignore commits in git blame

Commits that change formatting are a pain in git because they make using git blame much harder. It turns out, you can ask git to ignore these commits when running git blame with the --ignore-rev option and passing it a commit hash. You can even do things better and create …

Read more...

Use the same function as context manager and decorator

I recently learned that context managers created with @contextmanager can be used either as a context manager or a decorator:

from contextlib import contextmanager

@contextmanager
def test_context():
    print('Entering')
    yield
    print('Leaving')

with test_context():
    print('Inside')

@test_context()
def test_decorated():
    print('Decorated')

test_decorated()

We will yield:

Entering
Inside
Leaving

Entering
Decorated …

Read more...

Check domains

Here is a small script to allow you to easily check that a domain you manage is correct (ie responds correctly, is available with IPv4 and IPv6, only supports TLS 1.2+…). It even has some color built in! You can, of course, adapt it to fit your needs.

You …

Read more...