Skip to content

Instantly share code, notes, and snippets.

@zachjamesgreen
Created March 2, 2016 19:11
Show Gist options
  • Select an option

  • Save zachjamesgreen/e7119d273401583a5fa2 to your computer and use it in GitHub Desktop.

Select an option

Save zachjamesgreen/e7119d273401583a5fa2 to your computer and use it in GitHub Desktop.

Revisions

  1. zachjamesgreen created this gist Mar 2, 2016.
    11 changes: 11 additions & 0 deletions random_ruby
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/usr/bin/env ruby
    require "awesome_print"

    if ARGV.empty? || ARGV[0] == '' || ARGV[0].empty?
    length = 10
    else
    length = ARGV[0].to_i
    end
    ap "Generating random string of length #{length}"
    r = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + %w(! @ # { $ % ^ & * ? < > })
    ap (0...length).map { r[rand(75)] }.join