Summary of reading: January - March 2024
Lesley Lai's Blog
by
3w ago
I've realized that it's been quite some time since I've shared a "summary of reading" post, and I'm keen on reviving that practice. One reason I discontinued it was due to my embarrassment over not reading enough books. However, I believe that publicly sharing what I read will encourage me to read more. One significant change of the reading process I made this quarter is incorporating spaced repetition tool Readwise (note: requires a subscription) and Anki (free) aggressively (in addition to those traditional notes I made with Obsidian). I find this practice to be extremely beneficial despite ..read more
Visit website
Online Courses that I Recommend
Lesley Lai's Blog
by
1M ago
My journey of learning from online courses started from 2013, and over the years I took a lot of them, abandoning even more along the way. Nevertheless, I've found online courses to be far more accommodating for self-study compared to traditional books. In this post, I've compiled a list of courses that I found memorable, enjoyable, and, in retrospection, actually convey high-quality information. While the selection is undoubtedly biased towards my personal interests, I hope you find them useful as well. Do note that some courses that I recommend below are not MOOCs, but instead university cou ..read more
Visit website
Small Naming Tip: Use "from" Instead of "to" in Function and Variable Names
Lesley Lai's Blog
by
2M ago
Today, I'm tackling a piece of code involving several mappings. Like many others, I typically label such maps as x_to_y, and that's also what I've done here: let mut value_to_var: HashMap<Value, (String, usize)> = HashMap::new(); let mut var_to_num: HashMap<String, usize> = HashMap::new(); // This is not a hash table but I use the index as the key let mut num_to_canonical_var = vec![]; When I need to use those maps, my code often looks like this: let canonical_variable = num_to_canonical_var[var_to_num.get(var).unwrap()]; As you can observe, the sequence isn't particularly in ..read more
Visit website
What happened to Lesley in the last couple of years
Lesley Lai's Blog
by
4M ago
TL;DR: I was forced to leave university without completing my degree due to unfortunate circumstances, and returning has proven unexpectedly challenging. Update 2023/12/18: If you are reading this now, please refrain from DMing me and providing suggestions. While I appreciate your willingness to help, I find myself a bit overwhelmed at the moment. If you're looking for tech-related content, this article is not what you're seeking. There's no tech information here, so feel free to stop reading. I just share my pain here because it's too painful to bear the weight alone. 2021 Summer Fiasco Until ..read more
Visit website
Use ManuallyDrop in Rust to control drop order of structure fields
Lesley Lai's Blog
by
1y ago
First, for some context: I wrote this blog post more than a year ago but have yet to make it public since my mental health greatly degraded while I was still editing it. Now that I want to go back into blogging, I decide to release this post in its current form, though I lost interest in editing it. As programmers, "clean-up" always feels like the boring part of our code. Fortunately, in Rust, we destructors that help us to automatically write correct, ergonomic clean-up code. However, in the rare case where the order of destruction matters, compiler-generated destructor calls can be a hindran ..read more
Visit website
CMAKE_SOURCE_DIR is probably not what you want
Lesley Lai's Blog
by
2y ago
Today is the nth time I got bitten by CMAKE_SOURCE_DIR, so I will write it here. In short, there are two predefined variables in CMake: CMAKE_SOURCE_DIR and PROJECT_SOURCE_DIR. CMAKE_SOURCE_DIR refers to the top-level source directory that contains a CMakeLists.txt, while PROJECT_SOURCE_DIR refers to the source directory of the most recent project() command. They are often the same, but a common workflow when using CMake is to use add_subdirectory to add libraries. And in that case, any PROJECT_SOURCE_DIR in that inner library will refer to the outer project's root rather than the library's ow ..read more
Visit website
VK_KHR_dynamic_rendering tutorial
Lesley Lai's Blog
by
2y ago
Announced two months ago, the dynamic rendering Vulkan extension promises to get rid of the VkRenderPass and VkFramebuffer objects, which were parts of Vulkan that I "don't understand and don't really care about." To write a Vulkan renderer before the advent of dynamic rendering, we always needed to write a lot of boilerplate renderpass code. It is not an ergonomic API nor is it often that we need the flexibility of multiple subpasses or input attachments. By contrast, the DirectX 12 API has render passes as an optional thing that is only used to "improve performance if the renderer is Tile-B ..read more
Visit website
How I create bilingual functionality of this blog in plain Typescript
Lesley Lai's Blog
by
2y ago
Happy new year 2022, everyone! Today I want to talk about something different from most of my blog posts: how I implement my bilingual blog in pure Typescript. Since I created this blog in 2015, I always wanted to make it bilingual, and I finally implemented it at the end of 2019. My implementation of internationalization was probably different from most people, as I use plain Typescript without any third-party libraries such as i18next. I heavily rely on Typescript's remarkable features in its type system for my implementation. It is probably not the most "proper" and scalable solution, but I ..read more
Visit website
Little C++ Standard Library Utility: std::align
Lesley Lai's Blog
by
2y ago
Recently, I learned about std::align, which is one of the lesser-known functions in the C++ standard library because of its limited use cases. Since it is hard to describe without a specific use case, I will use a simple implementation of an arena allocator as a motivational example. Arena allocator Arena, also called bump allocator or region-based allocator, is probably the simplest allocation strategy. It is so widely used that even the C++ standard library has an arena implementation called std::pmr::monotonic_buffer_resource. With arena, we first have a large chunk of pre-allocated memory ..read more
Visit website
Fun with Ternary Search
Lesley Lai's Blog
by
2y ago
This year is my first year doing the Advent of Code challenge, and today (2021 Day 7)'s challenge is a fun one. I won't go to the details, but the problem involves finding the minimum for a function. The function takes an integer and returns another integer. An interesting property of that function is that it has one "valley": Everything at the left of the global minimal point monotonically decreases. Everything at the right of the global minimal point monotonically increases. You can think the function output as a bunch of integers like 100, 81, 56, 32, 16, 33, 44, 78, 129 And we want to ..read more
Visit website

Follow Lesley Lai's Blog on FeedSpot

Continue with Google
Continue with Apple
OR