<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: generation code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 05:30:51 GMT</pubDate>
    <description>DZone Snippets: generation code</description>
    <item>
      <title>ruby: random alphanumeric string</title>
      <link>http://snippets.dzone.com/posts/show/5017</link>
      <description>generate random alphanumeric string 'size' characters long&lt;br /&gt;&lt;br /&gt;&lt;code&gt;size = 8; (1..size).map{([*('a'..'z')]+[*('A'..'Z')]+[*(1..9)].map{|n|n.to_s}).instance_eval{self[rand(self.size)]}}.join&lt;/code&gt;</description>
      <pubDate>Mon, 21 Jan 2008 09:03:01 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5017</guid>
      <author>elliottcable (elliott cable)</author>
    </item>
    <item>
      <title>Ruby dictionary username generation</title>
      <link>http://snippets.dzone.com/posts/show/4536</link>
      <description>Generate a new random name from dictionary words.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;DICT_PATH = '/usr/share/dict/words'&lt;br /&gt;DICT_SIZE = 234936&lt;br /&gt;&lt;br /&gt;def self.generated_name words = 2, length = 23&lt;br /&gt;  name = 'a'*(length+1)&lt;br /&gt;  while name.length &gt; length&lt;br /&gt;    name = (1..words).map{%x[sed -n '#{rand(DICT_SIZE)} {p;q;}' '#{DICT_PATH}'].chomp.capitalize}.join&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 13 Sep 2007 13:57:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4536</guid>
      <author>elliottcable (elliott cable)</author>
    </item>
    <item>
      <title>Generate random password in ruby </title>
      <link>http://snippets.dzone.com/posts/show/3632</link>
      <description>Aaron Blohowiak suggests adding this as a public method in user.rb:&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def new_random_password&lt;br /&gt;  self.password= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--")[0,6]&lt;br /&gt;  self.password_confirmation = self.password&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 06 Mar 2007 08:51:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3632</guid>
      <author>Mickael (Mickael)</author>
    </item>
  </channel>
</rss>
