Skip to content

Instantly share code, notes, and snippets.

@mikz
Created March 17, 2014 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikz/9607003 to your computer and use it in GitHub Desktop.
Save mikz/9607003 to your computer and use it in GitHub Desktop.
Fetches awesome namesgenerator from docker & runs it in ruby.
require 'open-uri'
class NamesGenerator
def self.load
go = open('https://raw.github.com/dotcloud/docker/master/pkg/namesgenerator/names-generator.go')
left, right = go.read.scan(/\[\.\.\.\]string{(?<strings>.+)}/)
left = left.first.scan(/"(.+?)"/)
right = right.first.scan(/"(.+?)"/)
[left, right]
end
def initialize
@left, @right = self.class.load
end
def generate
[@left.sample, @right.sample].join('_')
end
end
if __FILE__ == $0
puts NamesGenerator.new.generate
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment