TIL you can hash None in Python
Recently I saw some Python code which looked something like:
d = { None: "value", "another_key": "another_value", } It had never really occurred to me you could use None (null) as a key to a dictionary before. What this also meant is that None must be hashable as only hashable objects can be keys in a dictionary. These objects include strings, tuples, sets but don’t include lists as they are mutable and not hashable.
...
TIL you can have conditional sections in your .gitconfig
As some of you may know, I keep my dotfiles in a git repo. The problem with this approach is that my email in my .gitconfig is set to [email protected].
Where my config looks something like this:
[user] email = [email protected] name = Haseeb Majid # ... However, when I am at work I need to use a different email to commit i.e. work email [email protected] not my personal email. So I was wondering how could I do that; one way would be to change the file locally and just not commit it. But of course, that is not ideal.
...
What is a TIL post? TIL - Stands for today I learnt. These posts will be shorts summaries of something I learnt “today”.
The TIL posts have a low barrier to entry and are a lot easier to write. Therefore they should encourage me to post more often. In all my blog posts I try to post about things that I struggled to do. If I struggled to implement a feature or build something. It shows that there wasn’t a tutorial or an easy example I could follow. So then I usually decide to write my own, to make it easier for others. It also has a nice side effect of helping me remember the topic better.
...