#ruby
15 posts tagged ruby. Clear filter
-
Transform Matching Text with Gsub in Ruby and Regular Expression
Here is a gist that demonstrates how easy it is to transform text using gsub and a block with Ruby. "Scs Epc Score".gsub (/scs|epc/i) { |i| i.upcase } =\ SCS EPC Score For more helpful string...
-
Color Output with Test:Unit, AutoTest and Ruby 1.9
If you are testing using Test:Unit (rather than RSpec) and you're using Ruby 1.9. colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test...
-
How to Merge a YAML File Into a Single Hash in Ruby
require 'yaml' Nested YAML structure from something-nested.yml nested: key: value keytwo: valuetwo Procedural Approach to building a single Hash from nested YAML data structure. @yaml =...
-
Class
See the full pastie here: http://pastie.org/2580020
-
Email Regex
Regular Expression that Matches Email Addresses:
-
How to Upgrade RVM on Mac OS X
I had an old version of rvm installed and wanted to upgrade. So old in fact that the resource for upgrading no longer existed. just returned a 301, redirect. Luckily, the following worked
-
Ruby Reload! Method in Non Rails IRB Sessions
I love the Rails reload! function when in the console. I need it in Irb. To get it back this is what I did. If you don't already have an .irbrc file in your home directory, just create it. Add this...
-
Ruby Rand Range
I assumed that rand would take a range as an argument. Something like rand(10..20), generating a random number between 10 and 20. Seems like you'd do this fairly often when working with random...
-
Installing Ruby on Rails 3, MySQL, Git, Ruby Enterprise Edition, Passenger (Mod_Rails) on Ubuntu with Rackspace Cloud.
Short and sweet. Here all the commands I run in this order to set up a brand new box. It usually takes about 10 - 15 minutes on a 256 MB RAM instance. Compiling Ruby Enterprise Edition, which is...
-
Ruby Enterprise Edition and Passenger ./script/console production fails and instead returns Loading production environment (Rails 2.3.5) Rails requires RubyGems >= 1.3.2. Please install RubyGems...
After installing Ruby Enterprise Edition, REE, and Passenger on Ubuntu you may see this error message when you run script/console for the first time You then scratch your head and run to find that...
-
Installing and Using Rvm on Mac OS X, Creating Gemsets and Reverting to Original Environment
What is RVM and why should you use it? RVM is a Ruby interpreter, version management tool. In short, it enables you to switch between different versions and releases of Ruby (for instance, version...
-
Combat Spam with the Akismet Class for Ruby
Here is the Akismet.rb class, written by David Czarnecki. I've seen several tutorials online using this class, however, the class isn't available at David's blog. So... I reposted it here and at...
-
Running Gem Server to View Docs for Ruby Libraries on Localhost
will boot up documentation on port 8808 by default pass it the -p flag followed by the port number to change.
-
Repost
This post is inspired by http://pupeno.com/blog/really-resetting-the-database/comment-1179. But as my blog mostly serves as a reference for my future self, I'd like to reprint this little snippet...
-
Using Formtastic to Cleanly Create Nice Looking Forms in Rails
Forms can easily get cluttered when you're dealing with a lot of form fields... er, ERB tags. I've written about extending Rails form builders, which certainly goes along way to shrinking your...