All About My Custom Hugo Theme KMT

My ToDo List for 2024 (daily updates)

waffarx cash back

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:

Git Cola Cheatsheet

git cola: A powerful Git GUI with a slick and intuitive user interface. Start the GUI: git cola Start the GUI in amend mode: git cola --amend Prompt for a Git repository. Defaults to the current directory: git cola --prompt Open the Git repository at mentioned path: git cola --repo path/to/git-repository Apply the path filter to the status widget: git cola --status-filter filter For more information: https://git-cola.readthedocs.io . I hope this post helps you.

Git Annex Cheatsheet

git annex: Manage files with Git, without checking their contents in. When a file is annexed, its content is moved into a key-value store, and a symlink is made that points to the content. Initialize a repo with Git annex: git annex init Add a file: git annex add path/to/file_or_directory Show the current status of a file or directory: git annex status path/to/file_or_directory Synchronize a local repository with a remote:

Gitlint Cheatsheet | Git commit message linter

gitlint: Git commit message linter checks your commit messages for style. Check the last commit message: gitlint The range of commits to lint: gitlint --commits single_refspec_argument Path to a directory or Python module with extra user-defined rules: gitlint --extra-path path/to/directory Start a specific CI job: gitlint --target path/to/target_directory Path to a file containing a commit-msg: gitlint --msg-filename path/to/filename Read staged commit meta-info from the local repository: gitlint --staged For more information about git lint: https://jorisroovers.