mirror of
https://github.com/jbranchaud/til
synced 2026-01-16 13:38:02 +00:00
Compare commits
6 Commits
735d5b069d
...
723a33230c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
723a33230c | ||
|
|
c8445c45a9 | ||
|
|
497b0ff3b7 | ||
|
|
64df6d16d7 | ||
|
|
69917e4c93 | ||
|
|
c79e4c45bf |
@@ -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).
|
||||
|
||||
_1606 TILs and counting..._
|
||||
_1609 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||
@@ -327,6 +327,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Exclude A File From A Diff Output](git/exclude-a-file-from-a-diff-output.md)
|
||||
- [Excluding Files Locally](git/excluding-files-locally.md)
|
||||
- [Extend Git With Custom Commands](git/extend-git-with-custom-commands.md)
|
||||
- [Files With Local Changes Cannot Be Removed](git/files-with-local-changes-cannot-be-removed.md)
|
||||
- [Find And Remove Files That Match A Name](git/find-and-remove-files-that-match-a-name.md)
|
||||
- [Find The Date That A File Was Added To The Repo](git/find-the-date-that-a-file-was-added-to-the-repo.md)
|
||||
- [Find The Initial Commit](git/find-the-initial-commit.md)
|
||||
@@ -690,6 +691,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
### Mise
|
||||
|
||||
- [List The Files Being Loaded By Mise](mise/list-the-files-being-loaded-by-mise.md)
|
||||
- [Read Existing Dot Env File Into Env Vars](mise/read-existing-dot-env-file-into-env-vars.md)
|
||||
|
||||
### MongoDB
|
||||
|
||||
@@ -1539,6 +1541,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [File Type Info With File](unix/file-type-info-with-file.md)
|
||||
- [Find All Files Matching A Name With fd](unix/find-all-files-matching-a-name-with-fd.md)
|
||||
- [Find All Files With A Specific Extension With fd](unix/find-all-files-with-a-specific-extension-with-fd.md)
|
||||
- [Find All Tool Version Files Containing Postgres](unix/find-all-tool-version-files-containing-postgres.md)
|
||||
- [Find Any Dotfiles That Modify Path Env Var](unix/find-any-dotfiles-that-modify-path-env-var.md)
|
||||
- [Find A File Installed By Brew](unix/find-a-file-installed-by-brew.md)
|
||||
- [Find Duplicate Lines In A File](unix/find-duplicate-lines-in-a-file.md)
|
||||
|
||||
@@ -4,7 +4,7 @@ Sometimes when viewing a page, you realize you want to keep that page open
|
||||
but also go back to the previous page to view something else. An easy way of
|
||||
achieving this is to duplicate the current tab and then go back.
|
||||
|
||||
To duplicate the current tab hit `Cmd+Enter` while the focus is on the URL
|
||||
To duplicate the current tab, hit `Cmd+Enter` (macOS) or `Alt+Enter` (Windows) while the focus is on the URL
|
||||
bar.
|
||||
|
||||
If the URL bar is not in focus, then first hit `Cmd+L` to focus followed by
|
||||
|
||||
26
git/files-with-local-changes-cannot-be-removed.md
Normal file
26
git/files-with-local-changes-cannot-be-removed.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Files With Local Changes Cannot Be Removed
|
||||
|
||||
This is a nice quality-of-life feature in `git` that should help you avoid
|
||||
accidentally discarding changes that won't be retrievable.
|
||||
|
||||
```bash
|
||||
❯ git rm .tool-versions
|
||||
error: the following file has local modifications:
|
||||
.tool-versions
|
||||
(use --cached to keep the file, or -f to force removal)
|
||||
```
|
||||
|
||||
My `.tool-versions` file has some local changes. I don't realize that and I go
|
||||
to issue a `git rm` command on that file. Instead of quietly wiping out my
|
||||
changes, `git` lets me know I'm doing something destructive (these local
|
||||
changes won't be in the diff or the reflog).
|
||||
|
||||
I can force the removal if I know what I'm doing with the `-f` flag. Or I can
|
||||
take the two step approach of calling `git restore` on that file and then `git
|
||||
rm`.
|
||||
|
||||
The `--cached` flag is also interesting because it doesn't actually delete the
|
||||
file from my file system, but it does stage the file deletion with `git`. That
|
||||
means the file now shows up as one of my untracked files.
|
||||
|
||||
See `man git-rm` for more details.
|
||||
28
mise/read-existing-dot-env-file-into-env-vars.md
Normal file
28
mise/read-existing-dot-env-file-into-env-vars.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Read Existing Dot Env File Into Env Vars
|
||||
|
||||
Just about any web app that I've worked on has had a `.env` file as a way of
|
||||
configuring aspects of the app specific to that environment. These typically
|
||||
are read into the environment with a language-specific
|
||||
[dotenv](https://github.com/bkeepers/dotenv) tool.
|
||||
|
||||
Mise supports this convention. In addition to specifying individual non-secret
|
||||
env vars, you can also instruct `mise` to read-in a `.env` file like so:
|
||||
|
||||
```toml
|
||||
[env]
|
||||
PORT=3344
|
||||
_.file = ".env"
|
||||
```
|
||||
|
||||
The `_.file` line tells `mise` that there is a file `.env` with key-value pairs
|
||||
that it should read in. It can even handle `.env.json` and `.env.toml` file
|
||||
formats.
|
||||
|
||||
To ensure that `mise` is picking up the values from the `.env` file, you can
|
||||
run the following command and make sure they show up in the output:
|
||||
|
||||
```bash
|
||||
$ mise env
|
||||
```
|
||||
|
||||
[source](https://mise.jdx.dev/environments/secrets.html)
|
||||
38
unix/find-all-tool-version-files-containing-postgres.md
Normal file
38
unix/find-all-tool-version-files-containing-postgres.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Find All Tool Version Files Containing Postgres
|
||||
|
||||
I've been using [`asdf`](https://asdf-vm.com/) for many years now which means I
|
||||
have projects and directories all over my machine with `.tool-versions` files.
|
||||
Many of them specify Ruby and Node versions. Some of them also include
|
||||
PostgreSQL versions. I used to use `asdf` to manage Postgres versions, but no
|
||||
longer do that for new or active projects.
|
||||
|
||||
I want to find all the places that a `.tool-versions` file declares `postgres`
|
||||
as a tool. That way I can begin to clean up the left behind artifacts of
|
||||
asdf-managed Postgres.
|
||||
|
||||
By combining [`fd`](https://github.com/sharkdp/fd) (a better `find`) and
|
||||
[`rg`](https://github.com/BurntSushi/ripgrep) (a better `grep`), I'm able to
|
||||
quickly track down the list of places.
|
||||
|
||||
```bash
|
||||
$ fd --hidden .tool-versions ~/ | xargs rg postgres
|
||||
|
||||
/Users/jbranchaud/.local/state/nvim/undo/%Users%jbranchaud%.tool-versions: binary file matches (found "\0" byte around offset 9)
|
||||
|
||||
/Users/jbranchaud/code/fake-data/.tool-versions
|
||||
2:postgres 13.1
|
||||
|
||||
/Users/jbranchaud/code/thirty_days/thirty_days_server/.tool-versions
|
||||
1:postgres 13.1
|
||||
|
||||
/Users/jbranchaud/code/visualmode/.tool-versions
|
||||
1:postgres 11.11
|
||||
```
|
||||
|
||||
That first instance is a binary file as part of `nvim`'s undo history which I
|
||||
can ignore. The other three are good results.
|
||||
|
||||
I tell the `fd` command to not exclude hidden files as it looks for all
|
||||
occurrences of `.tool-versions` recursively from my home (`~/`) directory. I
|
||||
then pipe that list of files to `xargs` which makes those filenames arguments
|
||||
to the `rg postgres` command.
|
||||
Reference in New Issue
Block a user