Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View niedzielski's full-sized avatar
🥨

Stephen Niedzielski niedzielski

🥨
View GitHub Profile
@niedzielski
niedzielski / sos.sh
Last active June 23, 2020 14:16
Assemble Scrum of Scrums Notes
curl \
-sG \
-d o=TRACKING_IDS \
--data-urlencode q='(owner:niedzielski OR owner:sniedzielski OR owner:pmiazga OR owner:jdrewniak OR owner:jdlrobson OR owner:nray OR owner:phuedx OR owner:volkere) -age:1week -is:wip -message:wip' \
https://gerrit.wikimedia.org/r/changes/|
node -e '
JSON.parse(require("fs").readFileSync(0).toString("utf-8").substring(5))
.reduce((sum, val) => ([...sum, ...val.tracking_ids]), [])
.filter(({system}) => system === "Phab")
.map(({id}) => id)
@niedzielski
niedzielski / format-json.sh
Created January 26, 2019 01:33
Pretty-print a JSON string from stdin.
node -pe 'JSON.stringify(JSON.parse(require("fs").readFileSync(0)), null, 2)'
@niedzielski
niedzielski / ripgrep.sh
Created January 26, 2019 01:31
ripgrep example.
rg -g\!/resources/dist/ -g\!/i18n/ -g\!/tests/ -g\!/doc/ -t js foo
@niedzielski
niedzielski / find-not-owner-or-not-group.sh
Last active January 26, 2019 00:14
Find and change files not in the current user's group or ownership
# Find all files not in the current user ownership AND group.
sudo find "$DIR" -not \( -uid $(id -u) -gid $(id -g) \)
# Recursively change owner and group to current user.
sudo chown -R $(id -nu):$(id -ng) "$DIR"
@niedzielski
niedzielski / shred.sh
Created January 20, 2019 21:28
Obliterate disk contents.
sudo sg_map -i
df -h /dev/sdX*
time sudo shred -v /dev/sdX
@niedzielski
niedzielski / flac2mp3.bash
Created October 2, 2018 01:29
Convert FLACs to MP3s.
find -type f -iname \*.flac|
while IFS= read -r file; do
ffmpeg -v 24 -nostdin -i "$file" -ab 320k "${file%.flac}.mp3"
done
@niedzielski
niedzielski / upto.sh
Created September 30, 2018 18:59
Delete up to matching line.
sed '0,/^LINE$/ d'
@niedzielski
niedzielski / parse-args.bash
Last active September 29, 2018 04:51
The simplest possible bash argument parsing.
set -k
foo() { echo "$bar"; }
foo bar=baz
# prints baz
echo $bar
# prints nothing
@niedzielski
niedzielski / diff-stdin-x2.sh
Created April 29, 2018 17:54
Diff the output of two programs.
diff <(sed -r s%1%3%g a.txt) <(sed -r s%2%3%g b.txt)
@niedzielski
niedzielski / docker-login.sh
Created April 29, 2018 17:48
Login to a Docker container.
docker exec -it container bash