This Week I Googled: git remote set-url, group permissions, docker, untaint, gem uninstall

This is a series of open notes on things I didn’t have committed to memory that hopefully gives some useful tidbits and also potentially alleviates any impostor syndrome as a software engineer.

How to change the remote URL on a git repository

I often end up cloning a git repository either without write permissions to it or just accidentally copying the https version of the clone URL. I’ve generally been too lazy to look up or refresh my memory on how to change the URL and just re-cloning, but recently, I’ve ended up with changes that I don’t just abandon.

git remote set-url origin new.git.url/here

How do I change the default group upon file modification and creation? (the syntax is actually wrong here). The following sets the group of project directory to ourpgroup (chgrp) and then chmod g+s sets the SGID bit on the project directory so that any new files will have the group assignment of the group owner. (See: Linux permissions: SUID, SGID, and sticky bit for more)

chgrp ourpgroup project
chmod g+s project

How to get change time for a file via ruby

I wanted to compare build logs from two different runs (using gvimdiff in my case) after processing them through a filter to strip out timestamps and identifiers that change from run to run, but I couldn’t remember how to get a modified or creation time. Note: This value can mean slightly different things depending on the operating system on which Ruby is running.


# get last two log files in macOS Downloads
# note ctime is creation time in Windows
Dir.glob("#{ENV['HOME']}/Downloads/*.log").sort { |a,b| File.ctime(a) <=> File.ctime(b) }.last(2)

Docker ps and run vs. docker container

docker container ls (docker ps) and docker container run (docker run) … see docker container reference

Multiple version constraints in Gemfile

Work with Multiple Version Constraints · Issue #930 – an old bundler issue from 2012, opened by a member of sous-chefs

Looks like it got added eventually: What is the syntax to specifing multiple gem constraints in a Rails Gemfile? … the answer is Use arrays or just list it out:

gem 'rbnacl', ['>= 3.2', '< 5.0']
gem 'bcrypt_pbkdf', '>= 1.0', '< 2.0'

Load library path in Unix and ruby

export LD_LIBRARY_PATH=/library/path

configure: error: cannot compute sizeof (long long) on AIX

Untaint method in Ruby

taint and untaint were a feature of Ruby for marking input from untrustworthy sources. As of Ruby 2.7, it was made a NOOP call. As of Ruby 3.2, the method has been removed from Object, so you might now be getting errors if upgrading to Ruby 3.2 (from your dependencies)

Mark the object as tainted.

Objects that are marked as tainted will be restricted from various built-in methods. This is to prevent insecure data, such as command-line arguments or strings read from Kernel#gets, from inadvertently compromising the user’s system.

To check whether an object is tainted, use #tainted?.

You should only untaint a tainted object if your code has inspected it and determined that it is safe. To do so use #untaint. – made NOOP in Ruby 2.7 – Remove $SAFE, taint and trust (Ruby 3.2) … this will require a bundler >= 2.1 per

Remove versions of old gems to a specification

The following command will uninstall a gem matching the version specification provided. However, it appears to only uninstall one version at a time, even if you pair --all with it.

gem uninstall bundler --version '< 2.1'

Leave a Reply

%d bloggers like this: