Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
random heroku-like name generator
haiku = ->
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))
"#{adjs[rnd>>6%64]}_#{nouns[rnd%64]}"
console.log haiku()
@jedschneider

This comment has been minimized.

Copy link

commented May 7, 2014

thanks! used this today for some auto-generating url endpoints. fun stuff!

@bmarcot

This comment has been minimized.

Copy link

commented Jun 15, 2014

Nice one, thanks!

@nfedyashev

This comment has been minimized.

Copy link

commented Jul 3, 2014

Thanks!

@adizam

This comment has been minimized.

Copy link

commented Dec 5, 2014

I'd remove the word throbbing

@jlebrech

This comment has been minimized.

Copy link

commented Dec 8, 2014

In Ruby:

module RandomNameHelper

  def generate_name
    rnd = Random.rand(64)

    "#{adjectives[rnd%adjectives.length]}_#{nouns[rnd%adjectives.length]}_#{rnd}"
  end

  private

  def adjectives
    [
      "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", "bold", "little", "morning", "muddy",
      "red", "rough", "still", "small", "sparkling", "shy",
      "wandering", "withered", "wild", "black", "young", "holy", "solitary",
      "fragrant", "aged", "snowy", "proud", "floral", "restless",
      "polished", "purple", "lively", "nameless"
    ]
  end

  def 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"
    ]
  end
end

=> "sparkling_silence_40"
=> "broken_butterfly_24"
=> "restless_dream_54"
=> "winter_glitter_15"

@mikebaldry

This comment has been minimized.

Copy link

commented Jan 6, 2015

In ruby you can use the useful Array#sample method

@sadikovi

This comment has been minimized.

Copy link

commented Apr 7, 2015

Cool, thanks a lot:)

@kylie-a

This comment has been minimized.

Copy link

commented Nov 26, 2015

In Python:

import random
import math


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"
]

def generate_name(adjs, nouns, separator='-'):
    num = int(math.floor(random.random() * math.pow(2,12)))
    adj = random.choice(adjs)
    noun = random.choice(nouns)
    return '{adj}{separator}{noun}{separator}{num}'.format(
         adj=adj,
         noun=noun,
         num=num,
         separator=separator
     )

Output:

dark-fire-759
fragrant-night-565
hidden-darkness-1092
silent-dream-3838
divine-sea-2637
@arelangi

This comment has been minimized.

Copy link

commented Mar 29, 2016

In Go:

package main

import (
        "fmt"
        "math/rand"
        "time"
)

var (
        adjs  = []string{"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 = []string{"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"}
)

func generateName() string {
        r := rand.New(rand.NewSource(time.Now().UnixNano()))
        return fmt.Sprintf("%s-%s-%d", adjs[r.Intn(len(adjs))], nouns[r.Intn(len(nouns))], r.Intn(9999-1000)+1000)
}

Output

> bold-brook-4866
> proud-wood-2799
> cold-snow-8062
@shanev

This comment has been minimized.

Copy link

commented Apr 10, 2016

In Swift:

import Foundation

extension Int {
    static func random(range: Range<Int> ) -> Int {
        var offset = 0

        if range.startIndex < 0   // allow negative ranges
        {
            offset = abs(range.startIndex)
        }

        let mini = UInt32(range.startIndex + offset)
        let maxi = UInt32(range.endIndex   + offset)

        return Int(mini + arc4random_uniform(maxi - mini)) - offset
    }
}

extension Array {
    func randomItem() -> Element {
        let index = Int(arc4random_uniform(UInt32(self.count)))
        return self[index]
    }
}

struct NameGenerator {
    let 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"
    ]
    let 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"
    ]

    func generate() -> String {
        let randomInt = Int.random(1...99)
        let randomAdj = adjs.randomItem()
        let randomNoun = nouns.randomItem()
        return "\(randomAdj)-\(randomNoun)-\(randomInt)"
    }

}
@joonas-fi

This comment has been minimized.

Copy link

commented Jun 12, 2016

Awesome stuff, guys! Might use this for generating server hostnames!

@nwjlyons

This comment has been minimized.

Copy link

commented Jun 23, 2016

I made a bookmarklet out of this which generates a name and copies it to your clipboard. https://gist.github.com/nwjlyons/61b6c5680c53d7da8baf7245aac7a970

Only tested in Chrome Version 51.0.2704.103 (64-bit) on OSX

@wmcraver

This comment has been minimized.

Copy link

commented Aug 20, 2016

Jut found this and love it. I forked it and made it work in R.

@EDDYMENS

This comment has been minimized.

Copy link

commented Sep 28, 2016

In PHP

<?php

$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"
];

function generate_name($adjs, $nouns, $separator='-') {
    $num  = intval(rand(2,3)*pow(5,5));
    $adj  = $adjs[array_rand($adjs, 1)];
    $noun = $nouns[array_rand($nouns, 1)];
    return $adj.$separator.$noun.$separator.$num;
}

echo generate_name($adjs, $nouns);

@alandipert

This comment has been minimized.

Copy link

commented Oct 25, 2016

In Bash (with shuf):

#!/usr/bin/env bash

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 shy wandering withered wild black young holy solitary fragrant aged snowy proud floral restless divine)

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)

sample() {
  eval "echo \${$1[\$RANDOM%\${#$1[@]}]}"
}

printf "%s-%s-%s\n"   \
       $(sample ADJS) \
       $(sample NOUNS)\
       $(shuf -i 1000-9999 -n1)
@mccarthy

This comment has been minimized.

Copy link

commented Nov 11, 2016

JavaScript / Node

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", "wobbling", "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"
]

var adj = adjs[Math.floor(Math.random()*adjs.length)];
var noun = nouns[Math.floor(Math.random()*nouns.length)];
var name = adj + '-' + noun + '-' + randomInt(1, 999);
console.log(name);

function randomInt (low, high) {
    return Math.floor(Math.random() * (high - low) + low);
} 
@huijari

This comment has been minimized.

Copy link

commented May 8, 2017

ES6 🙃

const 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", "wobbling", "shy",
  "wandering", "withered", "wild", "black", "young", "holy", "solitary",
  "fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
  "polished", "ancient", "purple", "lively", "nameless",
];
const 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",
];

const random = (high) => Math.floor(Math.random() * high);

const adj = adjs[random(adjs.length)];
const noun = nouns[random(nouns.length)];
const num = random(1000) + 1;

console.log(`${adj}-${noun}-${num}`);
restless-wind-659
little-darkness-664
lively-shadow-57
@ravernkoh

This comment has been minimized.

Copy link

commented Sep 10, 2017

Elixir version :)

defmodule HerokuNameGen do
  @adjectives ~w(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 shy wandering withered wild black young holy solitary fragrant aged snowy proud floral restless divine)
  @nouns ~w(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)

  def run do
    "#{Enum.random(@adjectives)}-#{Enum.random(@nouns)}-#{(:rand.uniform(9000) + 1000)}"
  end
end
@coryodaniel

This comment has been minimized.

Copy link

commented Jun 19, 2018

Rust version!

extern crate rand;
use rand::prelude::*;

fn main() {
  let mut rng = thread_rng();
  let adjectives = ["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"];
  let 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"];

  let adjective = adjectives[rng.gen_range(0, adjectives.len())];
  let noun = nouns[rng.gen_range(0, nouns.len())];
  let id = rng.gen_range(1000, 9999);

  println!("{}-{}-{}", adjective, noun, id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.