Skip to content

Instantly share code, notes, and snippets.

@adamgavlak
Created May 27, 2016 08:58
Show Gist options
  • Save adamgavlak/87de4f8a3c5011de5080d30d780409ec to your computer and use it in GitHub Desktop.
Save adamgavlak/87de4f8a3c5011de5080d30d780409ec to your computer and use it in GitHub Desktop.
Generate slug
# Generates slug with n characters that matches /[A-Za-z0-9]+/
def generate_slug(n = 7)
[*('A'..'Z'), *('a'..'z'), *('0'..'9')].shuffle[0,n].join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment