Rezha Julio
rezhajul.io.web.brid.gy
Rezha Julio
@rezhajul.io.web.brid.gy
Abusing computers for Fun and Profit
12 January 2025 at 23:12
I am trying out POSSE from my blog to my socials.
rezhajul.io
January 24, 2025 at 1:33 PM
Migrating from Hugo to Zola
I have been using Hugo for my blog for a while now, and while I have been happy with it, I have been looking for a change. After some research and testing, I have decided to migrate my blog from Hugo to Zola. In this post, I will share my experience with the migration process and some of the reasons behind my decision. ### __Why I Decided to Migrate My development journey started with Django. I have been using Django since version 1.6 when I started my career 11 years ago. After working as a Django developer for a long time, I have grown accustomed to its template syntax and structure. While Hugo's Go templates are powerful, I find Django's template system more intuitive and easier to work with. The familiarity and clarity of Django templates make development more enjoyable for me, and this was one factor that drew me to explore alternatives to Hugo. After exploring various static site generators, I settled on Zola for several reasons. First, Zola uses a template syntax similar to Django's, which felt immediately familiar. While the build times are comparable to Hugo in my case, I appreciate Zola's simpler and more straightforward configuration. Everything from the directory structure to the template organization feels more intuitive to me. Additionally, Zola comes with built-in syntax highlighting and search functionality out of the box, which were features I had to configure separately in Hugo. ### __The Migration Process As I was already using TOML for my frontmatter, the migration process was relatively straightforward. I started by creating a new Zola site and copying over my content files from my Hugo site. I then updated the frontmatter in each file to match Zola's format and made any necessary adjustments to the content itself. I also had to update my templates to work with Zola's template syntax, which was a bit more involved but manageable. There are some differences between Hugo and Zola. For example, the tags and categories taxonomies are handled differently in Zola. # Hugo tags = ["Hugo", "Zola"] # Zola [taxonomies] tags = ["Hugo", "Zola"] Editing all of them would be a pain, so I wrote a small awk script to automate the process. Here is the script: BEGIN { in_frontmatter=0; has_taxonomies=0; tags="" } /^\+\+\+/ { if (in_frontmatter) { if (!has_taxonomies && tags != "") { print "\n[taxonomies]" print tags } } in_frontmatter = !in_frontmatter has_taxonomies = 0 print next } in_frontmatter && /^tags = / { tags = $0 next } in_frontmatter && /^\[taxonomies\]/ { has_taxonomies = 1 if (tags != "") { print print tags tags = "" next } } { print } Save the script as `update_frontmater.awk` and run it on your content files like this: find content/posts -name "*.md" -exec sh -c 'awk -f update_frontmatter.awk "$1" > "$1.tmp" && mv "$1.tmp" "$1"' sh {} \; This script will add the `[taxonomies]` section to the frontmatter of each content file if it is missing and move the `tags` field to the `[taxonomies]` section. I haven't tested it for all cases so be careful when using it. ### __Other Additions I have also taken this opportunity to add Fediverse comments to my blog. I have been using Mastodon for a while now, and I wanted to integrate it into my blog. I found a blogpost by Carl Schwan that explains how to add Mastodon comments to a static site using a simple JavaScript snippet. I followed his instructions and added the snippet to my templates, and now visitors can comment on my posts using their Fediverse accounts. You can try it out by commenting on this post! ### __Conclusion The migration from Hugo to Zola was a smooth process overall, and I am happy with the results. Zola's template system is more intuitive for me, and I appreciate the flexibility it offers. I am looking forward to exploring more of Zola's features and customizing my blog further. If you are considering migrating from Hugo to Zola, I would recommend giving it a try and seeing if it fits your needs. See you in the next post!
rezhajul.io
January 12, 2025 at 8:54 AM
Uses
Hardware, software and services that I use for work and my own enjoyment. ### Computer * Macbook Pro M1 Pro 16GB RAM 1TB SSD * 32" curve monitor * TKL Mechanical Keyboard (assembled from several used parts that I already have) * Logitech G300s gaming mouse (reused from my PC Gaming) * Harman Kardon Aura Studio 3 for Audio * Bose QC45 headphone ### Gaming * RoG Ally Z1 Extreme * ~~PC Gaming~~ (Donated to my GF) * PS3 * ~~PS4~~ (Donated to my brother) * Nintendo Switch * PS5 * 55" 4K LG TV ### MacOS * Kitty: Fast, feature-rich, GPU-accelerated terminal emulator. It supports various features like ligatures, bitmap fonts, Unicode, and more. * Jetbrains IDE: Their IDEs are known for their powerful features, code analysis tools, and support for popular programming languages. * Orbstack * MarkText: a lightweight markdown editor that provides a distraction-free writing environment for creating and editing markdown documents. * Firefox: a popular web browser developed by Mozilla. It is known for its focus on privacy and security features, as well as its customizable interface and support for extensions. * Cryptomator: an open-source encryption tool that allows users to secure their files and folders with strong encryption before storing them in the cloud. * Obsidian: a note-taking and knowledge management app that uses a markdown-based approach to help users organize and connect their notes. It offers features like backlinks, graph view, and custom templates to facilitate knowledge organization and retention. * AdGuard Pro: Premium ad-blocking app help block ads, trackers, and malicious websites while browsing the internet. It offers advanced filtering options, DNS protection, and customization features to enhance the browsing experience. * Nheko: Nice Matric client written in qt. * Setapp subscription * Aldente Pro: the all-in-one charge limiter App for MacBooks. * Permute: a useful utility for quickly converting files to different formats. * OpenIn: can open links from apps to your preferred browsers. * Bartender: Replaced with Ice due to privacy issue after the app is being sold without any announcement * TripMode: Firewall, really useful when using mobile tethering to block apps from connectiong to internet and wasting your mobile data. * HazeOver: Dim other windows except the active one, to prevent distraction. ### iOS * AdGuard Pro * BitWarden: password manager application, uses self-hosted Vaultwarden * Obsidian * Mona: feature-rich Mastodon client designed to provide a seamless and intuitive experience when accessing the Mastodon social network on iOS. * IceCubes: an open-source Mastodon client with many AI features. * Infuse: a media player app that allows me to play a wide range of video formats on my devices. It offers features like support for various file types, streaming from network drives, and automatic metadata fetching for a seamless media playback experience. * Element: messaging app that enables secure and private communication through end-to-end encrypted messaging and video calls. * Reeder 5: RSS reader app that helps me stay updated with my favorite websites and blogs by aggregating their content in one place. It offers features like offline reading, feed organization, and integration with popular read-later services for a personalized reading experience. * Secure Shellfish: the best ssh client for iOS, complete with Codespaces support and Files.app integration. * Lagrange: a versatile and user-friendly Gemini client designed specifically for iOS devices. The app provides a seamless browsing experience for exploring the Gemini protocol, which focuses on simplicity, privacy, and minimalism in browsing. ### Services * ~~Google Workspace~~ (Migrated to Fastmail) * Fastmail: handles my main email and all of my domains. * Mullvad: Securely handles all of my VPN connectivity, don’t need private information to register. * Porkbun: Take care of all my International domains, also provide DNSSEC and email redirect. * Cloudkilat: Take care of my Indonesia domains. * Contabo: Hoster for VPS. * Hertzner: Hoster for Backup Storage. ### Self-host * Mastodon * Miniflux * The lounge: IRC client that act as a bouncer * Matrix: Secure and decentralized chat * Nextcloud * Uptime Kuma * Minio * Alternative Front-end Interfaces * Libreddit * Invidious * Libmedium * LibreY * Proxytok * Quetre * AnonymousOverflow ### Tools * Rclone * Restic * Kopia
rezhajul.io
January 11, 2025 at 8:52 AM
Several Cool Things You Can Do with F-Strings in Python
F-strings are a powerful and easy-to-use way to format strings in Python. They are more readable than traditional string formatting methods and offer more flexibility. In this blog post, we will explore five useful F-string formatting tricks that you can use to make your code more readable and maintainable. # __Use f-string to format number: You can insert any character after the colon in an f-string to add them as thousand separators. For example, the following code will format the number 1234567 as 1,234,567: number = 1234567 print(f"The number is: {number:,}") print(f"The number is: {number:_}") === Result === The number is: 1,234,567 The number is: 1_234_567 # __Align text: You can use the right arrow > to right-align text, the left arrow < for left-align, and the up arrow ^ to center-align text. You can also specify a fill character to fill the empty spaces. For example, the following code will right-align the text "Hello" with 20 spaces: text = "Hello" print(f"{text:>20}") print(f"{text:<20}") print(f"{text:^20}") === Result === Hello Hello Hello You can also specify the character that you want to use to fill the empty space. text = "Hello" print(f"{text:+>20}") print(f"{text:-<20}") print(f"{text:=^20}") === Result === +++++++++++++++Hello Hello--------------- =======Hello======== # __Format date and time: You can use date time format specifiers like `%d`, `%m`, and `%Y` to format date and time in an f-string. You can also use `%I`, `%p`, `%H`, `%M`, and `%S` to format the time in 12-hour format, 24-hour format, etc. For example, the following code will format the current date and time to `%Y-%m-%d %H:%M:%S`: from datetime import datetime now = datetime.now() print(f"The current date and time is: {now:%Y-%m-%d %H:%M:%S}") === Result === The current date and time is: 2024-02-13 19:24:06 You can check this site to find other date time format specifiers. # __Round numbers: You can use the f specifier followed by the number of decimal places to round a number to that many decimal places. For example, `:.2f` rounds a number to two decimal places. The following code will round the number 3.14159 to two decimal places: number = 3.14159 print(f"The number rounded to two decimal places is: {number:.2f}") === Result === The number rounded to two decimal places is: 3.14 # __Debug code using f-strings: You can add an equal sign and an expression inside the curly braces of an f-string to evaluate the expression and print the result. This can be useful for debugging code because it shows you the value of the expression at that point in the code. For example, the following code will print the value of the variable x: x = 10 print(f"The value of x is: {x=}") === Result === The value of x is: x=10 I hope these five tips help you write more readable and maintainable Python code! In addition to the tips in the post, here are some other things to keep in mind when using F-strings: * F-strings can be used to format any type of data, not just strings. * You can use f-strings inside other f-strings. * You can use f-strings to create multi-line strings. I hope this blog post has been helpful! Please let me know if you have any questions.
rezhajul.io
January 12, 2025 at 8:54 AM
Upgrade Major PostgreSQL version on Docker
Upgrading a PostgreSQL database server to a newer version is a common task for database administrators and developers. In this post, we will discuss how to upgrade a PostgreSQL database server running in a Docker container. On 1 January, I decided to upgrade the PostgreSQL used by my Mastodon instance. It was using PostgreSQL 12 and I think it could used the upgrade to PostgreSQL 15 for that "extra performance and features". For the upgrade process, basically you need to run `pg_upgrade` tool. `pg_upgrade` allows data stored in PostgreSQL data files to be upgraded to a later PostgreSQL major version without the data dump/restore typically required for major version upgrades, e.g., from 9.5.8 to 9.6.4 or from 10.7 to 11.2. It is not required for minor version upgrades, e.g., from 9.6.2 to 9.6.3 or from 10.1 to 10.2. Fortunately, I found a github repository from Tianon that contain ready-to-use container image to upgrade PostgreSQL. I will share how my experience in using them. * Shutting down the database: I am using docker-compose for the deployment, so I just run `docker-compose stop` to stop the whole deployment of the Mastodon stack. * Backing up the data: `docker-compose.yml` I am using is already using volume, so I just simply copying the folder with new name `cp -r postgre12 old`. Notice I am using `old` as my folder name. This folder will be used as a source directory for `pg_upgrade` later. * Make new directory for new data: `mkdir new` * Pull the docker image: `docker pull tianon/postgres-upgrade:12-to-15`. Plase adjust with the Postgre version you have and the target version you want. See above repo to check wether your version is available. * Run the docker image and wait: `docker run --rm -v /path/to/folder/mastodon/old:/var/lib/postgresql/12/data -v /path/to/folder/mastodon/new:/var/lib/postgresql/15/data tianon/postgres-upgrade:12-to-15`. Make sure the version of image and version to postgresql path is already correct * Rename the folder: I rename the `new` folder to `postgres15`. * Adjust your docker-compose for the new database folder and docker image. See example below: Before: db: restart: always image: postgres:12-alpine shm_size: 256mb networks: - internal_network healthcheck: test: ['CMD', 'pg_isready', '-U', 'postgres'] volumes: - ./postgres12:/var/lib/postgresql/data After db: restart: always image: postgres:15-alpine shm_size: 256mb networks: - internal_network healthcheck: test: ['CMD', 'pg_isready', '-U', 'postgres'] volumes: - ./postgres15:/var/lib/postgresql/data I run the `docker-compose up -d` to check wether everythings work perfectly. You might want to check and compare the configuration on `pg_hba.conf` and `postgresql.conf` first beforehand. I had issue where the new `pg_hba.conf` only listen to localhost only.
rezhajul.io
January 12, 2025 at 8:54 AM
Hey there
It's been a few years since I last sat down to write a blog post, and a lot has changed in that time. The biggest change, of course, is the loss of my father this year. It's been a difficult and emotional journey, but I've been trying my best to keep moving forward and find ways to honor his memory. One of the things that has helped me through this difficult time is reconnecting with old hobbies and passions. For me, that means getting back to writing. It's been a great outlet for me to express my thoughts and feelings, and I've found that it brings me a sense of peace and clarity. I've also been spending more time outdoors, exploring new places and rediscovering the beauty of nature. I find that being in nature helps me to feel more connected to the world around me, and it reminds me of the endless possibilities that life has to offer. In the past few months, I've also been trying to focus on the things that bring me joy and make me happy. I've reconnected with old friends and made some new ones, and I've started taking on new challenges and trying new things. It's been a great way to keep moving forward and to keep my mind and body active. Of course, there are still days when the loss of my father feels overwhelming, and I struggle to find the motivation to keep going. But I remind myself that he would want me to keep living my life to the fullest, and to make the most of every day. I know that he would be proud of me for continuing to find ways to honor his memory and to keep moving forward, no matter what life throws my way. So here I am, back to writing again after all these years. It feels good to be back, and I'm looking forward to sharing my thoughts and experiences with all of you. Thanks for sticking with me, and for being a part of this journey.
rezhajul.io
January 12, 2025 at 8:54 AM
What happened to self-hosted blogs?
I remember a while ago when all of us run a personal blog on the Internet. And I mean personal, not hosted on some side platform or an addition to their website. I mean personal. Companies and individuals are now using Medium platforms to host and support all their articles, essays and case studies. I understand the drawing and can even list the positive elements: 1. Under the Medium brand there is already a large community. 2. Promoting your own work and following others is easy. 3. The platform can be set up and implemented relatively easily. Unfortunately, this has had a very severe impact on the blogging community - nobody controls their own blogs. It was an interesting and fun experience for me when I found a new blog: * How did they choose to design the page ? * What typefaces did they choose to use ? * What are they using as back-end ? * How do it look and feel on your mobile phone ? These personalized self-hosted blogs have inspired other developers to build their own or tweak current blogs. In some ways this was a small factor when we pushed what we can do further and further on the web as developers went on to compete with each other. I also think this inspired people to write better content instead of choosing clickbait garbage to get "featured" or boosted promotion on the main blogging platform, but I don't think that's the worst thing to come from this mass migration to a single blogging platform. I'm not sure if it is the intention of Medium, but I personally believe that it is awful either way. The personality of most design and development blogs has been completely removed from them. All blogs look the same now. Perhaps I was just a salty developer, with a narrow, pessimistic perspective about where our bloggers seem to lead – or perhaps I have only higher standards.
rezhajul.io
January 12, 2025 at 8:54 AM