mirror of
https://github.com/jbranchaud/til
synced 2026-01-07 09:08:01 +00:00
Compare commits
8 Commits
a8e58e82fb
...
197bd95dc4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
197bd95dc4 | ||
|
|
6ff8f19d08 | ||
|
|
14e6635383 | ||
|
|
0a0a509827 | ||
|
|
bb331577ca | ||
|
|
0e0dcbf2b4 | ||
|
|
fe9b62a631 | ||
|
|
295fe153ad |
15
README.md
15
README.md
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1589 TILs and counting..._
|
||||
_1593 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||
@@ -24,6 +24,7 @@ See some of the other learning resources I work on:
|
||||
* [Amplify](#amplify)
|
||||
* [Ansible](#ansible)
|
||||
* [Astro](#astro)
|
||||
* [AWS](#aws)
|
||||
* [Brew](#brew)
|
||||
* [Chrome](#chrome)
|
||||
* [Clojure](#clojure)
|
||||
@@ -97,10 +98,6 @@ See some of the other learning resources I work on:
|
||||
- [Case-Insensitive Search](ack/case-insensitive-search.md)
|
||||
- [List Available File Types](ack/list-available-file-types.md)
|
||||
|
||||
### Amplify
|
||||
|
||||
- [Sign Up User With Email And Password](amplify/sign-up-user-with-email-and-password.md)
|
||||
|
||||
### Ansible
|
||||
|
||||
- [Loop Over A List Of Dictionaries](ansible/loop-over-a-list-of-dictionaries.md)
|
||||
@@ -110,6 +107,11 @@ See some of the other learning resources I work on:
|
||||
- [Generate Types For A Content Collection](astro/generate-types-for-a-content-collection.md)
|
||||
- [Markdown Files Are Of Type MarkdownInstance](astro/markdown-files-are-of-type-markdown-instance.md)
|
||||
|
||||
### AWS
|
||||
|
||||
- [AWS CLI Requires Groff Executable](aws/aws-cli-requires-groff-executable.md)
|
||||
- [Sign Up User With Email And Password](aws/sign-up-user-with-email-and-password.md)
|
||||
|
||||
### Brew
|
||||
|
||||
- [Configure Brew Environment Variables](brew/configure-brew-environment-variables.md)
|
||||
@@ -216,6 +218,7 @@ See some of the other learning resources I work on:
|
||||
|
||||
- [Configure Different Host And Container Ports](docker/configure-different-host-and-container-ports.md)
|
||||
- [List Running Docker Containers](docker/list-running-docker-containers.md)
|
||||
- [Prevent Containers From Running On Startup](docker/prevent-containers-from-running-on-startup.md)
|
||||
- [Run A Basic PostgreSQL Server In Docker](docker/run-a-basic-postgresql-server-in-docker.md)
|
||||
|
||||
### Drizzle
|
||||
@@ -1316,6 +1319,7 @@ See some of the other learning resources I work on:
|
||||
- [Named Regex Captures Are Assigned To Variables](ruby/named-regex-captures-are-assigned-to-variables.md)
|
||||
- [Navigate Back In The Browser With Capybara](ruby/navigate-back-in-the-browser-with-capybara.md)
|
||||
- [Next And Previous Floats](ruby/next-and-previous-floats.md)
|
||||
- [OpenStruct Has Bad Performance Characteristics](ruby/open-struct-has-bad-performance-characteristics.md)
|
||||
- [Or Operator Precedence](ruby/or-operator-precedence.md)
|
||||
- [Output Bytecode For A Ruby Program](ruby/output-bytecode-for-a-ruby-program.md)
|
||||
- [Override The Initial Sequence Value](ruby/override-the-initial-sequence-value.md)
|
||||
@@ -1528,6 +1532,7 @@ See some of the other learning resources I work on:
|
||||
- [Find Newer Files](unix/find-newer-files.md)
|
||||
- [Find Occurrences Of Multiple Values With Ripgrep](unix/find-occurrences-of-multiple-values-with-ripgrep.md)
|
||||
- [Find Top-Level Directories Matching A Pattern](unix/find-top-level-directories-matching-a-pattern.md)
|
||||
- [Fix Shim Path After asdf Upgrade](unix/fix-shim-path-after-asdf-upgrade.md)
|
||||
- [Fix Unlinked Node Binaries With asdf](unix/fix-unlinked-node-binaries-with-asdf.md)
|
||||
- [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md)
|
||||
- [Generate A SAML Key And Certificate Pair](unix/generate-a-saml-key-and-certificate-pair.md)
|
||||
|
||||
30
aws/aws-cli-requires-groff-executable.md
Normal file
30
aws/aws-cli-requires-groff-executable.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# AWS CLI Requires Groff Executable
|
||||
|
||||
I have the AWS CLI installed on this machine, but when I went to run certain
|
||||
commands like `aws logs tail my_log_group` or even `aws logs tail help`, I'd
|
||||
get the following error:
|
||||
|
||||
```
|
||||
$ aws logs tail help
|
||||
|
||||
Could not find executable named 'groff'
|
||||
```
|
||||
|
||||
This may only be an issue on MacOS Ventura for older versions of the CLI, per
|
||||
[this PR](https://github.com/aws/aws-cli/pull/7413):
|
||||
|
||||
> The CLI's help commands are currently broken on macOS Ventura because Ventura has replaced groff with mandoc. This PR fixes the issue by falling back on mandoc if groff doesn't exist in the path.
|
||||
|
||||
There are two ways of dealing with this. One would be to install the missing
|
||||
dependency, [`groff`](https://www.gnu.org/software/groff/):
|
||||
|
||||
```bash
|
||||
$ brew install groff
|
||||
```
|
||||
|
||||
The other is to update the AWS CLI to one that falls back to `mandoc`.
|
||||
Depending on how you originally installed the AWS CLI, you can either [follow
|
||||
their official install/upgrade
|
||||
instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html),
|
||||
`pip install --upgrade awscli`, or upgrade view homebrew (`brew upgrade
|
||||
awscli`).
|
||||
53
docker/prevent-containers-from-running-on-startup.md
Normal file
53
docker/prevent-containers-from-running-on-startup.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Prevent Containers From Running On Startup
|
||||
|
||||
I have a bunch of docker containers managed by Docker Desktop. Some are related
|
||||
to projects I'm actively working on. Whereas many others are inactive projects.
|
||||
|
||||
When I restart my machine, regardless of which containers I had running or
|
||||
turned off, several of them are booted into a running state on startup. This is
|
||||
becaue their restart policy is set to `always`. That's fine for the project I'm
|
||||
actively working on, but the others I would like to be _off_ by default.
|
||||
|
||||
I need to update each of their restart policies from `always` to `no`.
|
||||
|
||||
First, I need to figure out their container IDs:
|
||||
|
||||
```bash
|
||||
$ docker ps --all
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
eb7b40aeba2d postgres:latest "docker-entrypoint.s…" 3 months ago Up 11 minutes 0.0.0.0:9875->5432/tcp still-postgres-1
|
||||
eb9ab2213f2b postgres:latest "docker-entrypoint.s…" 3 months ago Exited (0) 11 minutes ago next-drizzle-migration-repro-app-postgres-1
|
||||
ba792e185734 postgres:latest "docker-entrypoint.s…" 4 months ago Up 11 minutes 0.0.0.0:9876->5432/tcp better_reads-postgres-1
|
||||
3139f9beae76 postgres:latest "docker-entrypoint.s…" 9 months ago Exited (128) 7 months ago basic-next-prisma-postgres-1
|
||||
```
|
||||
|
||||
Referencing the `CONTAINER ID` and `NAMES` columns, I'm able to then inspect
|
||||
each container and see the current `RestartPolicy`:
|
||||
|
||||
```bash
|
||||
$ docker inspect eb9ab2213f2b | grep -A3 RestartPolicy
|
||||
"RestartPolicy": {
|
||||
"Name": "always",
|
||||
"MaximumRetryCount": 0
|
||||
},
|
||||
```
|
||||
|
||||
I can then update the `RestartPolicy` to be `no`:
|
||||
|
||||
```bash
|
||||
$ docker update --restart no eb9ab2213f2b
|
||||
```
|
||||
|
||||
Inpsecting that container again, I can see the updated policy:
|
||||
|
||||
```bash
|
||||
$ docker inspect eb9ab2213f2b | grep -A3 RestartPolicy
|
||||
"RestartPolicy": {
|
||||
"Name": "no",
|
||||
"MaximumRetryCount": 0
|
||||
},
|
||||
```
|
||||
|
||||
Rinse and repeat for each of the offending containers.
|
||||
|
||||
[source](https://stackoverflow.com/questions/45423334/stopping-docker-containers-from-being-there-on-startup)
|
||||
@@ -5,6 +5,8 @@ an array-like object with all of the arguments to the function. Even if not
|
||||
all of the arguments are referenced in the function signature, they can
|
||||
still be accessed via the `arguments` object.
|
||||
|
||||
> For ES6+ compatibility, the `spread` operator used via [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) is preferred over the `arugments` object when accessing an abritrary number of function arguments.
|
||||
|
||||
```javascript
|
||||
function argTest(one) {
|
||||
console.log(one);
|
||||
|
||||
32
ruby/open-struct-has-bad-performance-characteristics.md
Normal file
32
ruby/open-struct-has-bad-performance-characteristics.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# OpenStruct Has Bad Performance Characteristics
|
||||
|
||||
The Ruby docs for `OpenStruct` have a [_Caveats_
|
||||
section](https://ruby-doc.org/3.4.1/stdlibs/ostruct/OpenStruct.html#class-OpenStruct-label-Caveats)
|
||||
that warns about the poor performance characteristics of `OpenStruct` relative
|
||||
to `Struct` and `Hash`.
|
||||
|
||||
> This should be a consideration if there is a concern about the performance of
|
||||
> the objects that are created, as there is much more overhead in the setting
|
||||
> of these properties compared to using a Hash or a Struct. Creating an open
|
||||
> struct from a small Hash and accessing a few of the entries can be 200 times
|
||||
> slower than accessing the hash directly.
|
||||
|
||||
This doesn't mean don't use `OpenStruct`, but do be aware of if you are using
|
||||
it in a hot path or if you are allocating and processing tons of them.
|
||||
|
||||
If you turn on _Performance Warnings_ in Ruby, you'll see a warning message
|
||||
when allocating an `OpenStruct`.
|
||||
|
||||
```ruby
|
||||
> require 'ostruct'
|
||||
=> true
|
||||
> os1 = OpenStruct.new
|
||||
=> #<OpenStruct>
|
||||
> Warning[:performance] = true
|
||||
=> true
|
||||
> os2 = OpenStruct.new
|
||||
(irb):6: warning: OpenStruct use is discouraged for performance reasons
|
||||
=> #<OpenStruct>
|
||||
```
|
||||
|
||||
[source](https://www.reddit.com/r/ruby/comments/1d54mwl/comment/l6jgn59/)
|
||||
34
unix/fix-shim-path-after-asdf-upgrade.md
Normal file
34
unix/fix-shim-path-after-asdf-upgrade.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Fix Shim Path After asdf Upgrade
|
||||
|
||||
While doing [`brew install groff`](aws/aws-cli-requires-groff-executable.md),
|
||||
Homebrew decided to upgrade every last thing it knows about on my machine,
|
||||
including `asdf`.
|
||||
|
||||
`asdf` has undergone some big recent changes, including [a rewrite in
|
||||
Go](https://stratus3d.com/blog/2025/02/03/asdf-has-been-rewritten-in-go/).
|
||||
|
||||
I noticed that `asdf` wasn't picking up my specified tool versions. I tried an
|
||||
`asdf reshim`, but that didn't do the trick. Someone else wrote that [asdf
|
||||
seems broken after homebrew
|
||||
upgrade](https://braytonium.com/2023/01/09/asdf-seems-broken-after-homebrew-upgrade/)
|
||||
which gave some hints and pointed me to some interesting GitHub issues.
|
||||
|
||||
Additionally, I noticed when opening a fresh terminal session the following error from `zsh`:
|
||||
|
||||
```bash
|
||||
/Users/jbranchaud/.zshrc:.:225: no such file or directory: /usr/local/opt/asdf/libexec/asdf.sh
|
||||
```
|
||||
|
||||
That directory and file is gone. So, how does `asdf` now want you to configure
|
||||
its path with `zsh`? Revisiting their updated docs, I can see that the instead
|
||||
of sourcing that shell script, we should now export shims to the path:
|
||||
|
||||
```bash
|
||||
# . /usr/local/opt/asdf/libexec/asdf.sh
|
||||
export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"
|
||||
```
|
||||
|
||||
Updating my `.zshrc` to the above and then reloading did the trick. My tool
|
||||
versions are registering now.
|
||||
|
||||
[source](https://asdf-vm.com/guide/getting-started.html#_2-configure-asdf)
|
||||
Reference in New Issue
Block a user