Posts

My ToDo List for 2024 (daily updates)

waffarx cash back

Is Go Used in Production more than Rust ?

I was wondering if programs used in the real world are mostly written/built in Rust or Go? How to create a real world statistic to compare ? Homebrew package manager 🔗 I found that Homebrew lists the dependencies of the package like this. $ brew info eza ==> eza: stable 0.18.13 (bottled) Modern, maintained replacement for ls https://github.com/eza-community/eza Not installed From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/e/eza.rb License: MIT ==> Dependencies Build: pandoc ✘, pkg-config ✔, rust ✘ Required: libgit2 ✘ ==> Analytics install: 12,792 (30 days), 38,295 (90 days), 68,375 (365 days) install-on-request: 12,790 (30 days), 38,293 (90 days), 68,375 (365 days) build-error: 0 (30 days) The dependencies of eza to build are pandoc, pkg-config and Rust.

Trend of Focusing on Software Performance & Efficiency

You are hearing blazingly fast, faster, at the speed of thought, lightning fast, wicked fast,.. and too many similar phrases. This trend of performance optimization is not just in words and projects and such, It expands to include programming languages themselves, libraries, websites, servers, all things software. Even hardware, but we’ll focus on software. Performant and efficient programming languages 🔗 If you plot the performance and efficiency of programming languages from 2000 until 2024 (current year), you’ll find that the programming languages are competing to boost their performance and efficiency.

Should I use `mb_strlen($text, 'utf-8')` or `strlen($text)` in PHP ?

In most cases, you should use mb_strlen($text, 'utf-8') in PHP. Here’s a breakdown of the reasons: Why mb_strlen is the recommended? 🔗 Accuracy for Multibyte Characters: mb_strlen is designed for handling multibyte character encodings like UTF-8. It considers characters that can be composed of multiple bytes, giving you the correct character count. strlen assumes single-byte characters and might undercount the length for strings with characters outside the basic ASCII range.

Don't Communicate by Sharing Memory, Share Memory by Communicating: A Go Approach

This concept, a core principle in Go’s concurrency model, can be confusing at first glance. Let’s break it down with practical examples in Go, highlighting the difference between unsafe memory sharing and safe communication via channels. The Problem with Shared Memory 🔗 Imagine two goroutines (lightweight threads) in your Go program, Reader and Writer, that need to access the same data: var data int // Shared variable (unsafe) func Reader() { fmt.

How I improved Kartbusiness.com page loading speed from 52 to 94

I used PageSpeed Insights , to detect the performance bottlenicks so I can analyze and fix the performance issues. Here are all optimizations I did on KartBusiness.com to improve the PageSpeed Insights performance metrics. run scripts inside web workers 🔗 I offloaded some scripts from running on browser/JS main thread into a web worker by using the partytown library. I specifically offloaded Google Analytics scripts (gtag) and Meta Pixel script (Facebook’s).

Execute a command once per line of piped input?

How to execute a command once per line of the piped input? or how to pipe each line at a time in linux terminal? is the same question. There are two main ways to achieve this. Using a while loop with read 🔗 This is a common approach for simple scenarios. Here’s the structure: command | while read line; do # Perform some action on each line stored in the variable "$line" your_command "$line" done command: This is the command that generates the output you want to process line by line.

ed Cheatsheet

ed : The original Unix text editor. ed is a line editor for the Unix operating system. It was one of the first end-user programs hosted on the system and has been standard in Unix-based systems ever since. ed was originally written in PDP-11/20 assembler by Ken Thompson in 1971. Start an interactive editor session with an empty document: ed Start an interactive editor session with an empty document and a specific [p]rompt:

Awk Cheatsheet

awk: A versatile programming language for working on files. Print the fifth column (a.k.a. field) in a space-separated file: awk '{print $5}' path/to/file Print the second column of the lines containing “foo” in a space-separated file: awk '/foo/ {print $2}' path/to/file Print the last column of each line in a file, using a comma (instead of space) as a field separator: awk -F ',' '{print $NF}' path/to/file Sum the values in the first column of a file and print the total:

sed Cheatsheet | Edit text in a scriptable manner

sed: Edit text in a scriptable manner. Replace all apple (basic regex) occurrences with mango (basic regex) in all input lines and print the result to stdout: command | sed 's/apple/mango/g' Execute a specific script [f]ile and print the result to stdout: command | sed -f path/to/script_file.sed Replace all apple (extended regex) occurrences with APPLE (extended regex) in all input lines and print the result to stdout: command | sed -E 's/(apple)/\U\1/g' Print just a first line to stdout:

Git Subtree Cheatsheet

git subtree: Manage project dependencies as subprojects. Add a Git repository as a subtree: git subtree add --prefix=path/to/directory/ --squash repository_url branch_name Update subtree repository to its latest commit: git subtree pull --prefix=path/to/directory/ repository_url branch_name Merge recent changes up to the latest subtree commit into the subtree: git subtree merge --prefix=path/to/directory/ --squash repository_url branch_name Push commits to a subtree repository: git subtree push --prefix=path/to/directory/ repository_url branch_name Extract a new project history from the history of a subtree: