💾 Archived View for 1436.ninja › Phlog › 20171215.post captured on 2020-10-31 at 01:02:44.
⬅️ Previous capture (2020-09-24)
-=-=-=-=-=-=-
# On a simple pastebin On the list of projects I have been kicking around in my mind, a simple pastebin has been high on the list. It struck me that since I live in ssh, a daemonized port dwelling beast was overkill. Then it hit me that everyone's webserver is an scp away.So a simple bash script to pipe to would suffice for pulling this off. Character encoding via the (granted, not totally accurate) hueristics of the file command and some simple css to state that we are using UTF-8 (the one true character encoding) was added. I started down the rabbithole of adding a width handler for output, then unix philosophy came slapping me in the face. If I needed width formatting I could pipe thru cut/fmt/fold. So here is my script, there are many like it, but this one is mine... #!/usr/bin/env bash while read line do a=$(echo -e "$a\n$line\n") done CHARSET="$(file -bi "$i"|awk -F "=" '{print $2}')" nam=$(date +%s) echo "<html><head><meta charset='UTF-8'><title>Leveck.us pastebin "\ "document $nam</title></head><body style='font-size: "\ "calc(16px + 1vw); line-height: calc(1.1em + 0.5vw);'><pre>"\ > /tmp/$nam echo "$a" | sed 's/&/\&/g; s/</\</g; s/>/\>/g;\ s/"/\"/g; s/'"'"'/\'/g' | iconv -f "$CHARSET" -t UTF-8 \ >> /tmp/$nam echo "</pre></body></html>" >> /tmp/$nam scp /tmp/$nam leveck@rpod:/var/www/html/pastebin rm /tmp/$nam echo -e "\n\nYour link:\nhttps://leveck.us/pastebin/$nam"