Getting File Stats in Electron

You can get basic information about a file using the fs.stat method. This asynchronous function accepts a file path and returns an object that looks like this: { "dev": 16777234, "mode": 33188, "nlink": 1, "uid": 501, "gid": 20, "rdev": 0, "blksize": 4096, "ino": 806397637, "size": 311339, "blocks": 616, "atimeMs": 1740349370637.4573, "mtimeMs": 1740349369783.987, "ctimeMs": 1740349369783.987, "birthtimeMs": 1740349369783.5325, "atime": "2025-02-23T22:22:50.637Z", "mtime": "2025-02-23T22:22:49.784Z", "ctime": "2025-02-23T22:22:49.784Z", "birthtime": "2025-02-23T22:22:49.784Z" } Here’s how you could use it to check if the file is empty: const stats = await fs.stat(filePath); if(stats.size === 0){ // Do something }

February 23, 2025 · 1 min · 90 words · Me

Hugo Code Highlight

After reading about Expressive code highlighting in Astro, I was curious if it was possible to achieve the same in Hugo. This post is proof that it is, but it wasn’t as straightforward as I had hoped. Since I’m using the PaperMod theme, highlighting doesn’t work the same as it does in generic Hugo themes (PaperMod is doing some opininated things with the syntax highlighting). Nonetheless, all I had to do was add this CSS to the themes/papermod/assets/css/post-single.css file: ...

February 10, 2025 · 2 min · 262 words · Me

Four Backticks for Code

I recently realized there is no upper limit on the number of backticks you can put in front of your markdown code blocks. This uses 4 backticks. This uses 5 backticks. This uses 6 backticks. And so on. The use cases for this are rare but they exist. For example, I recently posted about using expressive code features in Astro. Since Hugo (what this blog is built on doesn’t support expressive code), expressive code features either break the build or don’t render correctly. But by using 4 backticks, I was able to show the code block as it would appear in Astro. ...

February 10, 2025 · 1 min · 114 words · Me

Fuzzy Search vs Code

There is a new experimental setting for VS Code’s copilot that lets you enable semantic search in the search window. github.copilot.chat.search.semanticTextResults Once you enable the semantic search setting, you’ll see a new dropdown under the search results in the search panel. Expanding the dropdown will show you the semantic search results (after a few seconds of processing). Caution I’ve noticed that this works better in non-blog projects. In my Hugo blog (this website), the search results miss things that seem obvious. ...

February 8, 2025 · 1 min · 94 words · Me