hystking / Yuhei Nakayama / gon

@hystking

Commit activity

55 commits in the last 6 months

longest streak 44 dayscurrent 44

1,652 / 2,500 XP848 XP to root

Today

Piping curl into sh without -f? A 404 page gets fed straight to your shell.
curl -fsSL https://example.com/install.sh | sh
-f fails on HTTP errors instead of printing the error page. -s hides progress, -S still shows errors, -L follows redirects.

Yesterday

Fixed a typo in an older commit? Don't add a new one:
git commit --fixup=<sha>
git rebase -i --autosquash <base>
--fixup marks the change for a specific commit. --autosquash moves it under that commit and folds it in.

Tue, Dec 1

Diffing two unsorted lists? Let the shell sort both sides on the fly:
diff <(sort old.txt) <(sort new.txt)
<(...) is process substitution. Each sort's output shows up as a file path, so diff reads them like ordinary files.

Mon, Nov 30

Sun, Nov 29

Lost commits after a bad reset or rebase? They're usually still there:
git reflog
git switch -c recovered <sha>
Reflog records every place HEAD has pointed, usually for weeks. Find the SHA of the lost commit, then point a new branch at it.

Sat, Nov 28

Fri, Nov 27

Thu, Nov 26

Bug somewhere in the last 200 commits? Let git hunt it down:
git bisect start HEAD v1.2.0
git bisect run ./test.sh
Exit 0 means good, non-zero means bad. Binary search finds the culprit in about 8 steps. Then git bisect reset.

Wed, Nov 25

Tue, Nov 24

Mon, Nov 23

Sun, Nov 22

Filenames with spaces breaking your xargs pipeline?
find . -name "*.log" -print0 | xargs -0 wc -l
-print0 ends each name with a NUL instead of a newline, and -0 tells xargs to split on NULs. Spaces, quotes, and even newlines in names are safe now.

Sat, Nov 21

Fri, Nov 20

Port 3000 already in use? Find out who's holding it:
lsof -nP -iTCP:3000 -sTCP:LISTEN
-iTCP:3000 filters to that port, and -sTCP:LISTEN keeps only the listeners. Grab the PID from the output and run kill <PID>.

Thu, Nov 19

Wed, Nov 18

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

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.