Skip to content

Instantly share code, notes, and snippets.

@HumanEquivalentUnit
Created August 25, 2020 04:28
Show Gist options
  • Save HumanEquivalentUnit/8d8d465319c8fd9cbbd99c5aa3e0befd to your computer and use it in GitHub Desktop.
Save HumanEquivalentUnit/8d8d465319c8fd9cbbd99c5aa3e0befd to your computer and use it in GitHub Desktop.
decode a TIO.run link in Dyalog APL / .Net
tioCode{
decodes a TIO.run link such as
tioCode 'https://tio.run/##SyzI0U2pTMzJT////1Hf1EdtExSMFYwf9W551LvZkgsioq4OZSg86lzwqHcFkor//wE'
load dfns workspace to use base64 decoder
_{( ⎕NS ).⎕CY }'dfns'
⎕USING'System' 'System.Net,System.dll'
hash('^https://tio\.run/##'⎕R'') remove web address parts of the link
hash('/'@{='_'})('+'@{'@-'})WebUtility.UrlDecodehash
zBytesdfns.base64 hash
inflatedStream⎕NEW IO.MemoryStream
deflateStream⎕NEW IO.Compression.DeflateStream((⎕NEW IO.MemoryStream(zBytes)) IO.Compression.CompressionMode.Decompress)
_{deflateStream.CopyTo inflatedStream} dfns.do
bytesinflatedStream.ToArray
{'UTF-8'⎕UCS}¨255()bytes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment