Skip to content

Instantly share code, notes, and snippets.

@antongorshkov
Last active September 29, 2016 00:14
Show Gist options
  • Save antongorshkov/b27a1837407a1d06b8fbfe5d2f90b679 to your computer and use it in GitHub Desktop.
Save antongorshkov/b27a1837407a1d06b8fbfe5d2f90b679 to your computer and use it in GitHub Desktop.

Send a file to Kafka

while true; do bin/kafka-console-producer.sh --broker-list $KAFKA --topic test2 < simple.json > k.out; done

Pick a random file and send to Kafka

while true; do bin/kafka-console-producer.sh --broker-list $KAFKA --topic test2 < "$(ls *100.json | shuf | head -1)" > k.out; done
while true; do ksend kafka1 < "$(ls *1e5 | shuf | head -1)" > k.out; done &

Search and Replace

sed 's/100/500/g' < pear.json  > pear100.json

Repeat a line a few times

while read line; do for i in {1..100}; do echo "$line"; done; done < apple.json  > apple100.json
cat peach.json | perl -ne 'print "$_" x1e2' > peach1e2

Random

ls | shuf | head -1
ls | sort -R | head -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment