Ruby Learning

December 11th, 2007 -

Have you been interested in learning Ruby, but haven’t found the best resource to do so, or are not sure where to start? Well, a friend of mine, Satish Talim, asked me to announce his third class, Learning Ruby Programming.

This course is instructed by Satish, for free! it’s open to anyone and begins January 7th, 2008. The syllabus is available online and in several languages.

To sign up and join this class (last class had over 500 students), head on over and register. This is a great opportunity to learn Ruby, with an excellent and knowledgeable instructor, all for free.

Not surprising or new, there has been some “new” buzz about Rails, scaling, DHH’s use of the f-word and other irrelevant arguements on why Rails isn’t a good choice for a framework to use and stick with. From what I can tell, it started with this blog post where a lot of assumptions, yes assumptions, are thrown around as truths instead of what they are.

Time Calculation Extension

July 27th, 2007 -

I’ve been working on this project that prorates and have needed to add some extra Time extension goodness. Things like,
  • Time.now.end_of_year
  • Time.now.first_of_the_year (or) Time.now.the_new_year
  • Time.now.end_of_week
  • Time.now.next_quarter
  • Time.now.end_of_quarter

I’ve been finding these pretty handy and so I’ve added them to a plugin to extend the Time class. You can grab the plugin here:

http://svn.robertrevans.com/plugins/calc_extension/

Enjoy!

Rails Creator

July 20th, 2007 -

Previously it was called, creator. Today, it has a new name: rails_creator. Dr. Nic suggested the idea to make it easier to remember and if you forgot, you could type rails and hit tab to see it pop up in the Terminal window.

You can either download the gem at or you can open up your terminal/command line and type:

gem install rails_creator

Go check it out and use it to create your rails applications on edge or not and check-in/check-out from subversion.

Permalize Fun

July 1st, 2007 -

I was playing around with my permalize plugin to optimize it just a bit. Initially it was around 8 lines of code that did the actual parsing of the string. After a few improvements, it is now a one liner. Man I love Ruby!

(Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv word).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase 

Creator - Rapid Rails Setup

June 17th, 2007 -

Finally, this weekend I found some free time to finish off my first gem release: Creator – Rapid Rails Setup.

I’ve been promising this gem for some time now, but with numerous projects going on at work, several freelance projects, and trying to find time to spend with my 1 year old little girl, it’s been hard to find time to do any personal projects these days. (phew, now that is a sentence!) Since it was father’s day, I decided I would do a few things I have been wanting to do for months now, and this was one of them.

I have a Ruby Forge account setup for the project, just head over here and grab the gem. Once you have it installed on your system, open a terminal window and type creator. There are instructions that will walk you through the process allowing several options:

  • Create your project on Edge Rails or whatever version you have installed on your system.
  • Choose what database you’re using (mysql, postgres, etc) – this sets up your config/database.yml file
  • Choose the name of your Project
  • Decide if you are checking this into subversion or not
  • If you are checking it into subversion, then it will automatically check it out again on your local machine – this because it will then do svn:ignore on several files (database.yml, log, tmp)

Hopefully in the near future I’ll have some time to add a few more options, such as not checking it out from subversion, after checkin, of you so choose.

If you have any suggestions of what you’d like to see added, just leave me a comment. Hope you like it!

Rcov

May 23rd, 2007 -

I posted this over on my Ruby Snips site.

I really like using rcov for my testing. It helps show those little places in your code that could use more tests. However, it gets annoying to keep writing out the rcov test/unit/* rcov test/functional/*. Perhaps there is a better way to run those that is quicker, I’m not sure, but I wrote a little rake task to take care of it for me. Here it is:

1
2
3
4
5
6
7
8
9
namespace :test do
  desc "Run rcov for both unit and functional tests."
  task :rcov => :environment do
    return unless %w[development test staging].include? RAILS_ENV
    `rcov test/unit/*`
    `rcov test/functional/*`
    `open -a firefox #[RAILS_ROOT}/coverage/index.html`
  end
end

That “open -a” line will open up firefox to the index.html page that was just created so you can view your test coverage. It is OSX specific. To for windows, just use start firefox and I assume you can pass the url as I’ve done above, but I’m not quite sure – I haven’t tested it.

Permalize

April 15th, 2007 -

It’s been quite a while since last I blogged. I’ve been really busy with work and freelance – some of which I’ll talk about in a later post. For now, I wanted to introduce my first plugin for Rails, Permalize.

I had gone through the Rails source looking at the various methods that extend the String class in Ruby and didn’t find any that would work well as a permanent link creator. There’s dasherize (which I thought would work, but it is for underscores to dashes), pluralize, titleize and a bunch of other goodies. Thus, permalize was born.

Ruby Snips

February 22nd, 2007 -

I work with Ruby everyday and everyday I am learning something new. In an effort to retain everything that I am learning, I’ve created a place where I can keep code snippets, with an explanation of what is going and how to use it.

I know this has been done before, but I personally like the blog style with the categories, tags and search capabilities to find whatever it is I am looking for. It is like having my own personal code bank of Ruby snippets. I’ve called this Ruby Snips.

Currently, Ruby Snips doesn’t have much on there. I need to make sure the RSS is working, add code highlighting, etc. But those will come very soon.

Part of my vision for this site is to ask other Ruby enthusiasts to come and be a guest author to write short, sweet and concise pieces of their favorite snips to share. I’ve always liked Ruby Inside’s code snippets, but there wasn’t a search functionality (that I saw) and often times there was no explanation of the code. Granted it isn’t too hard to figure out what is going on, but I am a firm believer in commenting your code and providing explanations for other people to learn what you’ve done. This then provides a solid basis for learning and building upon principles.

I’m definitely not looking to have long tutorials on the site, but rather examples of small snips of code with an explanation of how it is being used and how it could be used. Ruby Snips has a small post on my vision for the site and a post with snip of Ruby code that will provide an example of how short and sweet I’d like to keep each post.

If you are interesting in sharing a Ruby and/or Rails snip, either leave me a comment here or shoot me an email (contact info on contact page). I hope that this can be a good learning ground for beginners to intermediate Ruby coders.

Textmate Snippets

January 25th, 2007 -

I love Textmate. It is by far the greatest text editor available. Any other editor currently on the market cannot compare to the simplicity and yet vastness of Textmate.

What I really like about it is that you can create code snippets to speed up your productivity when coding. I feel that are a few missing in the HTML and Rails bundles. So, I’ve created a few that I use often and thought others might like to use what I have created.

Search Ruby Docs within Safari

January 7th, 2007 -

Working on the Mac, I’ve really become found of using Safari. One thing I wish is that it had the web developer toolbar like firefox has. Firefox is still a great browser, but on the Mac, it just doesn’t look or feel like Mac software. Version 2 of Firefox is a great improvement, but it isn’t quite there and won’t be until version 3.

Another aspect of Firefox that I like is the ability to create customized searches with keywords. Well, Safari can do the same thing with two different plugins – you only need one.

Ruby nuggets

November 17th, 2006 -

Ola Bini has great little post on Ruby he entitled, Nooks and Crannies of Ruby. He talks about the splat operator, symbols, to_proc, operators as method names and some other cool stuff. Set 15 minutes or so aside and give this read, you will learn something new.

Check it out.

Ruby Bytes

November 7th, 2006 -

Inspired by Cody Lindley’s JavaScript Tidbits, I’ve decided to follow suit. I’ve been wanting to write some small samples of code to share about the depth of the Ruby language.

There has been so much focus on Rails, that Ruby seems to take a back seat at times. So, I’d like to share somethings that Ruby is very known for being able to do in the Rails world. Let’s start with this example of using Ruby scripting power to search within a file.

Ruby Phrasebook

August 27th, 2006 -

&rlThere has been a lack of posts recently, but I promise it is for a good reason. As it might suggest, I am not currently writing a book. I have had two offers as of now, but with work, freelance and several on going projects, I just don’t have the time right now. I do have several good ideas for some titles, but lack the time to actually make it happen.

So, instead of pursuing the authoring thing, I have been doing the Technical Editing thing for SAMS Publishing company. In December, a new book will be released, entitled Ruby Phrasebook. I have been fortunate enough to have already read about half of the book already, editing the code and giving ideas and suggestions where I feel they are needed.

This has been a really great experience. One, I get to read a book beofre it is even published, and two I get to learn about the whole publishing thing before ( if ) I ever decide to actually author a book.

The Ruby Phrasebook is turning out to be a really good book. It, as all SAMS Phrasebooks do, concetrates on presenting examples or tutorials and not so much on trying to teach beginning programming. There are several aspects that are “beginner” topics within programming itself, demonstrated in the Ruby language, that can be quite helpful for those that are either new to programming or those who are new to Ruby. Also, what is interesting is that this book is coming from the perspective of a system admin who uses Ruby in his day to day job. There are some tricks that I think many people will find quite interesting and cool that are usually done in Shell Scripting but can also be done in Ruby as well, say if you don’t have Telnet installed or don’t have access, and need to use it anyways.

Rails :through

June 6th, 2006 -

Nate, over at the Godbit forum had asked a question some time ago about using Rails to join tables. His assessment was that there aren’t very many good tutorials on the subject. So, I present to you a very simple Rails tutorial covering how you would join tables.