2021 Week 285 min read

giscus 💎

I added custom CSS support on Monday. I was a bit hesitant at first because of the security implications. However, I think as long as the user trusts the author and provider of the CSS file, it should be okay.

If you're reading this and you think that it was a bad idea, please chime in and let me know about it. I'm no expert and I'd really like to know the pitfalls of the approach.

I also started implementing a small client API that lets you interact with the <iframe>. The API currently has two major features:

  • Emit discussion metadata. If enabled, you can listen to message events and be notified of any updates to the discussion metadata (e.g. discussion URL, number of comments, reactions, etc.). This lets you use the metadata from the parent window.
  • Config updates on-the-fly. The parent window can now send message events to the <iframe> to update configurations without having to reload the <script> or the <iframe>. You can try it out right now, try switching the theme on this website from this page. You'll see that the giscus theme will be updated without having to reload the discussion.

I managed to implement and document the client API in less than a day. I'm quite impressed!

On the other hand, though, I spent the whole previous day just trying to prevent flashing of unloaded CSS variables when changing the theme.

I've started writing a changelog. Still not automated at all, though.

I also made a React component for giscus, which became my first published package on NPM. I'm planning to add support for Vue and Svelte as well.

Speaking of the project... I just realized one of the big users of utterances, the "Writing an OS in Rust" blog, recently switched from utterances to giscus. How did I notice this? Well...

I got an email from Vercel saying that I've exceeded the "fair use" of a free account.

Exceeding fair usage limit

I checked my Vercel dashboard. It turns out...

1 million requests per month

giscus is now serving almost 2 million requests per month! I never thought it'd reach that number this quickly. Yay! But, I had to do something about the fair usage limit...

Spending $20/month for something I work on for free isn't on my budget yet.

After analyzing the situation, I found out that serverless functions on Vercel are given 1GB of memory by default, and you are billed for that 1GB regardless of the actual memory usage.

Meanwhile, my functions only use less than 128MB of memory.

108MB of memory

I decided to try limiting the functions to 256MB of memory, and...

It works!

it seems to work! You can see that the usage has dropped since July 9th.

I guess this should "buy" me some time before giscus gets even bigger.

GitHub Copilot

I got access to GitHub Copilot this week. I know that there are some questionable decisions built into the product, so I kept that in mind as I tried it.

It's not perfect, but I'm honestly blown away when it spits out something that makes a lot of sense.

For example, I was trying to write a script to remove some unused CSS variables in giscus. Here's what I got:

Copilot suggests the exact function I'm trying to write

And when I tried to write the main function...

It knows

Later on, when I was writing some docs...


Seriously 🤯

According to my quick search on GitHub, it doesn't seem to be spitting out verbatim in these cases. However, I am aware that there are instances where that's happening.

I think if they improve how they handle licensing (among other) issues (e.g. excluding repos that are GPL-licensed, making sure that it doesn't produce verbatim code, etc.), this could be a very useful tool. If used wisely, that is.

In other news

I upgraded this website to Next.js 11. I had been waiting for this issue to be fixed first.

I got pinged about my patch to Django earlier this year. I had planned to add tests and docs on the weekend, but giscus ended up taking most of my time. It's been six months since I initially worked on the PR, so I need some extra time to gather the context again. I've rebased the branch locally, though.

I started playing Ōkami today, just for less than an hour. I really like the art style. Looking forward to play it next weekend.

COVID-19 cases are still way up in here. I don't even know when we'll ever see a "peak" anymore.

Another one of my friends, who's studying medicine, tested positive.