Rick Cogley's Tech Logr

Short Technical Laser Bursts %%

Welcome

Here be my pithy, short, technical nuggets. Maybe I’m the only one who cares. Who says Hugo can’t be used for microblogging‽

15 Nov 2020

«22:03:26»

Devs, if you upgraded to MacOS Big Sur and use brew, you might need to manually uninstall and re-install «CLT» Command Line Tools. It does appear in Software Update, but just updating Xcode there does not do it. 😅

Here are the simple steps you can take in your term:

1
2
sudo rm -rf /Library/Developer/CommandLineTools/
sudo xcode-select --install

Once you run the second install line, it will popup a dialog box to agree to and off you go. Go have a coffee, as it is a large download.

N.b.: if you stumbled on this and don’t know what to do, you can run the above in Terminal.app. You can copy paste in the first line, press enter, then because the command uses sudo you’ll need to enter your MacOS login password. The password you enter will still be effective for the second line, which pops up a disclaimer to agree to. When you agree, it will do the needful and reinstall.

RC Logr 20201115 220326 - Devs, if you upgraded to MacOS … Rick Cogley

12 Nov 2020

«15:24:07»

Macs with the new M1 chip from Apple are limited in external monitor support. People will be expecting a Macbook Pro to support 2 or more external displays but it supports only 1. 😒

RC Logr 20201112 152406 - Macs with the new M1 chip from … Rick Cogley

02 Nov 2020

«16:38:43»

«Dasel» is an open source DAta SELector program that allows you to query and modify data structures from JSON, YAML, TOML and XML, similar to jq and yq. It is written in go, so it has zero runtime dependencies. 🤩

If you look at the repo readme, it seems like it would be fairly trivial to convert from jq to dasel in many cases, and it also replaces some obscure jq syntax with more verbose syntax that might be a tad easier to grok.

RC Logr 20201102 163842 - «Dasel» is an open source DAta … Rick Cogley

15 Oct 2020

«10:56:57»

I have not used it yet, but «Vale», a cross-platform command-line linter for prose, looks really sweet. Will set up a .vale.ini in a project and give it a whirl. 🌀

RC Logr 20201015 105657 - I have not used it yet, but … Rick Cogley

18 Aug 2020

«13:27:12»

Learned about the sweet free and open source «@Asciinema» service today, which lets you record your terminal sessions for sharing. Read on for a few tips. 🤩

  • Create an account at https://asciinema.org by supplying an email, click on the link in an email you will receive to create an account, then give yourself a username. This creates a profile URL like: https://asciinema.org/~rickcogley
  • If you use macOS and brew, install with brew install asciinema. ASCII Cinema, get it?
  • Run asciinema auth and open the link that appears in the terminal, in the browser where you are logged into asciinema. This links your localhost with your account, so when you make a screen recording on that host, it will be linked and appear when you are logged in. You can see what localhosts are linked in the “recorder tokens” section in Settings in the web app:
1
2
3
Recorder tokens
The following recorder tokens have been associated with your account:
    c06f7b2a-22af-4b05-9abb-e1c2345d4321 registered on Tue, 18 Aug 2020 04:19:44 Z - Revoke
  • Record a session by issuing asciinema rec -t "Title of the Session" changing the title to taste. Press ctrl-D to exit, and you’ll get a message like:
1
2
3
4
5
6
7
asciinema: recording finished
asciinema: press <enter> to upload to asciinema.org, <ctrl-c> to save locally

View the recording at:
    https://asciinema.org/a/UzPY3BQvQ8NkBJffOEn7T6hYq

user=86.94s system=68.94s cpu=69% total=3:44.77
  • You can download the “cast” files for sharing, as well. They are tiny, compared to video screencasts.
1
2
3
 $ ll 345381.cast
 Permissions Size User    Group Date Modified    Name
 .rw-r--r--@  87k rcogley staff 2020-08-18 14:45 345381.cast

RC Logr 20200818 132712 - Learned about the sweet free … Rick Cogley

10 Aug 2020

🗓 "Mountain Day" in Japan

«18:08:31»

If you have a json config file and want to see what it looks like in yaml format, the utility site json2yaml makes trivial work of this. Nice! 🤖

RC Logr 20200810 180831 - If you have a json config file … Rick Cogley

30 Jul 2020

«11:34:44»

If you make a mistake and enter sensitive information in your zsh prompt, it is saved in history. Since you do not want that info sitting around in a plain text file, simply edit $HISTFILE to get rid of the offending line, then use fc -R to reload the history file. 😎

A couple of tips:

  • zsh history is often kept in ~/.zsh_history but that path can be confirmed by doing echo $HISTFILE.
  • your ~/.zsh_history might be massive, but vim can load it without trouble. Assuming you have vim, open the history file with vim ~/.zsh_history, press esc, then use shift + G to jump to the end of the file. Delete the offending line with D then save with :wq.
  • if you confirm with history it will show the unneeded line still, so do the fc -R to reload the history file you just edited and saved.

RC Logr 20200730 113444 - If you make a mistake and … Rick Cogley

21 Jul 2020

«19:58:46»

If you want to autosign git commits on Mac, there are a couple of tricks to it. I have not been able to get brew gpg to work consistently well, but installing from gpgtools.org seems to be able to be made to work. 🤖 This worked for me:

  1. Install GPGTools from https://gpgtools.org
  2. Create / import a key, then run gpg --list-secret-keys to find the sec key fingerprint
  3. Make git settings, specifying the signing key as the fingerprint with no spaces:
1
2
3
4
% git config --global gpg.program /usr/local/MacGPG2/bin/gpg2
% git config --global user.signingkey 54EF87etc02B 
% git config --global commit.gpgsign true 
% git config --global tag.forceSignAnnotated true
  1. If you want to autocommit to GitHub, open https://github.com/settings/keys and add the same public gpg key there. This links signed commits you make locally, once you push to master on the remote.
  2. Edit ~/.gnupg/gpg-agent.conf and add this line:
1
 pinentry-program /usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac

I had the brew version installed, and this was set to call /usr/local/bin/pinentry-mac, but the brew version is an older version. You can see that the pinentry-mac binary is being called from within an app bundle.

1
2
3
4
% /usr/local/bin/pinentry-mac --version
  pinentry-mac (pinentry) 0.9.4
% /usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac --version
  pinentry-mac (pinentry) 1.1.0
  1. Edit ~/.gnupg/gpg.conf and add this line:
1
no-tty

You can relogin with exec $SHELL --login, and reload the agent with gpgconf --kill gpg-agent.

It may work now.

RC Logr 20200721 195846 - If you want to autosign git … Rick Cogley

«08:52:28»

If you like Sudoku, you might also like «Hexologic», by Mythic Owl. ⬡

六角論理 in Japanese.

RC Logr 20200721 085228 - If you like Sudoku, you might … Rick Cogley

20 Jul 2020

«21:12:27»

«Zsh for Humans» (z4h by @romkatv on GitHub) is a configuration for z-shell that just works and works well. It has a killer ssh wrapper feature, that lets you auto-push your zsh environment up to a remote server, and is pre-configured with the most useful stuff. So sweet. 😎

That is not to even mention the awesome prompt it includes: powerlevel10k.

Use the ssh wrapper like this:

1
% z4h ssh myuser@thehost.com

If you are on MacOS, be sure to tweak some settings in your term so the bindings work as expected:

  • iTerm2:
    • iTerm, Prefs, Profiles (select your profile), Keys, then…
    • Right/Left option key: Esc+
  • Kitty:
    • in the config file: macos_option_as_alt yes

Now you can enter a command like history and before hitting Enter, press Alt-H to show help for that command.

RC Logr 20200720 211227 - «Zsh for Humans» (z4h by … Rick Cogley

19 Jul 2020

«18:10:54»

Today I sat and replaced cat with «bat». Bat is a fast (written in Rust) cat clone with syntax highlighting for programming and markup languages, integration with your $PAGER, and git index awareness. 🔥

Set defaults in a config stored in ~/.config/bat/config, which looks something like:

1
2
3
4
5
--theme="Dracula"
--style="numbers,changes,header"
--paging=always
--pager="less --quit-if-one-screen --tabs=1"
--show-all

I use most as my $PAGER and it appears to not play well with bat, so, setting the --pager in the config was required.

RC Logr 20200719 181054 - Today I sat and replaced cat … Rick Cogley

18 Jul 2020

«20:33:03»

«Exa» (@dot_slash_exa) is a superb modern and fast ls replacement that supports colors, file and filesystem info, tree view, git info, and wide view. You have plenty of compute power, so why not take advantage of it and use something better than ls. 🤖💌

It’s easily installed on mac (brew install exa) or linux (e.g. on fedora sudo dnf install exa).

Try:

1
2
3
4
5
6
7
% exa --long
% exa --classify
% exa --header --long --list-dirs
% exa -lh -t=mod --time-style=long-iso 
% exa --tree --level=2
% exa --long --git
% exa --long --extended some_pdf.pdf

RC Logr 20200718 203303 - «Exa» (@dot_slash_exa) is a … Rick Cogley

14 Jul 2020

«15:59:07»

Interesting project by Owen Ou «Upterm» (@owenthereal) is written in Go and makes remote pair programming or debugging, or simply accessing computers behind firewalls, a bit easier.

RC Logr 20200714 155907 - Interesting project by Owen Ou … Rick Cogley

10 Jul 2020

«18:32:08»

One way to hide the contents of a file, e.g. one containing environment variables containing secrets, is to use gpg symmetric encryption, which meb7 ans encrypt and decrypt use the same secret. It is convenient, and you can supply the secret when you need it. 🤖

For example:

1
2
3
4
5
% gpg --symmetric --cipher-algo TWOFISH /path/to/vars.txt
  Password: ********
  Re-enter: ********
% gpg --output /path/to/working/vars.txt --decrypt /path/to/vars.txt.gpg
  Password: ********

The encrypt command will create a file vars.txt.gpg and if you list its contents you will see they are encrypted.

RC Logr 20200710 183207 - One way to hide the contents … Rick Cogley

06 Jul 2020

«06:07:12»

Trying a different zsh plugin system, «zplug». It is super simple and flexible, and I am testing out «liquidprompt» prompt with it (morphy goodness). So far I like this combo a lot. 🤩

You install zplug like this:

1
% curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh

Enable and configure it in your ~/.zshrc using some of the examples provided:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Source zplug
source ~/.zplug/init.zsh

# Make sure to use double quotes
zplug "zsh-users/zsh-history-substring-search"

# Grab binaries from GitHub Releases
# and rename with the "rename-to:" tag
zplug "junegunn/fzf-bin", \
    from:gh-r, \
    as:command, \
    rename-to:fzf, \
    use:"*darwin*amd64*"

# Supports oh-my-zsh plugins and the like
zplug "plugins/git",   from:oh-my-zsh

# Liquidprompt
zplug "nojhan/liquidprompt"

# Load if "if" tag returns true
zplug "lib/clipboard", from:oh-my-zsh, if:"[[ $OSTYPE == *darwin* ]]"

# Group dependencies
# Load "emoji-cli" if "jq" is installed in this example
zplug "stedolan/jq", \
    from:gh-r, \
    as:command, \
    rename-to:jq
zplug "b4b4r07/emoji-cli", \
    on:"stedolan/jq"
# Note: To specify the order in which packages should be loaded, use the defer
#       tag described in the next section

# Set the priority when loading
# e.g., zsh-syntax-highlighting must be loaded
# after executing compinit command and sourcing other plugins
# (If the defer tag is given 2 or above, run after compinit command)
zplug "zsh-users/zsh-syntax-highlighting", defer:2

# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
    printf "Install? [y/N]: "
    if read -q; then
        echo; zplug install
    fi
fi

# Then, source plugins and add commands to $PATH
zplug load --verbose

# Self manage
zplug 'zplug/zplug', hook-build:'zplug --self-manage'

Except for liquidprompt, those are just copy-pasted from the docs. Then restart your terminal and answer the install prompts to install the plugins. Sweet zsh goodness. Thanks to Masaki Ishiyama for coding up a great system https://twitter.com/b4b4r07.

liquidprompt screenshot

RC Logr 20200706 060711 - Trying a different zsh plugin … Rick Cogley

27 Jun 2020

«10:38:37»

If you are using the aws cli tool, you can set the shell env var «AWS_PROFILE» to match your setup profile names linking to specific IAM credentials. 🍺 Here it is in a zsh function.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
function hugodeploy-coolsite (){
    echo "====== Deploy coolsite.jp site to AWS S3 ======"
    _hugobin="$HOME/gocode/bin/hugo"
    _awsbin="/usr/local/bin/aws"
    _workingdir="$HOME/dev/coolsite.jp"
    _current_aws_profile="$AWS_PROFILE"
    cd ${_workingdir}
    export AWS_PROFILE="deploy-coolsite"
    echo "🍺 Confirm aws profile via \"aws configure list\""
    ${_awsbin} configure list
    echo "🍺 Build and deploy site"
    ${_hugobin} && ${_hugobin} deploy --invalidateCDN --target coolsitejp --verbose
    [[ -z "$_current_aws_profile" ]] && unset AWS_PROFILE || export AWS_PROFILE=${_current_aws_profile}
}

This function sets some local vars, sets AWS_PROFILE via export then confirms it is set, then builds and deploys the site via hugo and hugo deploy. The site has a config file with the “coolsitejp” target, and under that is specified which AWS S3 bucket to deploy to. Use export instead of a simple assignation like I am doing with _hugobin etc, because you want to have the variable ready for use when the script invokes hugo to build and deploy the site. The last line unsets AWS_PROFILE for good measure if it was not set already, or resets it to whatever it was set to initially.

RC Logr 20200627 103837 - If you are using the aws cli … Rick Cogley

25 Jun 2020

«09:09:30»

If you have AirPods Pro headphones there is a firmware update (from 2D15 to 2D27) with no details on what it does. How to update? 🤔 Nobody can say.

Apparently, if you listen to music for a minute or so, then put the headphones in their charger and connect to power, they update in a few minutes. It may be voodoo majick but it worked for me.

Confirm the before and the after:

  1. Connect to your iOS device.
  2. Open Settings, then go to General -> About.
  3. Find your AirPods and tap the name.
  4. Find the firmware version. (Take a screenshot which on my XS is: press big right button and volume up button simultaneously)

RC Logr 20200625 090929 - If you have AirPods Pro … Rick Cogley

«08:48:15»

I connected a new ELECOM WRC-X3000GS broadband router that supports «Wi-fi 6», or IEEE 802.11ax via an Intel WAV600 chipset, with high hopes for 9.6 Gbps goodness. It connected to my Docomo hikari line without any settings (convenient!) but kept dropping the connection. 👺 A call to Elecom support solved it straight away.

The support professional suspected she knew what it was, and had me check the PPP LED on the unit. It was off. She asked if I had entered the ISP credentials and I said no, it just connected. She told me that that kind of connection is kind of a test mode and recommended I check my ISP information again for login information. She directed me where to enter it, and sure enough, once I did that, the unit is stable and fast.

Still, I find it really odd that the installer would not mention this important fact. The Amazon reviews section is full of people grousing about how bad the router is and that it drops its connection, so I bet others are getting hit with this same thing and just giving up.

RC Logr 20200625 084815 - I connected a new ELECOM … Rick Cogley

«05:42:37»

Google released a way to automatically delete the data it stores on you more frequently. Log in to https://myaccount.google.com/data-and-personalization and find Auto-delete in «Activity Controls». 😌

You can set the auto-deletion period as short as 3 months, and the setting is separate for web and app, location and YouTube history.

RC Logr 20200625 054237 - Google released a way to … Rick Cogley

16 Jun 2020

«09:58:55»

Simon Fredsted @fredsted has been prolifically releasing new features for his fantastic webhook utility site https://docs.webhook.site/news.html. 🤖🦾 Now manipulate CSVs, upload to S3, ping Slack and Discord, schedule actions.

Some usage ideas:

  • Schedule sync of information between systems A and B
  • Receive jpg by email, upload to AWS S3 bucket
  • React to Slack “slash command”
  • Receive a CSV via web form, manipulate and upload it to a data table via REST
  • Receive inputs via web form, append to Google Sheet

Get the paid version; it’s well worth it.

Update for https://logr.cogley.info/2020/03/17/1584405754/

RC Logr 20200616 095855 - Simon Fredsted @fredsted has … Rick Cogley