Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Im0rtality
Forked from friggeri/haiku
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Im0rtality/9702982 to your computer and use it in GitHub Desktop.
Save Im0rtality/9702982 to your computer and use it in GitHub Desktop.

Haiku name generator

Original was in coffeescript, so I simply converted to JS to run in browser without dependencies.

Usage

  1. Open browser console
  2. Paste script above and hit enter
  3. Type haiku() to generate name
  4. Click Arrow up and then Enter to generate another one
  5. Profit
haiku = function () {
var adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
"polished", "ancient", "purple", "lively", "nameless"
],
nouns = [
"waterfall", "river", "breeze", "moon", "rain", "wind", "sea", "morning",
"snow", "lake", "sunset", "pine", "shadow", "leaf", "dawn", "glitter",
"forest", "hill", "cloud", "meadow", "sun", "glade", "bird", "brook",
"butterfly", "bush", "dew", "dust", "field", "fire", "flower", "firefly",
"feather", "grass", "haze", "mountain", "night", "pond", "darkness",
"snowflake", "silence", "sound", "sky", "shape", "surf", "thunder",
"violet", "water", "wildflower", "wave", "water", "resonance", "sun",
"wood", "dream", "cherry", "tree", "fog", "frost", "voice", "paper",
"frog", "smoke", "star"
];
rnd = Math.floor(Math.random() * Math.pow(2, 12));
return adjs[rnd >> 6 % 64] + '-' + nouns[rnd % 64];
}
@MichielDeMey
Copy link

You might want to add the var keyword on line 24 to avoid adding the rnd variable to the global window.

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