cliday

  • About

2022-09-23

September 23, 2022

  1. paydept: Shows every open-source dependency you use in your system that accept donations
  2. awesome-maintainers: Talks, blog posts, and interviews about the experience of being an open source maintainer

Article of the week: Open Source Bait and Switch

“…cURL is used by pretty much everyone but I don’t think we’ll see a cURL foundation… Does this mean all open source should be a hobby or a mega-all encompassing project?”

Tip of the week: String slicing and splitting:

% f="path1/path2/file.ext"

% echo "${#f}"  # number of characters

# slicing: ${<var>:<start>} or ${<var>:<start>:<length>}
% echo "${f:6}"   # path2/file.ext
% echo "${f:6:5}" # path2
% echo "${f: -8}" # file.ext

# splitting
% echo "${f#*.}"       # "ext"
% echo "${f##*/}"       # "file.ext"
% echo "$(basename $f)" # "file.ext"
% echo "${f%/*}"         # "path1/path2"
% echo "$(dirname $f)"   # "path1/path2"
% echo "${f%%/*}"           # "path1"
Continue reading

2022-09-16

September 16, 2022

  1. dog: A command-line DNS client
  2. rich-cli: Command line toolbox for fancy output in the terminal

Article of the week: Building the future of the command line

“The cloud is really a whole lot of Unix machines,” Chu says. “And shell is still the best interface we have for the cloud.”

Tip of the week: Using shuf and xargs to create a simple dicware app:

  • /usr/share/dict/words is a builtin dictionary
  • shuf randomizes input
  • xargs executes a given command on each input (by default the command is echo)
# randomly select 5 words from the dictionary:
% shuf -n 5 /usr/share/dict/words

# join the output into one line:
% shuf -n 5 /usr/share/dict/words | xargs  # this is equivalent to `xargs -I{} echo {}`

# make multiple passphrases at once:
% shuf -n 15 /usr/share/dict/words | xargs -n 5

# change the delimeter from space to a character:
% shuf -n 5 /usr/share/dict/words | xargs | tr ' ' '-'
Continue reading

2022-09-09

September 9, 2022

  1. when: An extremely simple personal calendar program
  2. gh-dash: A beautiful CLI dashboard for GitHub

Article of the week: Yes, pgrep and pkill originally come from Solaris

Also, as long as I’m commenting again on this, I should point out that pkill also had an Easter egg of sorts: “pkill -V” was a shorthand for killing everyone’s least favorite Solaris daemon: vold.

Tip of the week: Using secrets securely when building container images:

A common pattern is keeping credentials in .npmrc or pip.conf to access private repositories. To prevent those credentials from being baked into the container image, use the mount option.

# pip example
...
RUN --mount=type=secret,id=pip_conf,dst=/etc/pip.conf pip install -r requirements.txt
...

# npm example
...
RUN --mount=type=secret,id=npmrc,dst=/etc/npmrc npm install
...

A manual build:

docker build --secret id=pip_conf,src=/path/to/pip.conf .
docker build --secret id=npmrc,src=/path/to/npmrc .

Building from Compose:

services:
  app:
    build:
      secrets:
        - pip_conf
        - npmrc
secrets:
  pip_conf:
    file: /path/to/pip.conf
  npmrc:
    file: /path/to/npmrc
Continue reading

2022-09-02

September 2, 2022

  1. xplr: A hackable, minimal, fast TUI file explorer
  2. bearings: A fast, clean, customisable shell prompt for zsh, bash, fish, and more…

Article of the week: ASCII and Unicode quotation marks

The old X fonts encouraged some authors of Unix software and documentation to abuse 0x60 together with 0x27 as directional quotation marks. This practice looked somewhat acceptable like ‛quotation’ if displayed with old X fonts, but it looked rather ugly like `quotation' in most other modern display environments.

Tip of the week: Edit long commands with a text editor in Zsh:

  1. Add the following lines to ~/.zshrc:

    export EDITOR=vim  # use your editor of choice, e.g. vim, nano, etc
    autoload -U edit-command-line  # loads the 'edit-command-line' function
    zle -N edit-command-line  # makes the function a Zsh widget
    bindkey <key> edit-command-line  # bind a key sequence to the widget
                                     # e.g. '^X^E' (ctrl x e), '\033' (esc)
                                     # use `bindkey` command to get a list
    
  2. Save, and reload the shell with exec zsh.
  3. Enter command line edit mode from the shell prompt using your chosen key shortcut.
Continue reading

2022-08-26

August 26, 2022

  1. shellharden: The corrective bash syntax highlighter
  2. sampler: Tool for shell commands execution, visualization and alerting

Article of the week: Unix legend, who owes us nothing, keeps fixing foundational AWK code

Kernighan, now 80, offhandedly mentions in the interview that he has also patched something “quick and dirty” to let AWK handle CSV files.

Tip of the week: Getting information about your system:

uptime # uptime
id # user information

pmset -g batt # macOS battery
cat /sys/class/power_supply/BAT0/{capacity,status} # Linux battery

sw_vers # macOS system info
cat /etc/os-release # Linux distro info

system_profiler # macOS system profile
dmidecode # Linux system profile

systemstats # macOS system stats
sysstat # Linux system stats

sudo softwareupdate -aiR # install macOS updates and reboot
Continue reading
Prev Next

Powered by Jekyll with Type Theme