Skip to content

Instantly share code, notes, and snippets.

@harlantwood
Last active December 18, 2015 13:39
Show Gist options
  • Save harlantwood/5791655 to your computer and use it in GitHub Desktop.
Save harlantwood/5791655 to your computer and use it in GitHub Desktop.
Random subdomain segment generation
#!/usr/bin/env ruby
require 'securerandom'
MAX_SUBDOMAIN_SEGMENT_SIZE = 63
key = SecureRandom.base64 MAX_SUBDOMAIN_SEGMENT_SIZE*2
key.gsub!(/\W/, '').downcase!
key = key[0...MAX_SUBDOMAIN_SEGMENT_SIZE]
puts key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment