Skip to content

Instantly share code, notes, and snippets.

@horttanainen
Last active March 8, 2019 10:02
Show Gist options
  • Save horttanainen/1b9326f61c16b6bb52b4008e3ede11e2 to your computer and use it in GitHub Desktop.
Save horttanainen/1b9326f61c16b6bb52b4008e3ede11e2 to your computer and use it in GitHub Desktop.
Script to serve piped text indefinitely
#!/usr/bin/env bash
node -e 'var http = require("http"); var fs = require("fs"); process.stdin.resume(); process.stdin.setEncoding("utf8"); var data = ""; process.stdin.on("data", function(buf) { data += buf; }); process.stdin.on("end", function() { http.createServer(function (request, response) { response.writeHead(200); response.write(data); response.end(); }).listen(8989); });'
@horttanainen
Copy link
Author

horttanainen commented Mar 8, 2019

Add the snippet in your .bashrc

alias sutf8='sh ~/.scripts/serve-utf8.sh'

Try it out:

echo perkele | sutf8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment