I wanted to reduce the number of dependencies in my Rust project, and I noticed that the rust-i18n crate has a lot of dependencies (a whopping 46 of them). Since I didn’t really have that many translations and they didn’t need any special logic, I figured that I could just write a very simple localization function myself. First, I made an enum in a new file lang.rs to represent all supported languages (just two of them in my case):| Posts on aarol.dev
I recently saw a bunchofvideos about simple particle simulations where there are thousands of tiny 2D balls interacting with each other, and it looked very fun! I wanted to do something very similar, but I also wanted to use Zig, a language that I haven’t used much before but is currently one of the trendiest languages around. This post is primarily about using the Zig build system to build a program that uses SFML to make cross-platform graphics. SFML is a C++ multimedia library (which mea...| Posts on aarol.dev
It’s the time of year to start sending some summer job applications again. And is there a better way to procrastinate improve the job searching experience than to generate the CV from simple markup with Typst? Typst is new1 a typesetting system similar to LaTeX, but has much nicer syntax, and also it’s written in Rust!🤷 In this post I’ll show some basic features of Typst to build a simple CV file that looks like this.| Posts on aarol.dev
Anyone who has implemented a simple HTTP 1.1 server can tell you that it is a really simple protocol. Basically, it’s a text file that has some specific rules to make parsing it easier. All HTTP requests look something like this: 1 GET /path HTTP/1.1\r\nHost: aarol.dev\r\nAccept-Language: en,fi-FI\r\nAccept-Encoding: gzip, deflate\r\n\r\n The first line is the “request line”, and it has the requested method, path and HTTP version. The following lines are headers, each terminated with ...| Posts on aarol.dev
Making changes to websites is tricky, because even small changes may lead to visual regressions in the page layout. For example, changing a bit of CSS to fix something somewhere may blow up in a completely different place. I could just click around and make sure everything looks okay, but that is boring and error-prone. What if I told you that there is a way to make sure that every pixel on your site is perfect, staying just they way you intended it to be?| Posts on aarol.dev
Recently, the cushions of my old headset, the HyperX Cloud Stinger, were breaking apart pretty bad. I had been using them for 5+ years at that point, so it was time for an upgrade. I bought a new wireless gaming headset, the SteelSeries Arctis Nova 7. So far, it has been great. I was expecting to feel a noticeable delay in the audio since they are wireless, but I am happy to report that with the 2.4 Ghz wireless adapter there is practically no delay! They have about 38 hours of battery life t...| Posts on aarol.dev
Advent of Code is an annual set of Christmas-themed computer programming challenges that follow an Advent calendar. It has been running since 2015. The programming puzzles cover a variety of skill sets and skill levels and can be solved using any programming language. Participants also compete based on speed on both global and private leaderboards. – Wikipedia What makes AOC particularly fun is the daily challenge aspect, and the community. When doing this year’s AOC challenges in Go, I f...| Posts on aarol.dev
Dev Drive is a new type of storage volume in Windows 11 that is specially made for programming workloads. Instead of the typical NTFS filesystem, it uses ReFS (Resilient File System), which is a newer filesystem based on Copy-on-Write (COW) linking. Basically, if you have two copies of a file, only one copy actually exists on the disk. The other one exists only as a link to the first one. Then, when you actually write to the linked file, the original data is lazily copied into it (hence Copy-...| Posts on aarol.dev
Have you ever shared a link somewhere and wondered where those little preview images of websites come from? Well if you didn’t know, they are called OpenGraph tags. Open Graph protocol was invented by Facebook and is now used by many other social media sites, like X (Twitter), LinkedIn, Reddit, Discord, Mastodon and many others. They look like this: <head><metaproperty="og:title"content="Generating OpenGraph images with Hugo"/><metaname="description"content="Have you ever shared a link some...| Posts on aarol.dev
Valmistuin ylioppilaaksi keväällä 2023. Kirjoitin viisi eri ainetta, joista sain seuraavat arvosanat: AinePistemäärä / MaxArvosanaL:n pisteraja Äidinkieli80 / 120E89 Pitkä englanti271 / 299L267 Pitkä matematiikka105 / 120L81 Fysiikka84 / 120L81 Kemia111 / 120L99 Olin yllättynyt lopullisista arvosanoista, koska preliminäärikokeeni eivät olleet menneet yhtä hyvin. Opettajien arviot pitivät yleensä paikkaansa, mutta fysiikan arvosana romahti opettajan antamasta arviosta 15 pistet...| Posts on aarol.dev
After Lastpass suffered a massive data breach last year, I began looking for an alternative password manager. Bitwarden is another centralized password manager like LastPass, but with the added benefit of being completely open source! They also allow you to spin up your own Bitwarden server and connect to them with all of their clients. Fly.io has a generous free tier, allowing up to 3 virtual machines with 256 MB of RAM, and 3 GB of persistent volume. 256 MB of ram isn’t a lot, but it shou...| Posts on aarol.dev
Compared to Javascript, Python and other single threaded languages, Go takes a very different approach to I was having difficulties understanding how concurrent Go programs are supposed to work. Coming from single-threaded event-driven languages like Dart and Javascript, it was not easy wrapping my head around things like mutexes or channels. I recently found the Little Book of Semaphores, which is a free ebook that teaches methods for synchronization in concurrent programs. It does this with...| Posts on aarol.dev
TLDR: # http.ListenAndServe(":8080",nil)// badhttp.ListenAndServe("localhost:8080",nil)// good If you are using Go with Windows, you might encounter a small annoyance when running a http server. When using go run to run the server, Windows Defender will sometimes prompt you for firewall access. Here is an example of a Gin server doing it: packagemainimport("github.com/gin-gonic/gin")funcmain(){r:=gin.Default()r.GET("/ping",func(c*gin.Context){c.JSON(200,gin.H{"message":"pong",})})r.Run()// li...| Posts on aarol.dev
Shortcuts # Ctrl + Shift + K : Delete current line Alt + Down/Up : Move selected line(s) up/down Alt + Shift + Down/Up : Duplicate selected line(s) up/down Ctrl + D : Select next occurrence of selection (shown below) Ctrl + K + Ctrl + D : Unselect the last occurrence and select the next one (used in combination with Ctrl + D ) Alt + Click : Place a multi-cursor Ctrl + Shift + L : Place a multi-cursor on all matches in current file Ctrl + ` : Bring up and focus the integrated terminal Ctrl + P...| Posts on aarol.dev
ATTENTION: there are now several forks of SD that offer web GUI’s and can install on Windows in one click (most notably sd-webgui). If you want to run Stable Diffusion programmatically and don’t mind some extra steps, read on. Prerequisites # In order to run Stable Diffusion locally on Windows, you will need a Nvidia GPU with at least 8 GB of VRAM and the latest Game Ready drivers. We will use WSL2 (Windows subsystem for Linux) to run Stable Diffusion.| Posts on aarol.dev
Fly.io is a cloud service that can be used to easily deploy fullstack applications on the web. You only pay for what you use, and servers can be scaled up and down easily. Fly.io supports lots of frameworks and Docker images, which will come in handy. I’ll show how you can deploy a Caddy web server serving a single page application with a Go backend. Getting started # First, you will need to install flyctl and create a fly.io account. Once you have logged in with flyctl, create a new applic...| Posts on aarol.dev
X11 doesn’t support monitors with variable refresh rates: When using one 60hz monitor and one 144hz monitor, the shell (Gnome, KDE etc) will run at 60hz on both monitors. Wayland might fix this, but: Wayland is not enabled on Nvidia GPUs by default. Even if it is possible to use Wayland with the proprietary drivers, it’s not stable enough to be the default, for example in Fedora. Text rendering is not as good as on Windows. I don’t have any examples of this, but the text is less smooth ...| Posts on aarol.dev
While reading the code of flutter apps, I’ve seen this particular piece of code repeated way too many times: returnMaterialApp(theme:ThemeData.dark().copyWith(textTheme:...),home:...) This is problematic for a couple reasons that become clear when we take a peek at how ThemeData works. This is taken directly from the material library’s code: factoryThemeData.dark()=>ThemeData(brightness:Brightness.dark); That is all that it does. It just changes the brightness parameter from light to dark...| Posts on aarol.dev
There are a lot of units to remember in physics. I often make errors because I forget to multiply by something, or I’m mixing up meters and kilometers by mistake. Wouldn’t it be convenient to not have to worry about that and make the computer to it instead? I recently found out that SpeedCrunch, which is a fast & minimal open-source scientific calculator, happens to support units really well. Say we have a velocity and time, and we want to find the displacement s where $$ s=v*t $$| Posts on aarol.dev
The app I’m currently building has a feature which displays a custom wallpaper on the home screen. It involves the user choosing an image from their gallery and cropping it to their device’s aspect ratio. The app then modifies the image and sets it as the background. There’s just problem: How do I get the pixel dimensions of the screen? Screen height in Flutter # After a bit of searching, I found this property in the dart:ui package:| Posts on aarol.dev
Faster substring search with SIMD in Zig| aarol.dev
I’ve been learning a lot about low-level programming languages lately, and for a long time there has been one thing that has interested me: SIMD (or ‘single instruction, multiple data’) code. I’ve seen a lot of articles about having massive performance gains by utilizing SIMD and wanted to learn how to do it myself. This article is a journey into implementing ~60% faster substring searching compared to Zig’s std.mem.indexOf using a SIMD-friendly algorithm.| aarol.dev