Hung-Yi’s Journal

Front-end Developer, Emacs Adventurer, Home Cook

28 Sep 2020

JavaScript's Reduce: A Swiss Army Knife for Arrays

There's a little Array method in JavaScript that I've seen a lot of developers overlook. I suspect it's because of its abstract nature that doesn't exactly lead developers to any obvious use cases. But that's why I think it's a great programming Swiss Army knife: you can do a lot more with it than you might realise1. Let me introduce you to my friend, Array.prototype.reduce(). Today, I'll show you some creative ways to use it that may just inspire you.

22 Sep 2020

Why I Use ReactiveX and RxJS in Angular

It's been more than 5 years since I started writing my UI code in a reactive fashion with ReactiveX. I've used RxJava for Android development, ReactiveUI for Xamarin development, and now I'm using RxJS for Angular development. I stuck with it not because it was easy—it definitely wasn't—but because something about it just felt so right. For the longest time I couldn't explain it, and I'm not even sure I can explain it succinctly now. But today I want to use an example to at least try to illustrate just a touch of the mystery and allure that drew me into Reactive1 Programming in the first place. Let's dive in.

13 Sep 2020

Learning Emacs More Effectively

It can be confusing as a new Emacs user. The tutorials that you read online often throw a bunch of obscure command names or long chains of key sequences at you without explaining the why and the how behind the what.

Today I'll outline what I think are the fundamentals for exploring Emacs features. These techniques can be used if you're just messing around in Emacs on your own, but they can even help you understand other Emacs tutorials better. You might consider this a tutorial for how to follow other Emacs tutorials.

11 Sep 2020

An evil-mc Emacs Hydra

One thing sorely lacking in native Emacs is the ability to edit with multiple cursors like VS Code. Fortunately for Doom Emacs or Evil users, there's evil-mc. But even with that installed, all it gives you is a bunch of commands—you still have to decide how to bind them yourself or rely on Doom's suggested bindings that map everything to the g z prefix for every command.

But I think we can do better. Today, I'm sharing an Emacs hydra that I've been using to power up my evil-mc usage. Just put this anywhere in your config.el:

09 Sep 2020

Emacs Lets You Calculate While You Write

Let's say you're writing a recipe but you want to scale the ingredients down by one third. The recipe calls for 280g of flour. And you want to round to the nearest 10g.

I applaud you if you can easily do that in your head—because I certainly can't. Also yes, it would be easy just to run your system's calculator app to get the answer, but why leave Emacs if you can help it? Doing it this way also saves you a bunch of manual copying and pasting.