Header logo.
Small Hallucinations
HomeArchiveTagsAboutFeed

How Gen AI helps me in a very particular use case

I remember in late 2022, Vibhakar Sarswat told an audience of dozens of developers at a Flutter Stockholm event that he began building his mobile app with the help of GitHub Copilot after finishing a tutorial, and he described GitHub Copilot as “a good teacher.” I chuckled in disbelief.

My early impression of GitHub Copilot was that it was more clumsy than helpful, but it quickly improved and made me more productive. Now in addition to Copilot, I use ChatGPT every day and other gen AI tools quite often too.

Apart from generating code, asking technical questions, making quick queries of syntax and features, I'm using these tools for learning natural languages.

And I find ChatGPT helpful in this very particular way: ⋯

Copy and paste on Ubuntu

On a Mac, if you press Command-C while not selecting anything, nothing happens. I didn't realize this was a behavior that had been designed and implemented by someone until I did the same on Ubuntu.

On Ubuntu, what happens when you press Ctrl-C while not selecting anything is two things:

I'm saying as if this is an Ubuntu problem. But I don't really know. It is most likely handled by Gnome alongside (in my case) X11 according to Reddit.

And you would think the clipboard is a solved problem since it was invented in 1973.

“Asia/Beijing” doesn’t exist

I was writing a Python script last week and the ORM threw a tantrum, asking for an “offset-aware” datetime.

ChatGPT (GPT-4o) suggested I use the zoneinfo package and simply specify the name of the timezone.

Naturally, I assumed the timezone name for Beijing would be “Asia/Beijing” and asked GPT-4o for confirmation.

Recent readings

How to Work with SQL Databases in Go

This post is a good point of reference that clarifies how you can use transactions and contexts while working with SQL databases in Go. The author of this post, Jia Hao, also shares his learnings about algorithms and Elixir on his website.

Web Development with Go

This course is pretty good. Go has a rather straightforward syntax. When you want to build something using Go, there are a lot of options to choose from at every step. Which framework should you use? Do you need an ORM? How shoud you manage schema changes and run migrations? In addition, the internet will always tell you to “just use the standard library” because it already does everything well. ⋯

Fixing addon bugs for Anki 23

I've been using Anki for years. Anki has recently changed its version numbers to year.month. From version 23.10, FSRS algorithm is implemented for scheduling reviews. Without thinking too much, I upgraded to the latest version.

Not surprisingly, this upgrade broke a few addons on my computer:

Fixing them was easier than I had thought.

When you start Anki, you are greeted with this alert if there's a bug in an addon. ⋯

Something clever in the syntax of Elixir

I find this quite clever in the syntax of Elixir.

There are two sets of boolean operators in Elixir and, or, not versus &&, ||, !.

The difference is that and, or, not only take literal boolean values. In contrast, &&, ||, ! can take values of all types. And all values except false and nil will evaluate to true.

When you think about it, it makes a lot of sense. Because literal boolean values -- true and false -- are words. It's only natural that they go with words: and, or, not.

Adding a new context and define associations in Phoenix

I'm still doing Dockyard's tutorial of Elixir and Phoenix.

So far I've progressed to building a blog context. Now I'm trying to add a comment context to the app. This would also allow the user to post a comment and list all the comments below a post.

This exercise is designed to teach you about how to create one-to-many relations in Phoenix.

Although the concept is easy to grasp, there are a few steps you need to take and quite a few files you need to change. ⋯

Ecto search keyword interpolation

Updated on 2023-11-27:

Now I realize I didn't need to use a fragment. I could have used ilike.

The difference between ilike and like is that ilike is explicitly case-insensitive, whereas like could be case sensitive based on the database you are using.

Original post:

Untracking files in Git

Normally you can avoid tracking files in Git by adding files to .gitignore.

But if files have been previously added for tracking, they will still be tracked even after appending them to .gitignore.

We need to first remove tracked files from cache. And add back all the files – including .gitignore – in the current directory. Now .gitignore will take effect.

Using Readwise

I realized I read quite a lot on the web. I spend a lot of time browsing answers on StackOverflow and reading documentation.

For the most part, such information is only useful once and it's OK to forget it. But occasionally, I'd come across a new bug that reminds me of an older problem I had seen before. At that time, I'd wish I could remember how I solved that problem earlier.

I take notes in Obsidian when I try to seriously learn something new. In the meantime, I'd create flashcards in Anki if I find what I'm learning really useful.

The downside of this is, when you are in the middle of debugging, it feels costly to pause and change the mode from debugging to note-taking. (To reduce the friction while collecting information in Obsidian, I've enabled global hotkeys. Hope this can be helpful.) ⋯