Articles

How and when to use Async and Defer attributes

Published on:

Both async and defer attributes look like they do the same thing at first glance, but there are nuances to async and defer. Most of the time, you'd want to use defer instead of async, even though async sounds sexier.

But why?

I'd like to walk you through the differences and why you should use them (and also why you don't have to use them).

Trying Your Best is really bad advice (and strategy)

Published on:

For a while I've been telling myself that it's okay as long as I tried my best. It's been a decent strategy for a long time, but it's not working for me anymore.

I want to explain why it doesn't work and what pitfalls you might want to watch out for if you use the same strategy in your life.

Rapid Mac Setup for Frontend Development

Published on:

My Macbook broke down after using it for a year β€” the logic board got fried. I got this Mac repaired and it broke down a month later. The logic board got fried again πŸ€¦β€β™‚οΈ.

Long story short, Apple agreed to repair the Mac again for free. They also agreed to send me a new Macbook as a replacement since my current one gave me so many problems.

In the meantime, I've gotten pretty good at setting up my Mac and I'd like to share how I do this with you.

Using Gulp with Dart Sass

Published on:

I'm playing around with Sass again recently and I noticed newer features (like @use and @forward) are only available on Dart Sass. Upon further inspection, I noticed that LibSass is now deprecated.

This article aims to help you get started with Dart Sass if you're using Gulp.

Disabling languages for Prettier (in VScode)

Published on:

It used to be straightforward to disable languages for Prettier in VSCode. You just added a prettier.disableLanguages setting and you were done.

// In settings.json
[
  "prettier.disableLanguages": [
    "javascript",
    "javascriptreact",
    "json",
    "markdown"
  ],
]

Unfortunately, prettier.disableLanguages is deprecated so we can’t do this anymore. Here’s what we can do instead.

Prettier and Standard in VSCode

Published on:

Prettier is an opinionated tool that helps you format code. I love Prettier, but I don't like its opinions with JavaScript. I prefer using Standard for JavaScript because it doesn't have semicolons (which makes the code cleaner to read).

It used to be complicated to use Prettier and Standard together. We had to disable Prettier for specific languages. Thankfully, there's a simpler way now.

How to remember JavaScript

Published on:

JavaScript contains many things β€” lots of different methods and ways to do things. How do you remember them all?

If you ask around the web, many people will say you don't have to remember everything since you can always google. But this answer doesn't help β€” you can't always Google everything, every time. If you forget absolutely everything and Google everything all the time, you're going to be real slow when you code!

So what's the alternative? What must you remember? What can you forget? That's what this article is for.

Overcoming 7 main problems of learning to code for people who don't have a developer job

Published on:

If you don't have a job as a developer, learning how to code becomes a much bigger challenge for a simple reason β€” developers can learn to code on the job.

I want to share with you 7 major challenges people face when learning, especially if they don't have a developer job. I'm also going to talk about how you can overcome each challenge.

How to debug a Github Actions' secret

Published on:

One irritating thing about Github Actions is you can't debug secrets. If you try to debug secrets you'll get *** in the log.

<Image src="/assets/2021/debug-github-actions-secret/run-echo.png" alt="run echo" />

This makes sense because Github is trying to help us keep the secret secret (ha!). But it doesn't help when we're trying to figure out whether there's something wrong with the secret we provided.

Deploying to a server via SSH and Rsync in a Github Action

Published on:

I wanted to use Github Actions to deploy zellwk.com β€” when I push a commit into Github, I want Github Actions to build my site and deploy to my Digital Ocean server.

The hardest part of this process is deploying to the server with SSH and rsync. I tried various Github actions like SSH Deploy and SSH Action, but I couldn't get the permissions to work for A LONG TIME.

I found most articles about Github actions and SSH didn't help me much. I got stuck with debugging for a few days before I finally figured out how to make the process work.

Today, I want to share the exact steps to deploy via rsync and SSH. This process works for any server, even if you don't use Digital Ocean.

Understanding how to use Github Actions

Published on:

Github Actions is a Continuous Integration (CI) + Continuous Deployment (CD) tool by Github.

CI and CD are bombastic terms, but they simply mean the following:

  • Continuous Integration: People push to a Git repository and the code gets tested automatically.
  • Continuous Delivery: The pushed code (ideally tested and bug-free) is then pushed into the server so it becomes live for users.

Although Github Actions is one of the many CI + CD Tools out there, it's probably the simplest one to use (in my experience). Unfortunately, the Github Actions docs is a complete mess β€” they keep pointing you to different pages, expecting you to read everything (and understand everything) when you're still trying to set up your first action.

Today I want to share the basics of using Github Actions so it becomes easy for you to use it.

How to use Reduce in JavaScript

Published on:

reduce is an array method that helps you convert an array into a single value. It looks like this:

const callback = (accumulator, currentValue, index) =&gt; {
  // return something here
}
const result = array.reduce(callback, initialValue)
  • initialValue is the value you want to start with.
  • accumulator is the value returned from the previous iteration. It will be initialValue for the first iteration.
  • currentValue is array item in the current iteration.

Let's go through some examples.

Choosing between Netlify, Vercel and Digital Ocean

Published on:

A while back, I jumped onto the hype train and tried to host Learn JavaScript's marketing page on Netlify β€” I wanted to join the cool kids. After getting charged for it, I switched to Vercel and I got charged for it (again). I finally went back to good old Digital Ocean.

In this article I want to detail the differences between hosting on Netlify, Vercel, and Digital Ocean, along with what I experienced in the process.

How to write super simple and useful regular expressions for the real world

Published on:

Regular expressions are HARD! They look so complicated, they're turn me off completely most of the time. Sometimes I wished I was smarter so I can use them more effectively.

While working on Learn JavaScript, I noticed that using regular expressions effectively doesn't mean you need to write complicated regex. You can write super simple regex that solves a ton of problems.

I'm going to show you a real example.

Year End Review β€” 2020

Published on:

Hello! I want to begin the year with a year-end review again. I like doing these because it gives me a solid sense of where I am today versus where I was last year.

Case Conversion in JavaScript

Published on:

I got fed-up searching Google for case conversion utilities. The useful ones I found (Voca and change-case) both require an environment that allows me to use npm.

But I was using Vanilla JavaScript. I did not want to include any toolchains in this project, and I'm reluctant to send an asynchronous request to download a module just for case-conversion.

So I decided to write a set of conversion utilities myself.

It's simpler than I thought.

Why we should use Ergonomic keyboards

Published on:

Normal keyboards create tension in the wrists, which eventually lead to backaches. In this article, I explain how that connection happens and why we should use ergonomic keyboards.

What's the difference between an Interface and an API?

Published on:

I used to think JavaScript doesn't have Interfaces because it doesn't have the Interface keyword, unlike Java.

<Image src="/assets/2020/interface-vs-api/java-interface.png" caption="Interface keyword in Java" />

But JavaScript DOES have interfaces. I found out about this when I tried Googling for the location API, which turned out to the location Interface πŸ€¦β€β™‚οΈ.

<Image src="/assets/2020/interface-vs-api/location.png" alt="Location interface." />

I was confused. What the hell is the difference between an interface and an API? I sat down and figured it out (as usual). I want to share my newfound understanding with you in this article.

Let's begin with interfaces.