Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbeam/981840 to your computer and use it in GitHub Desktop.
Save danbeam/981840 to your computer and use it in GitHub Desktop.
stdin-to-data-uri.sh
# lets you do echo 'lol' | todata
# or cat filename | todata
# and it'll spit out a nice data URI
todata() {
if [ ! -t 0 ]; then
php -r "echo 'data:text/plain;base64,'.base64_encode(file_get_contents('php://stdin')); }" && echo;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment