Use a graphical diff tool with Fossil

You can configure Fossil‘s gdiff command to launch your favorite graphical diff tool. Below are examples configuring some popular diff tools.

All the examples below include the --global option. If you want to configure this setting only for the current repository, omit that option.

Beyond Compare:

$ fossil settings --global gdiff 'bcomp'

Git:

$ fossil settings --global gdiff 'code --diff --wait'

vimdiff:

$ fossil settings --global gdiff 'vimdiff'

Visual Studio Code:

$ fossil settings --global gdiff 'code --diff --wait'

Resolve Fossil login failures after changing your password

After changing your password on a remote Fossil repository, you will receive login failures when trying to sync your local repository.

$ fossil sync
Sync with https://blachniet@example.com/test
Round-trips: 1   Artifacts sent: 0  received: 0
Error: login failed
Round-trips: 1   Artifacts sent: 0  received: 0
Sync done, sent: 420  received: 285  ip: 192.168.0.10

$ fossil commit
Autosync:  https://blachniet@example.com/test
Round-trips: 1   Artifacts sent: 0  received: 0
Error: login failed
Round-trips: 1   Artifacts sent: 0  received: 0
Pull done, sent: 446  received: 287  ip: 192.168.0.10
Autosync failed.
continue in spite of sync failure (y/N)?

The error occurs because your local repository is still trying to use your old password to sync with the remote.

To update the password in your local repository, run fossil sync <url>. When provided with a URL, this command will prompt you for a password. Enter your new password and instruct Fossil to save it.

$ fossil sync https://blachniet@example.com/test
password for blachniet:
remember password (Y/n)? Y
Round-trips: 1   Artifacts sent: 0  received: 0
Sync done, sent: 456  received: 305  ip: 192.168.0.10

Future syncs will use the new password.

Remove leaf and dependencies in Homebrew

A leaf in Homebrew is a formula that is not a dependency of another installed formula. You can list the currently installed leaves using the brew leaves command. See thoughtbot’s brew leaves post for more information on this command.

Removing a leaf in Homebrew can suddenly introduce many more leaves; the dependencies of the formula you removed. In this post I will show you how to remove a leaf as well as all its dependencies not used by any other formulae. These steps will work in Bash and Zsh.

Create a text file containing regex patterns for all the leaves. We’ll use this file later as input to grep.

$ brew leaves | xargs -I {} echo "^{}$" > leaves.txt

Edit leaves.txt, removing any that you want to uninstall.

Get the list of applications to remove, then remove them. Repeat this process until brew leaves | grep ... output is empty.

$ brew leaves | grep -v --file leaves.txt
gcc
$ brew remove gcc
Uninstalling /usr/local/Cellar/gcc/10.2.0_4... (1,465 files, 339.5MB)
$ brew leaves | grep -v --file leaves.txt
isl
libmpc
$ brew remove isl libmpc
Uninstalling /usr/local/Cellar/isl/0.23... (72 files, 5MB)
Uninstalling /usr/local/Cellar/libmpc/1.2.1... (13 files, 423.6KB)

Alternatively, you can perform the list and remove in one step:

$ brew leaves | grep -v --file leaves.txt | xargs brew remove
Uninstalling /usr/local/Cellar/mpfr/4.1.0... (29 files, 5.1MB)

Authenticate Cloud Vision Client in Go

Google’s Cloud Platform documentation is top of the line. Even with the documentation though, it took me some time to figure out how to use the Cloud Vision API from a Go application running on a Compute Engine instance. All the right information is there, but it’s scattered. Below I’ve compiled this information into a few steps.

Authenticating with the Cloud Vision API involves more setup than the Cloud Datastore, Cloud Pub/Sub and Cloud Storage. The client libraries for the latter use  Google Application Default Credentials and “just work” when running on a Compute Engine instance. In order to authenticate with the Cloud Vision API, you need to create a service account key and instruct the client library to use that key when sending API requests. See Authenticating to the Cloud Vision API for more details.

Prerequisites

Steps

  1. Enable the Cloud Vision API for your project: https://console.cloud.google.com/apis/api/vision.googleapis.com/overview
  2. If you haven’t already, create a JSON key for the service account running the Compute Engine instance: https://console.cloud.google.com/iam-admin/serviceaccounts/project. Click the dropdown beside the service account, click Create Key and select the JSON key type.
  3. Copy the key JSON file to your Compute Engine instance
  4. When creating the Vision API client in Go, provide the service account file with option.WithServiceAccountFile("/path/to/key.json"):
    visionClient, err := vision.NewImageAnnotatorClient(ctx, option.WithServiceAccountFile("/path/to/key.json"))
        if err != nil {
            return nil, nil, errors.Wrap(err, "Error creating vision client")
        }