Skip to content

Instantly share code, notes, and snippets.

@kphrx
Last active April 13, 2023 04:51
Show Gist options
  • Save kphrx/235aed622130055d67680956185633c2 to your computer and use it in GitHub Desktop.
Save kphrx/235aed622130055d67680956185633c2 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -s plc.jsonl ]; then
LATEST=$(tail -n1 plc.jsonl | jq -r '.createdAt')
echo "From: $LATEST; $(jq -s 'unique_by(.did) | length' plc.jsonl)"
curl -s https://plc.directory/export\?after\=$LATEST >> plc.jsonl
else
curl -s https://plc.directory/export >> plc.jsonl
fi
echo '' >> plc.jsonl
jq -Mcs 'sort_by(.createdAt, .did)' plc.jsonl | jq -Mc '.[]' > plc.jsonl.tmp
uniq plc.jsonl.tmp > plc.jsonl
rm -f plc.jsonl.tmp
echo "To: $(tail -n1 plc.jsonl | jq -r '.createdAt'); $(jq -s 'unique_by(.did) | length' plc.jsonl)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment