Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Logan Koester http://logankoester.com

« Newer Snippets
Older Snippets »
Showing 1-7 of 7 total  RSS 

Display the number of characters in the name of each month

   1  
   2  months = %w(January February March April May June July August September October November December)
   3  months.each { |m| print  m, " (", m.length, ")\n" }

Rails route lets :id be a domain name

// Named route for an id that contains . characters, such as a domain name
// eg: http://myapp/domains/foobar.com

   1  
   2  map.domain 'domains/:id', :controller => 'domains', :action => 'show', :requirements => { :id => /[a-zA-Z0-9\-\.]+/ }

Generate a random string of letters

// Generates a random string of lowercase letters. Great for email verification codes ;)

   1  
   2  Array.new(6) { (rand(122-97) + 97).chr }.join

Generate a random string of letters

// Generates a random string of lowercase letters. Great for email verification codes ;)

   1  
   2  Array.new(6) { (rand(122-97) + 97).chr }.join

Generate a random string of letters

// Generates a random string of lowercase letters. Great for email verification codes ;)

   1  
   2  Array.new(6) { (rand(122-97) + 97).chr }.join

Generate a random string of letters

Generates a random string of lowercase letters. Great for email verification codes ;)

   1  
   2  Array.new(6) { (rand(122-97) + 97).chr }.join

Generate a random string of letters

Generates a random string of lowercase letters. Great for email verification codes ;)

   1  
   2  Array.new(6) { (rand(122-97) + 97).chr }.join
« Newer Snippets
Older Snippets »
Showing 1-7 of 7 total  RSS