871 private links
Josh Comeau writes one of the best interactive css tutorial out there! I learned so much in this article. A few notes:
margin: auto
makes the child take as much margin as possible.width: fit-content
uses all available space, but within the intrinsic sizemargin-inline: auto
is a shorthand formargin-left: auto; margin-right auto;
place-content: center
is a shorthand foralign-content: center; justify-content: center
- difference between
place-content
andplace-items
in grid layout - the latter aligns items relative to the cell - the insight that css attributes are merely inputs to the underlying layout algorithm
An article on how Rust can benefit from an effect system.
The information advantage over your competitor is something you can choose to cultivate. In journalism, one can avoid large topic on key persons that everyone went about, instead focus people with just as much insight and far less attention.
This article explores how we can separate the lifetime of values in a container from the lifetime of the container structure. The author approach the problem by issuing a token (zero-sized type) with an invariant lifetime. TIL ghost token. I think the type AppendOnlyVec (Vec<Box<T>>) could make a more straightforward example.
Nice write up. Aside from these mentioned, I also wanted to point out a few problems about Protocols.
- the implementation on struct is fine, but implementations on primitive types are very different and sometimes awkward
- the first argument is forced to be the type that implements the protocol, making it difficult to define abstract methods on, for example, a set of values
- there is no concept of associated type, associated constant,
- the role of protocols mostly overlaps with a
@behaviour
but a behaviour is more flexible
And here are more places I'd like to see improvements (some pointed out in the article, too):
- the lack of simpler struct construction/deconstruction syntax sugar, forcing everyone to write code like
%{a_long_property: a_long_property}
repeatedly - the lack of early return. the design of
with
discards the information about the mismatching branch. Ecto.Multi
is not composable (I tried to fix it via https://github.com/shouya/ecto-tx)
A concise and complete cheatsheet for the format!
macro.
This article talks about the default value for DefaultRestartSec is not sensible for use cases where you expect the service to restart indefinitely. Under the default setting, if your service could crash in 100ms, then it will only be restarted for around 1 second before systemd gives up.
It's a pleasurable and informative read. The nature of algebraic effect was accurately and concisely pointed out. This has been one of the best write-up on algebraic effects implementation in Rust I've read so far.
Quick explainer for ZFS caching mechanisms: ARC, L2ARC, TXG, ZIL, and SLOG.
A detailed description on the hardware architecture of Game Boy console.
TIL A* with fixed iteration depth.
All look like interesting concepts to toy with!
- Text editor
- 2D game - Space Invaders
- Compiler - Tiny BASIC
- Mini operating system
- Spreadsheet (hard!)
- Video game console emulator (hard!)
- Ray tracer
- Key-value store web API
- Web browser
- Stock trading bot
Also see Challenging algorithms and data structures every programmer should try.
This article talked about three data structures for efficient text editing (a.k.a. text buffer data structure): Rope, Gap Buffer, and Piece Table. It's first time I learned about Piece Table, it works like this:
- Store the text in an append-only fashion in two buffers known as original file and add file
- Store the information about segments of the files as a list of reference to the slices into the two buffers (known as "piece table")
The inserting/deleting in this data structure would simply need to breaking up items in the piece table. It seems like a good candidate as a basis to implement CRDT in a collaborative editor.
From my preliminary understanding of the nature of this data structure, it doesn't seem necessary to have two buffers, a single append-only buffer preloaded with the file should be sufficient.
UPDATE: I found this post on vscode blog extremely helpful: https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation
A gallery of interactive explanations. And the tool used to make these.
Chatbot Arena: blind test on the performance of LLM models to assign them a ELO rating. It also serves as a playground for various models.
This is a useful lifehack I learned today.
TL;DR: pull the note downwards instead of peeling it upwards. This stops the note from curling and stick better.
Bluetooth protocol snooping, Android app decompilation, AES decryption.
A security search engine like https://shodan.io. Search open services on an IP, whois, protocol signature, etc.
A post on postgres replication feature.
The good'ol Google ngram explorer for tracking term uses across recent centuries.