Skip to content

Instantly share code, notes, and snippets.

@gfredericks
Created June 17, 2015 00:55
Show Gist options
  • Save gfredericks/af951e56680127f10eb8 to your computer and use it in GitHub Desktop.
Save gfredericks/af951e56680127f10eb8 to your computer and use it in GitHub Desktop.
Encoding strings as a collection of NaNs.
(ns sneaky-NaNs
"Secret codez.")
(defn char->NaN
[c]
(-> c
(int)
(bit-or 0x7ff8000000000000)
(Double/longBitsToDouble)))
(defn NaN->char
[nan]
(-> nan
(Double/doubleToRawLongBits)
(bit-and 0xffffffffffff)
(char)))
(->> "¡Hello, world! ☺" (map char->NaN))
=> (NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN)
(->> "¡Hello, world! ☺" (map char->NaN) (map NaN->char) (apply str))
=> "¡Hello, world! ☺"
@gfredericks
Copy link
Author

Does the internet yet have "run this code on fifty different processors as a service"?

@jafingerhut
Copy link

That is an interesting question. I wouldn't be surprised if Amazon or Travis might offer something like that, but quick Google searches don't return positive results for me. I would expect companies like Google, Amazon, Facebook, Microsoft probably have internal tools to test software against their data center fleets of servers, with their variations in processors, but that isn't likely to be a public service.

@gfredericks
Copy link
Author

Time to combine that with my other startup idea of mining and selling/trading testnet cryptocurrency.

@jafingerhut
Copy link

stenanography.com is still available! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment