How I Remove Duplicate Lines From a File With awk

One of the repositories I maintain is a beginner’s GitHub repo. New developers can make their first pull request by adding their GitHub handle to a simple text file. When pull requests get merged into the master branch, they often contain duplicates. The file has more than 7,000 lines. Names are not sorted alphabetically. I needed a simple way to remove all duplicates lines from the file without sorting the lines.
Read more →

TIL: Pass Multiple Commands to Xargs

I’m using fd, an alternative to the Unix native find, to find a list of files and copy them to a different location, using xargs. On Unix, we use cp to copy the files, but the command is silent. I don’t know which files cp will copy. Maybe I could use echo to log the files? How can I pass multiple shell commands to xargs? Previous command: fd --changed-within 1hour -0 | xargs -I cp {} /new/location/ fd -0 --changed-within: find all files changed within a time frame, separate results by null character |: pipe previous command as stdin to the next command xargs -I cp {} /new/location/: takes the input from previous command (fd) and uses cp to copy the files; {} is a placeholder What does not work:
Read more →

TIL: How to Set Multiple GOPATHs

How to set multiple workspaces (GOPATH) A Go Workspace is how Go manages our source files, compiled binaries, and cached objects used for faster compilation later. It is typical, and also advised, to have only one Go Workspace, though it is possible to have multiple spaces. The GOPATH acts as the root folder of a workspace. 1 Why multiple workspaces? I’d like to install my global binaries into a central location.
Read more →

My Git Aliases And Abbreviations

As a developer, Git is one of the essential tools in my daily work. Today I want to share my git aliases and fish abbreviations that make working with Git more comfortable. In my ~/.gitconfig file: [alias] # Git Commit, and Push — in one step. cmp = "!f() { git commit -m \"$@\"; }; f" # NEW. new = "!f() { git cmp \"📦 NEW: $@\"; }; f" # IMPROVE.
Read more →

The Terminal Sparks Joy

The Terminal Sparks Joy
Today I realized that using tools like the terminal, Vim or Tmux “spark joy” for me. The term comes from Marie Kondo’s bestselling book about tidying up. It loosely translates from original Japanese to ”the feeling of excitement and pleasure”. I thoroughly enjoy using Unix and its tools. For me, it’s like a mini game where I can always learn something new and feel more productive. For example, you can be productive with Vim after a few days.
Read more →

TIL: How to Watch YouTube Videos With mpv and Keyboard Shortcuts

Distraction-free YouTube (and other videos) on your computer The free YouTube version has ads and suggestions what to watch. Those try to keep the user on YouTube’s website. Tons of useful videos exist. If you’re like me, you’ll soon fall into the rabbit hole and spend too much time on YouTube. Today I learned how to use a distraction-free method of watching YouTube with mpv and (optionally) Vimium.
Read more →

TIL: How to Replace Backslashes (grep, sed, ripgrep, sd, ruplacer)

Today I needed to remove backslashes from a number of files. I have yaml frontmatter that should look like this: tags: - React.js - JavaScript I had some files that had backslashes before the dash: tags: \- React.js \- JavaScript You can use Unix tools like grep or sed to search all files that match a pattern. Then you can replace that pattern. But you have to remember that a backslash is a special character.
Read more →

Friday Picks 079

Read more →

Friday Picks 076

Read more →

Friday Picks 072

Read more →

Sign up for the newletter!

powered by Buttondown