Other articles


  1. Terminal Input Selector in Python

    When writing a cli program that needs the user to make a choice, you might want to present a list of options and get a selection. The simplest way might be to print each option and get the user to type the one or the index of the one they …

    read more
  2. Muting Linter Errors in Python

    Linters and static type checker are great for finding bugs in your code, but sometimes they misunderstand or you have some other reasons for leaving the code as is. In that case you might want to mute the error(s) to allow the linting or type checking to pass, either …

    read more
  3. Smart CLIs with Typer

    Published: Sat 06 May 2023
    Updated: Tue 29 August 2023
    By Rahul Pai

    In Python.

    The go-to library for adding CLI functionality in python is the built in argparse library. This works really well, but there is a relatively new 3rd party library called typer that boasts a number of improvements.

    Firstly, with typer, rather than configuring a parser with each argument, you can simply …

    read more
  4. Investigating Deadlocks in Postgres

    When performing transactions on the same tables in Postgres from multiple apps, you might face deadlocks.

    You might get an error like this one (example from here):

    DBAPIError: (TransactionRollbackError) deadlock detected
    DETAIL:  Process 61086 waits for ExclusiveLock on tuple (7217,55) of relation 626383 of database 380717; blocked by process …
    read more
  5. Property Based Testing With Hypothesis

    This is a summary based on this article.

    Rather than specifying test cases, define properties that your functions must fulfil, and let hypothesis generate dozens of test cases automatically.

    from hypothesis import given, strategies as st
    
    @given(st.integers(), st.integers())
    def test_func(a, b):
        # get result
        c = func(a …
    read more
  6. Local Network Speed Test

    There are multiple reasons why you might want to test the speed of you local network. For example you can test the speed between your router and your device. Or the speed between your device and a home server. For me it was the former. I wanted to make sure …

    read more

links

social