Skip to content

Instantly share code, notes, and snippets.

@onliniak
Created October 3, 2025 09:47
Show Gist options
  • Save onliniak/925e5793fce8560841f3f27b2a3be06f to your computer and use it in GitHub Desktop.
Save onliniak/925e5793fce8560841f3f27b2a3be06f to your computer and use it in GitHub Desktop.
files upload && NEON multistring decoder
require "http/server"
require "base64"
# require "yaml"
# data = <<-YAML
# ---
# multi line string: '''
# one line
# second line
# third line
# '''
# YAML
# a = data.partition(/'''/) #=> {"---\nmulti line string: ", "'''", "\n\tone line\n\tsecond line\n\tthird line\n'''"} match
# p a
html = <<-HTML
<!DOCTYPE html><html><body><div id="base64" style="display:none;">#{Base64.encode(File.read("./example.7z"))}</div><script>
const base64String = document.getElementById("base64").textContent;const fileName = "example.7z";function n(n,t){const o=atob(n);const c=new Array(o.length);for(let n=0;n<o.length;n++){c[n]=o.charCodeAt(n)}const e=new Uint8Array(c);const s=new Blob([e]);const u=document.createElement("a");u.href=URL.createObjectURL(s);u.download=t;document.body.appendChild(u);u.click();document.body.removeChild(u);URL.revokeObjectURL(u.href)}const t=document.createElement("button");t.textContent="Click Me";t.addEventListener("click",()=>{n(base64String,fileName)});document.body.appendChild(t);</script></body></html>
HTML
server = HTTP::Server.new([
HTTP::CompressHandler.new
# HTTP::StaticFileHandler.new("."),
]) do |context|
context.response.content_type = "text/html"
context.response.print html
end
server.bind_tcp "0.0.0.0", 8080
server.listen
p "http://localhost:8080/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment