Sometimes Python makes some useful things unnecessarily complex for weird and inconsistent reason … e.g. “code blocks.”
Tag: Programming
Naïvité FTW
Daniele Procida explores how a certain naivety (being unsophisticated) can lead to beautiful and useful things.
Update 2021-08-15: the original video from DjangoCon 2018 is not available any more. It seems Daniele gave a similar talk at EuroPython 2018 also.
https://www.youtube.com/watch?v=JNGNuiXLAcY
Threads on async
If you were to design a threading library today how would it look like? David Beazley manages to demonstrate a lot of edge cases in tiny examples … while live-coding! ?
https://www.youtube.com/watch?v=xOyJiN3yGfU
HN: the good parts
Dan Luu has a nice collection of interesting Hacker News posts.
Strings at Facebook
It’s great to see how the simplest things we take for granted are engineered and improved. Case in point: Facebook’s std::string replacement.
https://www.youtube.com/watch?v=kPR8h4-qZdk
Exciting Unlimited Register Machines
A brief and entertaining talk by an obviously excited presenter. 🙂 It goes into the same directions as Jim Weirich’s talk about the Y combinator.
https://www.youtube.com/watch?v=7Q-UwjgZ0q4
AR create_with
find_or_create_by
method but I didn’t know it had a very useful companion
create_with
.
@something ||= SomeModel.create_with(some: "stuff").find_or_create_by(foo: "bar")
This will either find a record
SomeModel.where(foo: "bar")
or create it with
SomeModel.create(foo: "bar", some: "stuff")
. Very useful.
AR Find Trickery
found = ModelA.find_by(id: id) || ModelB.find(id)
I stumbled over this during a code review. It was supposed to look for a record in two distinct tables.
find_by
will return
nil
if nothing was found while
find
will
raise
. Hence either you get something (from any model) or you
raise
.
Classic Programmer Paintings
This is a great idea. ?
TSA’s Random Lane Picker
This is so moronic I almost fell off my chair laughing: it seems like the TSA spent $47,000 on a “random lane picker.” Please, you be the judge whether it was worth it:
https://www.youtube.com/watch?v=P_KmFJ2gGzw
It needs to be operated manually … with hygienic gloves! ?