Skip to content

Instantly share code, notes, and snippets.

View rodigu's full-sized avatar
:electron:
☝️🤓

Rodrigo Morais rodigu

:electron:
☝️🤓
View GitHub Profile
@rodigu
rodigu / python-golfing-walrus.md
Last active March 25, 2025 15:30
code golfing with the the assignment expression operator (the golfing walrus `:=`)

the walrus operator, introduced in python 3.8, has been quite an useful tool.

it's documentation gives some examples of its intended use:

if (n := len(a)) > 10:
    print(f"List is too long ({n} elements, expected <= 10)")

before the introduction of the walrus, you'd have to do:

@rodigu
rodigu / airflow-daemon-logs.md
Created February 14, 2025 10:45
how to check airflow webserver logs from daemon

reference

journalctl -u airflow-webserver.service
@rodigu
rodigu / python-pandas-composite-id.md
Last active February 17, 2025 12:15
composite id column in dataframe

say we have a dataframe with many columns.

we want a new id column, which will be a concatenation of two or more columns in the dataframe.

this is useful in a case when we have a table without a "natural" id. for example a sales table with a client_id column, and a purchase_datetime.

this function will concat our columns:

@rodigu
rodigu / airflow-pickling.md
Created February 17, 2025 12:12
pickling classes in airflow

one of our classes, which made use of the pbipy library, could not be passed through XCom. we were getting the following error: airflow cannot pickle [CLASS] object

the fix involved changing a cfg variable to false:

# Whether to enable pickling for xcom (note that this is insecure and allows for
# RCE exploits).
# Variable: AIRFLOW__CORE__ENABLE_XCOM_PICKLING
enable_xcom_pickling = False
@rodigu
rodigu / architecture-unit-testing.md
Last active February 17, 2025 14:03
unit testing considered harmful?

in searching more in depth for topics in software architecture, i have come accross Simon Brown's Software Architecture vs Code lecture, for GOTO 2014.

the section that most caught my attention, was his reference to Why Most Unit Testing is Waste [^1], by James O Coplien.

in the paper, a specific quote from Coplien caught my attention:

(...) notions such as: “Every line of code has been reached,” which, from the perspective of theory of computation, is pure nonsense (...)

which is, undeniably true and, as i tought more about it, also comically unfortunate that lines of code reached is used as a measurement of test coverage.

@rodigu
rodigu / python-pip-show.md
Created February 19, 2025 19:28
checking for pip package versions
pip show [package]
@rodigu
rodigu / reference-wumbo.md
Created March 24, 2025 12:53
reference-wumbo

wumbo is a website with references for formal mathematical symbols.

@rodigu
rodigu / quote-walden-delicate-handling.md
Created March 26, 2025 09:50
walden - the most delicate handling

The finest qualities of our nature, like the bloom on fruits, can be preserved only by the most delicate handling. Yet we do not treat ourselves nor one another thus tenderly.

Thoreau, Henry David; Walden; 31

NPR how much does this cow weight survey:
- https://www.npr.org/sections/money/2015/08/07/429720443/17-205-people-guessed-the-weight-of-a-cow-heres-how-they-did
- https://www.npr.org/sections/money/2015/08/07/429720443/17-205-people-guessed-the-weight-of-a-cow-heres-how-they-did
[Hill investment wisdom of the crowd](https://www.hillinvestmentgroup.com/2023/08/17/wisdom-of-crowds/)
[first american wisdom of the crowd](https://blog.firstam.com/economics/the-wisdom-of-the-crowd-myth-or-reality)
betting markets in elections