Note to Self: Find the First Names

by Zach Briggs

These are notes to future Zach so that I may never need to look up this particular solution again. Today we are pulling an array of first names out of an array of full names. Unfortunately I couldn't quite get the regex to return the first names without leading spaces, so I punted and chained a strip call after the slice.

Visit Rubular to play in the sandbox. A one beer bounty for the person who can find the first names without leading spaces.

http://rubular.com/r/pNW6XF6J74

Note to Self: Roll Your Own YAML Config Files

by Zach Briggs

Adding your own config files to a Rails project should be easy but there isn't much clear guidance on doing it well. Here is how to parse the sweet, sweet YAML without surprising the person inheriting your code. We put this in initializers because it is the obvious place and because the deserialization only happens once, on Rails boot.

config/initializers/my_sweet_class.rb

Keep in mind that you'll need a bit of code in the spec helper to set those variables when testing in isolation. Please do not set defaults when the configuration is for a database-y operation. Fail loudly and proudly when the setup isn't performed.