It all started with the code challenge in our office. The weekly theme was waves, and I tried to think outside of the box. After dropping a few ideas, I remembered the waves people do on stadiumsAccording to Wikipedia these are known as Mexican or stadium waves. So I made waves using CSS only (code ...
Easily transfer attribute values from one pydantic model instance to another instance.The ModelLet's say that you have a model and one instance:>>> from pydantic import BaseModel >>> class A(BaseModel): ... field: str ... >>> one = A(field="one") >>> one A(field='one')The Tedious CopyWhen you wanted...
Here's how to write the nested loop as a list comprehension.WhyA list comprehension is nice because it's a single expression that returns a value. This better-supports immutable data structures. If one was to use for loops, multiple nested statements would be required and the modification of an exte...
Here's a way to remove an attribute by key from an immutable dict in Python.Mutable DeleteThe usual answer is to just delete the attribute:>>> obj = { "a": 1, "b": 2 } >>> del obj["a"] >>> obj {'b': 2}But that modifies the obj dict. Modifications to shared state allow for a class of bugs that we can...
It's a nightmare that clears up quickly. You rebase, and it produces a merge conflict. Instead of looking at the file contents, you decide to simply take the incoming changes.The ScenarioYou're on your feature branch:git checkout myfeatureYou try to merge the main branch:git rebase mainThis produces...
Here's a tool that will let you convert .heic images to .jpg images on Pop!_OS or Ubuntu derivatives.Install ToolsYou'll need a few dependencies. Some you can get from apt repos:sudo apt install libheif-examplesAnd the other from git:git clone https://github.com/nitinkamra1992/heic2jpgRun ItNow run ...