💾 Archived View for 1436.ninja › Phlog › gmi › 20171215.gmi captured on 2024-03-21 at 16:21:59. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-09-08)

-=-=-=-=-=-=-

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/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g;\ 
s/"/\&quot;/g; s/'"'"'/\&#39;/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"