Author: mattchung

  • A healthy (no oil), quick (15 minutes prep, 15 minutes cook), plant based instant pot dish

    If you are looking for a quick, delicious, healthy (no oil), plant based meal that takes only 30 minutes (15 of those minutes are waiting for the dish to cook in an instant pot) to whip up, look no further. Check out Jill McKeever’s video on “The Red Lentil Stew From Instant Pot”:

    I’ve taken her recipe and slightly modified it, changing the proportions of the ingredients. More specifically, I kick up the number of potatoes. In the video, you’ll see she tosses only in 1 potatoes or so; I like my dish a little more starchy and tend to chop up and throw in in twice the amount (about 4 or 5 potatoes). And occasionally, I’ll mix it up with a zucchini (or as my British wife calls it: “Courgettes”).

    So the modified recipe is as follows:

    • 4 carrots
    • 4 potatoes
    • 1 teaspoon of paprika
    • 1 tablespoon of coriander
    • 1 medium-sized yellow onion
    • 2 garlic
    • 6 cups of vegetable stock
    • 1 cup of lentils (I don’t wash them but she does)
    • 3 ounces of tomato paste

    Definitely try this out. It’s so easy and so delicious! Bon Appetit!

  • A No-Excuses Guide to Blogging – Excuse #5 – “I don’t want to be wrong”

    Many people (including myself) fear that we will be perceived as a fool if we publish on a post blog that contains a mistake, a public mistake. Nobody wants to be humiliated publicly. This fear is encapsulated inside of a quote that Sacha shares:

    “Better to remain silent and be thought a fool than to speak and remove all doubt.”

    But like Sacha, I’d rather know when I’m being a fool. At work, I never shy away from asking “dumb questions”. I’ve come to realize that there’s normally at least one other person who has the same question but they often shy away from asking it for fear of looking stupid. I’ve been that person and I later kick myself in my butt for not speaking up.

    If you don’t put your thoughts into words — verbally or written — then its very easy to convince yourself that you understand something, when you really don’t. So many times in both my career and personal life I thought I understood some topic but when I started forming those thoughts into my own words, I realized I had gaping holes in my understanding. For example, my co-worker asked how and why we prefetch in our code base, and when I started explaining, I realized I had to refresh my memory on the cost of certain instructions and CPU pipelining.

    In summary, do yourself a favor and when you are learning something, try and explain it someone. You might discover gaps in your understand. And that’s perfectly okay because your writing becomes a “history of change and learning”. This allows us to take a step back and honor our progress and allow us to remember our mistakes and lessons learned along the way.

    References

    Chua, Sacha. 2014. A No-Excuses Guide to Blogging.

  • What vacation looks like with a 10 month year old

    Summary

    I never could’ve imagine what being a parent (to a 10 month year old) looks like while on a vacation at the Suncadia Hotel (in the midst of a pandemic). When our daughter sleeps sprawled out on the cloud like king size bed, us two parents are quietly scarfing down our cold dinner while watching an episode of “Westworld” off an iPhone that’s balanced behind the bathroom sink.

    Our lives revolve around Elliott’s sleeping schedule

    Before becoming parents, my wife and I lived a life with almost no constraints. If we wanted to spontaneously watch a movie at the theaters, we’d pop open our laptops, check the next show time, and then walk downhill for literally 5 minutes to the local theater. It was that simple.

    But those days are gone.

    Life is a little more complicated nowadays. Our schedules tend to revolve around Elliott’s sleeping schedule. This strict adherence applies even when we are away for a vacation.

    But why do we follow a sleeping schedule to begin with?

    It’s quite simple, actually. The bi-conditional logical connectivity is as follows: If and only if Elliott sleeps well can we (her parents) sleep well. And a night with lack of quality sleep makes everyone miserable. Therefore, it is in our best interest to ensure that Elliott clocks enough sleep.

    Sleeping environment at a hotel

    To that end, we need to transform our hotel room to an environment that’s conducive for sleeping. That means rendering the room pitch black by covering all the windows with the curtains, allowing no single ray of sun to shine through. This combined with a white noise machine — blasted at max volume that penetrates even the deaf — soothes the baby to sleep.

    On top of blackening out the room and pumping the sound machine, we need to remove as many distractions as possible. And at Elliott’s age (and probably moving forward), pretty much everything in sight is a distraction: including me. So while Jess puts Elliott down, I tip toe out of the hotel room, flicking off the lights on my way out, and then make my way down to the hotel communal area (still wearing a mask), my laptop in hand. And for this short period of time, about 30-45 minutes, I double down and focus and chip away at writing on my blog (like this post). And then I sneak back into the room once Elliott hits her deep sleep.

    Dinner in the bathroom

    What does dinner look like while at a hotel resort? Well, that depends. If Elliott is awake, then we take the opportunity and eat an early dinner (around 5:00 pm), the three of us squatting over a wooden dining table that’s a shoulder height of Elliott. But if Elliott is asleep, then dinner takes a different turn.

    In this scenario, you’ll find (as mentioned above) the room blacked out and two parents (Jess and myself) huddling in the hotel bathroom, the door shut closed so that we can whisper to one another without fear of waking Elliott up. While in the bathroom, we both pop in our air pods, sync them to an iPhone (since the wifi signal sucks in our room), and proceed to watch an episode of “Westworld” while slurping down our noodles:

    Jess and I quietly eating our dinner while Elliott is sleeping in the bedroom
  • Swapping values of two variables with XOR

    As programmers, we know that we can swap two variables by using a temporary variable. That’s fairly simple and intuitive: given two variables (x and y) that you want to swap, you store x in a temporary variable z, copy y to x, then finally copy z (the temporary) to y. But I learned recently (in my compiler’s course) that you can swap two variables without allocating a temporary variable, by using three xor operations. Here’s a little C program that demonstrates that idea:

    # include<stdio.h>
    void
    swap(int *x, int *y)
    {
         *x ^= *y;
         *y ^= *x;
         *x ^= *y;
    }
    
    int
    main(int argc, char *argv[])
    {
        int x = 123;
        int y = 234;
        printf("x=%d;y=%d\n", x, y);
        swap(&x, &y);
        printf("x=%d;y=%d\n", x, y);
    }
    ./xor-swap
    x=123;y=234
    x=234;y=123

    Neat, right?! But why would you ever want to take this approach? Especially if the underlying CPU instructions are more expensive with the xor approach. That is, the typical process for swapping two variables consists of 3 MOV instructions and the total number of cycles is 3 — one cycle per MOV instruction. Whereas 3 XOR instructions takes 9 cycles (3 cycles per instruction).

    Well, one explanation is that compiler writer is making a tradeoff: we’re sacrificing CPU cycles but in return we free up a register, which is especially important for the register allocator. In other words, we’re reducing register allocation pressure.

    Anyways, the last thing I want to demonstrate for you (and really, for myself) is to see 3 XOR operations at the binary level

    XOR at the binary level

    Although the code (above) proves that we can swap two variables using three XOR operations without a temporary variable, I wanted to actually carry out the XOR operations at the binary level to see for myself (cause seeing is believing, right?)

    For the example below, assume that we have two registers ebx (1101)and eax (0001).

    First operation – xor %ebx, %eax

    1101
    0001
    ====
    1100

    The xor operation yields 1100 and is then store into ebx.

    Second operation – xor %eax, ebx

    0001
    1100
    ====
    1101

    This operation yields 1101 which is then stored eax.

    Third operation – xor %ebx, %eax

    1100
    1101
    ====
    0001

    And hooray — the final xor yields: 0001.

    References

    http://www.asciitable.com
    https://c9x.me/x86/html/file_module_x86_id_330.html

  • Waiting for one day …

    “If you want to be successful, find out what the price is and then pay it.”

    Scott Adams

    I agree with that Scott Adams wholeheartedly. I also think this rule can be more broadly applied: “If you want something — anything — find out what the price is and then pay it.”

    This quote reminds me of a story that my therapist recently shared with me. During this Covid-19 shelter in place, he’s participating in an online workshop lead by a poet named David Whyte. During the most recent workshop, one of of the other students in the program shared their life long dream: becoming an anthropologist. It’s something they always dreamed of but before they make that giant leap, they are first going to build a financial foundation and work in tech for another 8 years.

    David Whyte’s response? “You’re probably not going to become an anthropologist.” Ouch — brutal honesty. But David Whyte softens the below and elaborates, stating that when we do something on a daily basis, we assume that identity and that activity — in this case being a tech worker — becomes part of our fabric. He’s right.

    This short story struck a chord with me. And over the last couple days, I’ve been reflecting on my own one day dreams and aspirations, askingmyself what are some things in my life that I’ve been wanting to do but have been waiting for something — something in the distant future, only after I do x and do y.

    And the first thing that surfaced was writing. Writing on my blog. I used to write much more frequently but every since I started my masters program in computer science, I’ve pretty much abandoned writing all together convincing myself that I have zero time to commit to writing. That’s nonsense.

    So instead of waiting to graduate from the program — which is another 1.5 years — I’m going to chip away at my writing. Every day. Even if it’s for 5 minutes. Even if it’s just collecting field stones or existing content. Whatever it is, I’m making tiny incremental progress: and I’m happy with that. Little wins.

    Now I want to turn the table and ask you if there is anything you want to do one day? Is there something you are waiting for? Or waiting for someone to give you their approval? Or for the stars to align?

  • Week 1 and Week 2 of compilers

    Last week, I couldn’t carve out enough time to write a post on my reflections for week 1 of my compiler’s course so I’ll do the next best thing: write a post that combines week 1 and week 2. The quarter kicked off on January 10th and since then, I’ve felt a range of emotions, from excitement to anxiety. Meanwhile, I’ve been scarfing down a ton of knowledge about compilers (previously, I viewed the compiler as an elusive, magical and mysterious black box). On top of all this, I’ve been experimenting with Cornell Note taking system, switching back and forth between typing up notes on my laptop, writing notes down on my iPad, and using the good old pen and paper.

    Study Habits

    I’m constantly refining the way I study, optimizing my sessions for increased understanding and maximizing long term retention. Last quarter, I had taken notes using LaTex, generating aesthetically beautiful documents. The idea behind this was that that I would one day look back at them in awe. But in reality, I haven’t looked back at any previously taken notes, not for any of the four prior classes, so there’s really no point (as of right now) to continue precious cycles on typing out LaTex notes when (I think) I’m more actively engaged when scribbling notes down with pen and paper.

    Emotions and feelings

    A couple things make have been making me feel anxious. First, the sheer number of hours required for the course. According to the omscentral reviews, students estimate roughly 20-25 hours per week. To compare against these estimations, I’ve been tracking the hours I put into this course. So far, on average, I’m studying — watching lectures, reading the textbook, creating flash cards — in roughly 2.5 hours a day; same applies for the weekends. That means, in given week, I’m putting in roughly 17.5 hours, give or take. Will the number of hours increase once the first project is announced (two days from now) ? Perhaps. One way would be to reduce the number of commitments (e.g. singing, writing music, writing blog posts like this one) or sacrifice some sleep — not ideal at all. Instead, I think I’ll just accept that, given the finite number of hours in a week, I may be only able to pull off a B, which I’m totally fine with.

    What have I learned so far

    As mentioned before, I have zero prior background with compilers. But in just the past two weeks, I’ve discovered that a compiler is not just a black box. It actually consists of three major components: front end, optimizer, back end.

    The front end’s job is to scan and parse text and convert that text into a format (intermediate representation) that’s consumable by the backend (more on this below). And if we drill down a bit further, we’ll see that the front end actually consists of subcomponents: scanner, parser, and semantic analyzer. The scanner reads one character a time and then groups them into tokens. These tokens (tuple of type and value) are passed back to the parser (who initially requested them), which then calls the semantic analyzer to ensure that the generated tokens adhere to the semantic rules, ensuring that they are meaningful and make sense.

    How does the compiler know whether something is both syntactically and semantically correct? Based off of the rules of the language: the grammar. These are the set of rules that specify the language and can be formalized using finite automata and represented as state machines. What I found most interesting is that we can express the grammar using a human readable format called regular expressions.

    Regular Expressions

    If you are a programmer, you certainly used regular expressions (in your favorite language like Python) for searching text. But regular expressions are much more powerful than just creating search patterns. They are fundamental to compiler design.

    By using regular expressions, we can create a formal language, which consists of the following:
    • Alphabet – finite set of allowed characters
    • Transition Function
    • State – finite set of states
    • Accepted State – finite set of accepted states
    • Starting State – initial state of the state machines

    State Machines

    As mentioned above, regular expressions can be converted into state machines (similarly, state machines can be converted back into regular expressions) that fall into one of two categories: deterministic and non-deterministic. Next week will cover this topic in more detail.

    Summary

    So that about wraps it up. I’m looking forward to next week (I.e. Week 3) !

  • Top 6 photos from first family photo shoot

    Below are my top 6 photos I cherry picked from our first family photo shoot that took place a couple weeks ago.

    As some of you my already know, my daughter Elliott was born recently, on October 3rd (2019). And shortly after, my wife had arranged for a professional photographer — Stephanie BC — to spend half the day in our Pacific Northwest home, scheduling the photographer on a typical, no sunshine Sunday to snap some photos and capture some moments of our growing wolf pack: once four now five (3 humans and 2 dogs).

    And I must say, the images turned out nothing short of beautiful; I could not be any happier with not just the end product but the process itself. Apart from one or two photos, all the captured images are not staged, meaning we were not posing or putting on a forced smile or contorting our arms and body in some uncomfortable (but aesthetically pleasing) position. The entire shoot felt organic.

    Anyways, enough of the chatter. Here are my 6 photos I hand picked from the our shoot.

    Music. Such a gift. Here I am playing guitar and singing for Elliott and my wife. The song is titled “My Little Bird”, which I wrote when Elliott was just a week or two old.
    This is how I spend 90% of my time with Elliott: cradling her in my arms and rocking her to sleep.
    Here’s my and my first fur daughter: Metric. In her head, she weights 10 pounds still and loves to lean all her weight on those willing.
    Look at this cutie staring out the window while I hold her in the foot ball position. I cannot imagine that I’ll be able to hold her like this much longer since her weight is increasing exponentially, my forearms no longer able to sustain the burn.
    Yes. She’s peeing all over me. Luckily, this time, the pee only hits my shirt and my jeans. I have been tagged in the eye and mouth (who knew girls and projectile pee like boys).
    Me giving Elliott what I call “Kissy kisses” (no idea how I came up with that name) while she rests on top of my wife’s folded legs.
  • Almost half way through M.S. in Computer Science

    I’m almost half way through the OMSCS (online masters in computer science), last week marking the end Spring 2020, my third term in the program. And although I’m looking forward to taking compilers next semester, my mind often wanders into the distant future , my mind fast forwarding to the time in which I’ll be graduating from the program. So, I stitched together a line graph that includes the classes, breaking down each term along with the courses that I’ve already taken (and will take). Here’s what it looks like:

    As you can see from the above graph, I’ve historically taken one class per semester (except for the previous semester, when I simultaneously took information security and computer networks simultaneously); taking one class per semester takes the middle path, allowing me to balance school and work and family and other obligations and the millions of my other hobbies (e.g. singing, guitar). So at this current rate, I anticipate that I’ll graduate in Spring 2021 — 2 years from now. Seems like a long time away but it really isn’t. Because as they say: time flies. And It really does. Feels like yesterday when my wife and I were discussing whether it even made sense for me to apply and enroll to this masters program.

  • Masters in CS paying off

    Taking computer science courses are already paying off in my career. Nothing too significant (yet) but I am witnessing small wins.

    For example, this past summer I suffered through HPCA (high performance computing architecture), a course historically only offered in the longer semesters (e.g. fall, spring). In the course, I learned a lot of theory: barrier synchronization, processing pipelines, instruction scheduling, multi level caches, branch predicators, cache coherence protocols, and much more (many of which I have already purged from my memory). However, since most of that knowledge was primarily theory, very little of it I’ve been able to directly apply to my day to day job.

    Until a couple days ago.

    While at work, my co-worker had pointed out that the unlikely C function calls were sprinkled throughout our code base, used for branch prediction. And thanks to theory, I was able to describe to another co worker how the compiler (with its understanding of the underlying CPU architecture) will rearrange the assembly (or machine code) in order to avoid a branch prediction miss: if the wrong instruction is fetched, the processing pipeline must flush all the previous instructions queued in the pipeline, temporarily halting the pipeline, which ultimately reduces the throughput.

    And this is just one example of how taking my masters had paid off. There have been a number of other situations (like understanding shared memory and interprocess communication) that I’ve been able to apply theory from academia to practice at work.

    Thanks to the program, I’m feeling much more competent and confident working as a software developer at Amazon Web Services.

  • Next up: Compilers (theory and practice) and reflecting on fatherhood

    For next semester, Spring 2020, I enrolled in what I expect to be one of the most difficult (yet rewarding) courses: compilers – theory and practice. I’m stoked and at the same time, feeling very nervous.

    I’m stoked for several reasons. First, according to the previous semester’s syllabus, I’ll be learning a ton of theory: Automata, finite state machines, grammars, predictive parsers. Many of these concepts I’ve learned on my own with my self directed education.

    The second reason that I’m elated is that I’ll be given the opportunity of building an entire compiler, from the ground up! No existing code base, all from scratch. That in itself strikes fear in me.

    And third, Steve Yegge’s executive summary (on his post on compilers) — “If you don’t know how compilers work, then you don’t know how computers work” — motivates me, making me want to prove (to myself) that I know how computers work.

    So with all that good stuff, why am I feeling nervous?

    Normally, taking a master’s course while working is manageable. I often carve out about an hour (or sometimes 90 minutes) of my early morning, studying while eating an avocado toast and sipping a ginger tea, headphones wrapped around my head while people are buzzing in the background at a near by café. In addition to the early mornings, I will leverage my one hour lunches, again watching lectures or banging out code for a (school) project.

    But my life has changed.

    Although my previous routines and rituals worked well for me for the last several years, my life has changed in significant ways. Most obvious is the arrival of my (first) child, Elliott. With Elliott now here (and no longer just an abstract creature curled up in my wife’s belly), I want to make sure that I’m present for her: not just for the big moments (like her first vaccinations) but for the little, day to day moments (in fact, I had one of the weirdest feelings when I stepped into the office this past Monday, my first day back in the office after 4 weeks off of paternity. while staring into the wide screen monitor pinned up against the wall of my not too shabby cubicle, I wanted to be at home, changing Elliott’s dirty diaper).

    Elliott with her thinking hat on

    On top of all of this, omscentral reviews (the unofficial review website for courses offered by online master’s program at Georgia Tech) suggest that the course demands anywhere between 15-25 hours per week. Those extra 10 hours gotta come from somewhere. But from where? Sacrifice it from hanging out with my life? Or strumming my guitar? Or singing? Or writing music? Or exercising at the gym? Or playing with my dogs? Or spending time with other friends and family?

    You see, there’s only so much time (you already knew that) and all the decisions (small and large) are trade offs. These choice reflect our ethos. The sum of where and how we spend our time essentially defines who we are and what we believe in.

    Okay. Rant over.

    Back to studying (information security and computer networks) on my day off of work — thank you Amazon for offering a ramp back period, allowing me to work 50% (of course my salary is pro rated) and allowing me to pitch in with my family on Thursdays and Fridays.