hystking / Yuhei Nakayama / gon

@hystking

Commit activity

41 commits in the last year

longest streak 30 dayscurrent 30

1,267 / 2,500 XP1,233 XP to root

Today

Yesterday

Watching a log through a grep filter and it sits silent?
tail -f app.log | grep --line-buffered ERROR
When grep's output is piped, it buffers, so matches arrive in chunks, if at all. --line-buffered flushes after every line.

Tue, Nov 17

Need a hotfix while mid-feature? Skip the stash dance:
git worktree add ../hotfix main
You get a second checkout of main in its own folder, sharing the same repo history. Fix it, push, then git worktree remove ../hotfix when you're done.

Mon, Nov 16

Fixed a typo in an old commit? Don't add a "fix typo" commit:
git commit --fixup <sha>
git rebase -i --autosquash <sha>~1
--autosquash moves the fixup directly under its target. Save the rebase and the typo vanishes from history.

Sun, Nov 15

Who wrote these lines? Ask git for just the range:
git blame -L 40,60 src/app.js
-C follows lines moved or copied from other files, so you find the original author, not the person who reformatted it.

Sat, Nov 14

Messy output with uneven columns? Line it up:
mount | column -t
column -t pads each field to the width of its widest entry, so any whitespace-separated output becomes a readable table. Pipe ps, df, or mount through it.

Fri, Nov 13

Compare two commands' output without temp files:
diff <(git show main:config.json) <(cat config.json)
The <(...) process substitution hands each command's output to diff as a file. Works in bash and zsh.

Thu, Nov 12

Wed, Nov 11

Need to find the commit that added or removed a string? Skip the log scroll:
git log -S "retryCount" --oneline
-S (the "pickaxe") lists commits where the number of occurrences of that string changed. Add -p to see the actual diff.

Tue, Nov 10

Check a URL's status code without downloading the body:
curl -s -o /dev/null -w "%{http_code}\n" https://example.com
-o /dev/null throws away the response, and -w prints only the format you ask for. It's handy for health checks in a loop.

Mon, Nov 9

Sun, Nov 8

Bash scripts fail quietly by default. Add this line near the top:
set -euo pipefail
-e exits on the first error, -u catches typos in variable names, and pipefail makes a pipeline fail if any stage fails, not just the last one.

Sat, Nov 7

Switched branches and want to jump back?
git switch -
Like cd -, it returns to the branch you checked out last. Run it again to toggle between the two.
Wait until you pair that with git merge - or git rebase -. The shorthand @{-1} works across almost every git command that takes a branch ref.

Fri, Nov 6

Filenames with spaces breaking your xargs pipeline?
find . -name "*.txt" -print0 | xargs -0 wc -l
-print0 ends each path with a null byte instead of a newline, and xargs -0 splits on that. Spaces and tabs in names are now harmless.
Pairing -print0 with xargs -0 or using find with -exec ... + is the only way to survive user-uploaded filenames that have spaces and quotes in them.

Thu, Nov 5

Which commit broke the tests? Let git find it:
git bisect start HEAD v1.4.0
git bisect run npm test
Git binary-searches the history and stops at the culprit. Exit code 0 is good, anything else is bad. Done? git bisect reset.

Wed, Nov 4

Port already in use? Find what's holding it and stop it:
lsof -ti :3000 | xargs kill
-t prints only the PIDs, so kill gets exactly what it needs. Swap in your port number. Handy for the "address already in use" moment.

Tue, Nov 3

Copy a file's contents to your clipboard on macOS, no selecting required:
pbcopy < notes.txt
Then Cmd+V anywhere. pbpaste goes the other way, dumping the clipboard to stdout. Pipe it into jq or grep and you're done.

Mon, Nov 2

Sun, Nov 1

Sat, Oct 31