1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 23:28:02 +00:00

Compare commits

...

4 Commits

Author SHA1 Message Date
nick-w-nick
4157e21dc6 Merge 295fe153ad into a547b9cee2 2025-04-02 13:26:13 -04:00
jbranchaud
a547b9cee2 Add Create A Filename With The Current Date as a Unix TIL 2025-04-02 09:26:38 -05:00
jbranchaud
99ce5aee7b Add Bypass On-Save Tooling When Writing File as a Vim TIL 2025-04-01 10:56:25 -05:00
nick-w-nick
295fe153ad added mention of ES6 compatibility
Hello, I've added a small blockquote below the description to indicate that this method of accessing an indefinite number of function arguments has been superseded by the use of the spread operator via rest parameters for ES6+ compatibility.
2022-01-06 11:39:04 -05:00
4 changed files with 73 additions and 1 deletions

View File

@@ -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).
_1632 TILs and counting..._
_1634 TILs and counting..._
See some of the other learning resources I work on:
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
@@ -1542,6 +1542,7 @@ If you've learned something here, support my efforts writing daily TILs by
- [Count The Number Of ripgrep Pattern Matches](unix/count-the-number-of-ripgrep-pattern-matches.md)
- [Count The Number Of Words On A Webpage](unix/count-the-number-of-words-on-a-webpage.md)
- [Create A File Descriptor with Process Substitution](unix/create-a-file-descriptor-with-process-substitution.md)
- [Create A Filename With The Current Date](unix/create-a-filename-with-the-current-date.md)
- [Create A Sequence Of Values With A Step](unix/create-a-sequence-of-values-with-a-step.md)
- [Curl With Cookies](unix/curl-with-cookies.md)
- [Curling For Headers](unix/curling-for-headers.md)
@@ -1700,6 +1701,7 @@ If you've learned something here, support my efforts writing daily TILs by
- [Breaking The Undo Sequence](vim/breaking-the-undo-sequence.md)
- [Buffer Time Travel](vim/buffer-time-travel.md)
- [Build And Install A Go Program](vim/build-and-install-a-go-program.md)
- [Bypass On-Save Tooling When Writing File](vim/bypass-on-save-tooling-when-writing-file.md)
- [Case-Aware Substitution With vim-abolish](vim/case-aware-substitution-with-vim-abolish.md)
- [Case-Insensitive Substitution](vim/case-insensitive-substitution.md)
- [Center The Cursor](vim/center-the-cursor.md)

View File

@@ -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);

View File

@@ -0,0 +1,38 @@
# Create A Filename With The Current Date
I was recently working on a script to pull a scrubbed database dump using the
`pg_dump` Postgres utility. Ultimately, the script does something like this to
dump a remote database to a local file:
```bash
pg_dump \
-h host.region.rds.amazonaws.com \
-U db_username \
-d db_name \
-F c \
-f scrubbed-database-$(date +%Y-%m-%d).dump
```
Notice the last part of that command where we define the name of the dump file.
It has a `$(...)` that is used to run and interpolate a command as part of the
filename.
Here is that `date` command run on its own:
```bash
$ date +%Y-%m-%d
2025-04-02
```
In the above command, that would mean if I were to run it today, I'd get
`scrubbed-database-2025-04-02.dump`.
This approach can be used with any command where you are producing a file that
you want to be dated or timestamped.
Here is another example that incorporates the time as well:
```bash
$ touch $(date +%Y%m%d_%H%M%S)-migration.sql
# => 20250402_092442-migration.sql
```

View File

@@ -0,0 +1,30 @@
# Bypass On-Save Tooling When Writing File
Every once in a while I run into an issue where my code formatters or linters
are misconfigured for a project. I try to save a file and it applies formatting
that I don't want. Or in an extreme case, the error ouput of the tool is what
overwrites the file.
I need to troubleshoot my dev tooling eventually, but I don't want to get
sidetracked at the moment. I just want to save the file. What can I do?
Tools like linters and code formatters are typically hooked up to Vim via
autocommands on certain actions like `FileWrite*` or `BufWrite*`. We can
execute a Vim command like writing a file (`w`) while disregarding autocommands
like so:
```vim
:noautocmd w
```
or, write and quit:
```vim
:noautocmd wq
```
This disables all autocommands for this one command. The file gets saved and
the misconfigured formatters and linters don't clobber the changes you
intended.
See `:h noautocmd` for more details.