Resolve conflict of auto-completion script when installing some packages

If we have Fish installed and try to install pretty new softwares via APT package manager (on Ubuntu), we may encounter this error:

Error: error processing archive /var/cache/apt/archives/just_1.35.0-1build1_amd64.deb (--unpack):

Error: error processing archive /var/cache/apt/archives/just_1.35.0-1build1_amd64.deb (--unpack):
 trying to overwrite '/usr/share/fish/completions/just.fish', which is also in package fish 4.0b1-1~oracular
...

Grey background issue with Helix inside Byobu

I often work on a remote Linux box and like to have Byobu running so that I have tab view and status bar. But somedays in mid 2024, somethings start to break when I open Helix inside Byobu and get this annoying gray background every where:

Grey background

The root issue is that, Byobu runs Tmux with a configuration, and that configuration makes tmux disable some features which is needed to render Helix theme correctly. The key is the TERM environment variable. No matter which terminal emulator we use, after running Byobu, the TERM is set to screen-256color.

...

Khám phá Nushell

Ai dùng Linux thì cũng phải đụng vào shell, với hình thức đơn giản nhất là chạy một chương trình / lệnh nào đó từ Terminal. Khi làm việc với server không có giao diện đồ họa, mọi tác vụ quản lý phải thực hiện qua dòng lệnh thì cũng là lúc ta sử dụng shell ở mức độ nâng cao hơn. Ta sẽ cần viết một lệnh dài để thực hiện nhiều việc theo chuỗi, hoặc viết thành một file script với điếu kiện if else, với vòng lặp để thi hành nhiều tác vụ phức tạp. Tuy nhiên, thật tình mà nói thì các phần mềm shell phổ biến trên Linux như Bash, Zsh tôi đều không thích cú pháp của chúng, nên nếu cần viết lệnh dài, viết ra file script thì tôi sẽ chuyển qua viết script Python. Mọi việc thường là thế cho đến khi tôi bắt gặp Nushell...

Sau khi chạy thử vài dòng lệnh theo bài giới thiệu nhanh, tôi thấy Nu quyến rũ với tư tưởng khá mới mẻ, đó là thiết kế dữ liệu chảy qua các ống dẫn (pipe) là dữ liệu có cấu trúc, có các field, chứ không đơn giản là văn bản text như các shell truyền thống. Để hình dung được ý tưởng này, xét ví dụ sau, là chạy lệnh ls trong Nu:

❯ ls
╭───┬────────────────┬─────────┬─────────┬────────────────╮
...

How to automatically deploy Python web application

Recently I saw a question from a Python fellow, how to deploy Django application without manually SSH to server and run commands. This style is single-server deployment, where you put all components, from the application code, database, to static, media files, in the same server. No Docker involves. With this deployment strategy, we will need some way to deliver new version of our app everytime new code is pushed to the "release" branch of Git repository. Here is a guide.

Why we need automation? Because it is boring to do these things by hand again and again:

  • SSH to the server, cd to the installation folder.
  • Run git pull.
  • Run commands to stop your services.
...


Prevent Firefox from being installed as snap package

Though being a long-time Ubuntu user, I still prefer softwares distributed as deb packages to snap. Every time upgrading to new Ubuntu version, I have to repeat the task of removing Firefox snap and install Firefox from deb.

When installing Firefox from APT repositories (like PPA or Mozilla APT repository), we have to set some configuration to prevent Ubuntu from installing Firefox snap again.

This snippet is introduced on Mozilla help page to do that:

...

Lập trình nhúng, Rust đã có những gì?

Rust là một ngôn ngữ hiện đại dành cho lập trình hệ thống và rất phù hợp cho việc lập trình nhúng. Nếu bạn làm trong lĩnh vực điện tử, IoT và muốn thử áp dụng Rust mà đang phân vân vì chưa biết có đủ "đồ chơi" hay chưa, có thể tham khảo bài viết dưới đây.

Ferris

Trước hết, nhắc lại những ưu điểm khiến Rust đáng để thử. Sau khi dùng Rust thì tôi thấy:

  • Giúp tăng năng suất làm việc. Sự chặt chẽ của Rust khiến lập trình viên tránh bug từ sớm, và giảm đáng kể thời gian, công sức test đi test lại. Thông thường, người lập trình nhúng hay phải nạp xuống board thường xuyên để chạy thử. Nhưng với Rust, tôi có thể viết code chay liền tù tì cả tháng mà không cần nạp xuống board. Ở AgriConnect Khi tôi bắt tay vào viết những dòng code đầu tiên của dự án thì thực ra đội điện tử chỉ mới xong bản vẽ chứ chưa làm mạch. Khi mạch thử nghiệm vừa hàn xong thì code cũng gần xong. Do làm việc từ xa nên tôi cũng không trực tiếp nạp code mà nhờ bạn khác trên văn phòng kéo code từ Git về, build, nạp, quan sát log và báo lại lỗi để tôi sửa tiếp. Tính chất này của Rust có lợi cho việc phát triển song song giữa đội phần cứng và đội lập trình.
...


How to play Zoo Tycoon 2001 in Ubuntu

Zoo Tycoon is one of my favourite games. Though I played it the first time around 2003, today, after more than 20 years, I still miss it. It is a Windows game, and I have switch to Linux for more than ten years, I still want to play it. Here is how to play it on Ubuntu.

Zoo Tycoon on Ubuntu

This article assumes that you already have its two CDs as ISO files. I cannot tell where to download them.

Released in 2001, where PCs are just 32-bit, this game can only run in 32-bit environment. This is a key to remember.

...

Effectly copy part of code file from remote machine

Let's say you have a source code file on a remote machine (accessed via SSH) and you want to copy a portion of the content to your local machine. There are many ways to do this, but I want to present an effective way, as it will take advantage of Helix's very convenient block selection feature.

For example, in the following image, the window on the left is accessing a remote machine, via SSH, on which I am opening a source code file using Helix. The window on the right is an editor, e.g. Geany, of your local machine. I want to copy the source of the enable_mqtt_on_gsm_modem function to Geany. In the left window, we should use a slightly modern Terminal application, e.g. Kitty, WezTerm, Alacritty because of a feature that I will explain later.

Figure 1

On the source file, we'll move the cursor to any line inside the enable_mqtt_on_gsm_modem body, then press m. Helix will bring up a menu of m command, let's press a to select "Select around object". Helix then shows the menu of m a.

...