November of 2021
Projects⚑
-
New: Add seed to self host a routing web application.
Host and play around with brouter and brouter-web.
Life Management⚑
Map Management⚑
-
New: How I manage maps in my life.
For navigating on the go, I strongly recommend OSMand+, for browsing maps in the browser, use OpenStreetMaps or CyclOSM if you want to move by bike.
To plan routes, you can use brouter.de, it works perfectly for bikes. For hiking is awesome too, it shows you a lot of data needed to plan your tracks (check the settings on the right). If you want to invest a little more time, you can even set your personalize profiles, so that the routing algorithm prioritizes the routes to your desires. It's based on brouter and both can be self-hosted, although brouter does not yet use Docker.
Coding⚑
Python⚑
asyncio⚑
-
New: Limit concurrency.
Use
asyncio.Semaphore
.sem = asyncio.Semaphore(10) async with sem: # work with shared resource
Full screen applications⚑
-
New: How to use Conditional Containers.
from prompt_toolkit.layout import ConditionalContainer from prompt_toolkit.filters.utils import to_filter show_header = True ConditionalContainer( Label('This is an optional text'), filter=to_filter(show_header) )
Type Hints⚑
-
New: Define a TypeVar with restrictions.
from typing import TypeVar AnyStr = TypeVar('AnyStr', str, bytes)
-
New: Use a constrained TypeVar in the definition of a class attributes.
If you try to use a
TypeVar
in the definition of a class attribute:class File: """Model a computer file.""" path: str content: Optional[AnyStr] = None # mypy error!
mypy will complain with
Type variable AnyStr is unbound [valid-type]
, to solve it, you need to make the class inherit from theGeneric[AnyStr]
.class File(Generic[AnyStr]): """Model a computer file.""" path: str content: Optional[AnyStr] = None
Dash⚑
-
New: Testing Dash applications.
dash.testing
provides some off-the-rack pytest fixtures and a minimal set of testing APIs with our internal crafted best practices at the integration level. The commit includes a simple example and some guides on how to test Dash application.
Properties⚑
-
New: Automatically generate a factory from a pydantic model.
Sadly it's not yet supported, it will at some point though. If you're interested in following this path, you can start with mgaitan snippet for dataclasses.
-
New: Give an overview on Python's @property decorator.
Faker⚑
-
New: Create a random string with a defined format.
faker.pystr_format("id-#######{{random_letter}}") 'id-6443059M'
-
faker.ipv4()
If you want a CIDR, use
network=True
.
Python Snippets⚑
-
New: Replace all characters of a string with another character.
mystring = '_'*len(mystring)
-
New: Make a flat list of lists with a list comprehension.
There is no nice way to do it :(. The best I've found is:
t = [[1, 2, 3], [4, 5, 6], [7], [8, 9]] flat_list = [item for sublist in t for item in sublist]
-
New: Remove a substring from the end of a string.
On Python 3.9 and newer you can use the
removeprefix
andremovesuffix
methods to remove an entire substring from either side of the string:url = 'abcdc.com' url.removesuffix('.com') # Returns 'abcdc' url.removeprefix('abcdc.') # Returns 'com'
On Python 3.8 and older you can use
endswith
and slicing:url = 'abcdc.com' if url.endswith('.com'): url = url[:-4]
Pydantic⚑
-
New: Define fields to exclude from exporting at config level.
Eagerly waiting for the release of the version 1.9 because you can define the fields to exclude in the
Config
of the model using something like:class User(BaseModel): id: int username: str password: str class Transaction(BaseModel): id: str user: User value: int class Config: fields = { 'value': { 'alias': 'Amount', 'exclude': ..., }, 'user': { 'exclude': {'username', 'password'} }, 'id': { 'dump_alias': 'external_id' } }
The release it's taking its time because the developer's gremlin and salaried work are sucking his time off.
-
New: Field customization.
Optionally, the
Field
function can be used to provide extra information about the field and validations. Such as thetitle
,default
,description
and many others
Tenacity⚑
-
New: Introduce the Tenacity python library.
Tenacity is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything.
DevOps⚑
Infrastructure as Code⚑
Helm Git⚑
-
Correction: Update installation method.
In the last version 0.11.1, the issue that forced us to use the version 0.8.0 was solved
Infrastructure Solutions⚑
Jobs⚑
-
New: Manually creating a job from a cronjob.
kubectl create job {{ job_name }} -n {{ namespace }} \ --from=cronjobs/{{ cronjob_name}}
Continuous Integration⚑
Pyment⚑
-
New: Introduce Pyment.
Pyment is a python3 program to automatically create, update or convert docstrings in existing Python files, managing several styles.
As of 2021-11-17, the program is not production ready yet for me, I've tested it in one of my projects and found some bugs that needed to be fixed before it's usable. Despite the number of stars, it looks like the development pace has dropped dramatically, so it needs our help to get better :).
Operative Systems⚑
Linux⚑
Github cli⚑
-
New: Basic usage of gh.
gh
is GitHub’s official command line tool.It can be used to speed up common operations done with github, such as opening PRs, merging them or checking the checks of the PRs
Graylog⚑
-
New: Introduce Graylog.
Graylog is a log management tool. The commit includes some tips like how to send a test message to check an input.
Jellyfin⚑
Vim⚑
- Correction: Correct vim snippet to remember the folds when saving a file.
Arts⚑
Board Gaming⚑
Regicide⚑
-
New: Introduce the awesome Regicide card game.
Regicide is a wonderful cooperative card game for 1 to 4 players. It's awesome how they've built such a rich game dynamic with a normal deck of cards. Even if you can play it with any deck, I suggest to buy the deck they sell because their cards are magnificent and they deserve the money for their impressive game. Another thing I love about them is that even if you can't or don't want to pay for the game, they give the rules for free.
If you don't like reading the rules directly from their pdf (although it's quite short), they explain them in this video.
I've loved the game so much, that I've created some variations of the rules to make each game more different and changeling.