Skip to content

Instantly share code, notes, and snippets.

@StephenWakely
Created November 6, 2015 15:18
Show Gist options
  • Save StephenWakely/f1dd93e5d6f1561dd834 to your computer and use it in GitHub Desktop.
Save StephenWakely/f1dd93e5d6f1561dd834 to your computer and use it in GitHub Desktop.
Generate random data that is almost pronouncable
module Main where
import System.Random
import Data.Char
names :: [[Char]]
names = ["Onk", "Ponk", "Erk", "Wonk", "Plark", "Pan", "Ork",
"Plerk", "Sha", "Noc", "Toc", "Wop", "Pap", "Shn", "Agh",
"Pert", "Munk", "Shton", "a", "e", "i", "o", "u", "Gert", "Onx",
"Ink", "Mank"]
fragment :: Int -> [Char]
fragment num = names !! num
fragments :: RandomGen g => g -> [[Char]]
fragments g = let limit = (length names) - 1
in take 3 $ map fragment (randomRs (0, limit) g :: [Int])
combined :: [[Char]] -> [Char]
combined = foldl (++) ""
capitalize :: [Char] -> [Char]
capitalize (x:xs) = (toUpper x) : (map toLower xs)
capitalize [] = []
main :: IO ()
main = do g <- getStdGen
putStr $ capitalize $ combined $ fragments g
@StephenWakely
Copy link
Author

Hammerspoon script to dump the generated gobbledegook to the keyboard :

hs.hotkey.bind({"cmd", "alt"}, "V", function() 
  task = hs.task.new("/Users/home/data", function(exit, out, err) 
     hs.eventtap.keyStrokes(out)
  end)
  task:start()
end)

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