mirror of
https://github.com/jbranchaud/til
synced 2026-01-17 05:58:01 +00:00
Compare commits
4 Commits
76b8f46831
...
b49b730c81
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b49b730c81 | ||
|
|
f658a31435 | ||
|
|
db00ec69c2 | ||
|
|
bc767a0ad3 |
@@ -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).
|
||||
|
||||
_1534 TILs and counting..._
|
||||
_1536 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -317,6 +317,7 @@ _1534 TILs and counting..._
|
||||
- [Grab A Single File From A Stash](git/grab-a-single-file-from-a-stash.md)
|
||||
- [Grep For A Pattern On Another Branch](git/grep-for-a-pattern-on-another-branch.md)
|
||||
- [Grep Over Commit Messages](git/grep-over-commit-messages.md)
|
||||
- [Highlight Extra Whitespace In Diff Output](git/highlight-extra-whitespace-in-diff-output.md)
|
||||
- [Ignore Changes To A Tracked File](git/ignore-changes-to-a-tracked-file.md)
|
||||
- [Ignore Files Specific To Your Workflow](git/ignore-files-specific-to-your-workflow.md)
|
||||
- [Include A Message With Your Stashed Changes](git/include-a-message-with-your-stashed-changes.md)
|
||||
@@ -406,6 +407,7 @@ _1534 TILs and counting..._
|
||||
- [Not So Random](go/not-so-random.md)
|
||||
- [Parse A String Into Individual Fields](go/parse-a-string-into-individual-fields.md)
|
||||
- [Parse Flags From CLI Arguments](go/parse-flags-from-cli-arguments.md)
|
||||
- [Redirect File To Stdin During Delve Debug](go/redirect-file-to-stdin-during-delve-debug.md)
|
||||
- [Replace The Current Process With An External Command](go/replace-the-current-process-with-an-external-command.md)
|
||||
- [Sleep For A Duration](go/sleep-for-a-duration.md)
|
||||
- [Sort Slice In Ascending Or Descending Order](go/sort-slice-in-ascending-or-descending-order.md)
|
||||
|
||||
30
git/highlight-extra-whitespace-in-diff-output.md
Normal file
30
git/highlight-extra-whitespace-in-diff-output.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Highlight Extra Whitespace In Diff Output
|
||||
|
||||
When running a `git diff` (or `git add --patch`) I'll sometimes come across
|
||||
lines that don't have any visible changes. This is usually because some
|
||||
whitespace characters were either added (on accident) or removed (often by a
|
||||
autoformatter).
|
||||
|
||||
Depending on the `core.whitespace` config, you'll probably see at least some of
|
||||
the whitespace errors that git provides. By default, git only highlights
|
||||
whitespace errors on added (`new`) lines. However if some extra whitespace was
|
||||
originally committed and is now being removed, it won't be highlighted on the
|
||||
`old` line in the diff.
|
||||
|
||||
We can have git always highlight whitespace errors by setting
|
||||
`wsErrorHighlight` to `all` in the global git config.
|
||||
|
||||
```bash
|
||||
$ git config --global diff.wsErrorHighlight all
|
||||
```
|
||||
|
||||
Which updates the global gitconfig file with the following line:
|
||||
|
||||
```
|
||||
[diff]
|
||||
wsErrorHighlight = all
|
||||
```
|
||||
|
||||
The `all` option is a shorthand for `old,new,context`.
|
||||
|
||||
See `man git-diff` for more details.
|
||||
39
go/redirect-file-to-stdin-during-delve-debug.md
Normal file
39
go/redirect-file-to-stdin-during-delve-debug.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Redirect File To Stdin During Delve Debug
|
||||
|
||||
I have a go program that accepts input from stdin. The way I've been running
|
||||
the program as I develop it is to redirect the output of some sample files to
|
||||
the program.
|
||||
|
||||
```bash
|
||||
$ go run . < sample/001.txt
|
||||
```
|
||||
|
||||
When I then go to debug this program with
|
||||
[Delve](https://github.com/go-delve/delve), I'd still like to be able to
|
||||
redirect a file into the program to reproduce the exact behavior I'm seeing.
|
||||
|
||||
The following won't work:
|
||||
|
||||
```bash
|
||||
$ dlv debug . < samples/001.txt
|
||||
Stdin is not a terminal, use '-r' to specify redirects for the target process or --allow-non-terminal-interactive=true if you really want to specify a redirect for Delve
|
||||
```
|
||||
|
||||
Fortunately, `dlv` sees what I'm trying to do and makes a recommendation. The
|
||||
`-r` flag can be used to specify redirects for the target process. The [`dlv`
|
||||
redirect
|
||||
docs](https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_redirect.md)
|
||||
explain that `-r` can be passed a `source:destination`. The `source` is `stdin`
|
||||
by default, but can also be `stdout` and `stderr`.
|
||||
|
||||
I can redirect my file into the debugging session of my program like so:
|
||||
|
||||
```bash
|
||||
$ dlv debug . -r stdin:samples/001.txt
|
||||
```
|
||||
|
||||
Or even more succinctly:
|
||||
|
||||
```bash
|
||||
$ dlv debug . -r samples/001.txt
|
||||
```
|
||||
@@ -6,7 +6,7 @@ convert it using the `ebook-convert` binary from `Calibre`.
|
||||
First, install `Calibre`:
|
||||
|
||||
```bash
|
||||
$ brew cask install calibre
|
||||
$ brew install --cask calibre
|
||||
```
|
||||
|
||||
Then convert your ePub using `ebook-convert`:
|
||||
|
||||
Reference in New Issue
Block a user