Birds-Eye.Net
All things broadband and more...
 
Web Birds-Eye.Net

What's New?

Ruby on Rails (RoR)
Programming Reference


Models
External database connections
Passing current_user into model
Passing object into model
Using static lookup tables
Validates IF
Validates MongoMapper

Views
Dynamically delete form element
Edit create nested data
HTML form field check_box
Layout jQuery datatable module
Select array
Select cascading via JS
Text_area Array
Text_area listing submit
Text field format time

Controllers
Dynamic model selection
Including first item from a sorted desc table
Using from_unixtime on epoch dates

Rack
Integrated NTLM/Kerberos Authentication
Pass-through Authentication w/ NTLM

ActionMailer
Broken links in emails

Rails General
Add, Subtract, Multiply, and Divide
Calculate number of weekdays for date range
Date->Epoch & Epoch->Date
Extract first letter of each word
Hash of hashes assignment
Using: variable as hash index

jQuery
jQuery accordion MongoDB


More to come

 

Extract First Letter of Each Word to Form an Acronym

By: Bruce Bahlmann - Contributing Author (your feedback is important to us!)

In rails development, you may run across a case where you are given a string of characters (for example a job title, a phrase, or some other group of words) and want to simply extract the first letter of each word to form an acronym or some other cryptic word to use as a password.

Rails provides a fairly easy way to do this via chaining several functions together as shown below:

[Extract first letter of each word in a string]
s = "this is my best try"

s.split(/\s+/).map(&:first).join 
=> timbt

## Or to make these all CAPS simply add upcase

s.split(/\s+/).map(&:first).join.upcase
=> TIMBT

Note: One of the time tested best ways to select passwords is to obtain an old book of ancient proverbs or sayings and then extract the letters from these proverbs or sayings to form your password. The older the book the better. To further increase security, you can come up with your own substitution system (numbers for certain letters) and/or which letter from each word according the word's position within the phrase. The result is often a catchy yet an extremely safe password. I've used this practice in the past to generate SNMP community strings and root passwords.

Can Birds-Eye.Net help you or your Company?
Receive your Birds-Eye.Net articles and white papers hot off the presses by adding our RSS feed to your reader.

 

 

(C) Copyright Birds-Eye.Net, All rights reserved.
It is against the law to reproduce this content or any portion of it in any form without the explicit written permission of Birds-Eye Network Services, LLC. Federal copyright law (17 USC 504) makes it illegal, punishable with fines up to $100,000 per violation plus attorney's fees.