Tuesday, February 12, 2008

Ruby and VOIP - Continued

I completed my presentation this past weekend of Ruby and VOIP to the Twin Cities Asterisk User's Group. It went very well and I had a great time talking about Ruby and how I see Adhearsion and Telegraph being used in this emerging technology space. There were some great questions from the group and I think they had fun seeing my demonstrations as well. Plus, this time I had 2 hours to present, so I was able to get through all of my demos!

Contrasting this presentation with the one I did a few weeks ago at RUM, it was an interesting difference in groups that I presented to. Both groups are extremely technical people and include collegues that I have a great deal of respect and admiration for. It was interesting to me that there wasn't much crossover exposure of technology between the groups. Many people at the RUM group, had heard of Asterisk, but I think only 1 person raised their hand when I asked if anyone had download or run it. Likewise, the Asterisk folks had heard of Ruby, but none of them had written a script before. I had however planned for this and modified my slides slightly since the Ruby User's Group needed some background information Asterisk and the Asterisk User's Group needed some context on what Ruby is. If you are curious, you can download my modified slides here.

<SOAPBOX>
What is so interesting in VOIP as I see it coming from a software background, are the applications that we can develop and put online. Bringing the ideas of Web 2.0 to VOIP makes these frameworks a disruptive technology - and disruptive in a good way. The status quo in telecom hopefully is not going to cut in any longer and being able to write applications to interface voice and web in some ways I see as the next frontier in internet application development. Additionally, with these two isolated camps of software developers and hardware telecommunication experts, I see the market needing more people that can bridge that gap and create some really kicking applications.

</SOAPBOX>

And at the end of the day though, what I enjoy most about working with both of these frameworks is that they are FUN to use. They allow you to be innovative. Go ahead, think up a new feature or application and have at it!

Friday, February 1, 2008

Ruby and VOIP

I've been doing a some work in the VOIP area recently, using Ruby and Open Source PBXes such as Asterisk and decided it would be fun to present at the Ruby User of Minnesota ( RUM ) meeting earlier this week. My topic was on Ruby and VOIP and it seemed to have been pretty well received. I have great respect for people who are comfortable and confident speakers. I still have a lot of work to do to get the jitters out, but I do enjoy taking the time to put together presentations and share what I have learned or created with other people in the technology world. Here is a link to my presentation - 32 slides of Ruby and Asterisk goodness!

I was able to show a few of the demos that I created, but I unfortunately ran out of time and didn't get a chance to show my "Who Wants To Be A Billionaire" Application. It's an application that allows you to be a contestant of a game show using your phone. You create and manage the questions using your web browser and when people call in, the system uses text to speech to speak you the questions. It keeps track of your point total and you can call back later and resume the questions if you wish. It's pretty cool and wasn't hard to do in Ruby using Adhearsion. Besides Adhearsion another cool framework for VOIP and Ruby is Telegraph. Telegraph provides some slick integration with Rails and allows you to integrate voice response directly into your controllers.

I'll be doing this same presentation for the Twin Cities Asterisk Users Group in a few weeks so I'll need to tweak the presentation slightly as most of the slides are currently explaining Asterisk. The guys at the Asterisk Users Group will need more of a background of Ruby as they work with and understand Asterisk. Wish me luck!

As I've written in a previous post, I see the interaction between voice and the internet being more and more blurry as time goes on (in many way with VOIP it already is pretty blurry), but where they come together I see an opportunity for new products, services and small business like myself to create some really cool stuff. And all the time, having fun while doing it!

Resources:
For those that saw the demo and are curious how you might get a hosted Asterisk solution, here's some providers that I am working with who do great work. I'd be more than happy to put you in contact with the right people at either of these organizations.

OneNetUSA - http://www.onenetusa.com
Arretta Communications - http://www.aretta.com

If you have hardware and want to host it yourself, Trixbox is a fully bundled ISO that contains everything you need to be up and running in minutes. I highly recommend it if you need to get a PBX up and running quickly.

TrixBox - http://www.trixbox.org

Monday, January 28, 2008

Ruby, Rails, Groovy, Grails, What's a programmer to do?

I'm doing some prototyping on a possible project for a client and have been getting my feet wet with the Grails Framework. I feel like know my way around Rails fairly well as I've done a few different small web applications in the framework and although there was a learning curve and Rails does have it warts, overall Rails really has saved me a TON of time and made me write better and well tested code.
For this project with my client, I'll be leaving it in their possession and feel that selling them on Groovy and Grails was a slightly easier sale as they already are a 100% Java shop. I think making the switch to writing Groovy, using their existing IDE (IntelliJ) and deployment in a J2EE container, would make them a little more comfortable than having to learn Rails. The JRuby guys are doing awesome work and if it was entirely up to me, I'd take the Rails route and consider using JRuby for production deployment if needed. But, getting them even to consider another framework was enough of a strain and if I told them I was leaving them an application in Ruby, I think I would most likely have been shown the door.

So, alas, I walk the Grails line. I must admit, it has been an interesting experience so far and one that I'd like to write more about in a future posting. I did however come across this blog posting in my research and have found it sums up very well some of the feelings I have for the whole Grails / Rails debate I see ensuing. I'd highly suggest reading the article.

Overall, I think each has it's place. I would agree that with Grails I find myself spending more time learning the framework because of poor or outdated documentation, and picking p Groovy the language relatively quickly. Where with Rails, I find myself learning the framework quickly, but taking more time to learn Ruby. It might however have to do with the fact that I learned Rails first and in some ways have to break my mind of some of the differences between what I learned in Rails and how it's done in Grails.

Regardless of which side you land on, I think it's worth your time to atleast investigate and learn about these frameworks as these are going to become more and more popular methods in developing applications as time marches on.

Tuesday, January 1, 2008

Upgrade to Rails 2.0

Well, to usher in the New Year, I bit the bullet today and tried upgrading one of the applications I built for my client to Rails 2.0 . The process to do the upgrade was relatively painless. The whole idea of Rubygems is awesome and is something I feel that the Java community is horribly lacking.
Installing Rails 2.0.2 was a simple as:

>sudo gem install rails

And then changing the line in the environment.rb to:

RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION

The issues though came in when I actually tried to run the application. Here's a brief rundown of the refactoring that I had to do and some gotchas that maybe other will run into.

1. Pagination - I had heard all of the warnings that the default pagination was going to be taken out of Rails 2.0, but like more programmers I am somewhat lazy ( or too busy ) to implement changes until I really NEED to. Well, if you upgrade to Rails 2.0 and you use the default pagination functions in Rails 1.2, you will NEED to do something else. It has been ripped out for Rails 2.0. I must say I agree with the the idea to pull it out as pagination is something that really should be done by a plug-in. After some searching I found a two options for people in my same situation.

a. classic_pagination - This is the plugin that will give you the same functionality of the old Rails 1.2 pagination. Many in the Rails community frown on the use of the old code for performance reasons, flexibility and good object oriented design.

b. will_paginate - This is the plugin that is seems like the Rails community is backing going forward for pagination. It offers some advantages of the old pagination methods and doesn't require too much refactoring to implement. Here is a good screencast on using it.
I decided to go with will_paginate since this is more the standard and new projects going forward this is what I will probably use, so it made sense for me to get aquainted with how it works. It turned out to be actually very easy to make the changes. He is an example of a change in the controller that I needed to make for "Jobs".

This:
@job_pages, @jobs = paginate(:jobs, :order => 'deadline')

Was changed to:
@jobs = Job.paginate(:page => params[:page], :order => 'deadline')

and in my view this code:
Page Number: <%= pagination_links(@job_pages, :params => {'job[filter]', @job_filter }) %>

was changed to simply:
<%= will_paginate @jobs %>

Much easier to read, understand and maintain. I'd suggest watching the screencast I mentioned above to learn more.

2. Nested RESTful routes - This was very annoying and was a little difficult for me to find much information on how to fix it. It seems like when you define a nested route in the routes.rb in Rails 2.0, the helper methods that are created don't behave the same or work the same as they did under Rails 1.2 This is what I had previously.

We have a relationship with jobs containing artifacts. So in our routes.rb:

map.resources :jobs do |job|
job.resources :artifacts
end

and in the a show.rhtml view had:

artifacts_path(@job)

When running under Rails 1.2 this works fine and generates the url

/jobs/1/artifacts URL.

Under Rails 2.0 we get an error:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym

Annoying. Well it turns out you have 2 options.
a. Modify your routes.rb to be

map.resources :jobs do |job|
job.resources :artifacts, :name_prefix => nil
end

b. Change the call to artifacts_path to instead be:

jobs_artifacts_path(@job)

There is information on this helper methods here. Thank god I found this reference. That is one thing that I do find frustrating about Rails is the lack of the documentation I was able to find when going through an upgrade. It seems like this issue I ren into should have beein BIG BOLD letters warning people that old RESTful methods don't work the same with out the changes that I mention. Anyway, I digress. I decided to go with the more simpler change of adding :name_prefix => nil to my routes.rb since I was worried about making sure I found all of the helpers. Hopefully this is the right choice and will work in all my cases. It seems to work for the time being.

3. Running unit tests in Textmate - It seems like there is some issues with a file called Builder.rb and it conflicting with Builder.rb in Rails 2.0. I couldn't run my tests in Textmate until I did what was described here. Not a big deal, but again... annoying and nothing that I have seen other documentation. With 75% of the Rails community using TextMate I'm surprised that at the very least DHH didn't mention it in the release notes for Rails 2.0

4. Capistrano - Capistrano 2 is what is now used by default with Rails 2.0. I tried running a simple 'cap deploy' after upgrading an have been getting some odd errors. I need to track down exactly what is going on. I had thought that deploy.rb was backward compatible, but I guess not. For now I have been doing `cap _1.4.1._ deploy` and forcing it to use the old version for now. I'll track this down shortly.

5. Flash.now - So, I re-ran by functional tests and started getting failures. I have the following line in my application.rb

flash.now[:error] = "You are not authorized."

When running under 1.2.3 and my functional test I have an assert to validate that the error returns in the flash.

assert_equal "You are not authorized", flash[:error]

However, when running under Rails 2.0.2, THE FLASH IS NOT RETURNED! Why is that?

If I change the line in the application.rb and remove the .now to be

flash[:error] = "You are not authorized."

THE TEST PASSES! Not sure why this is in the case. I haven't seen anything in the release notes that mention an upgrade would cause this. Maybe I'll send a post to the RUM group to see if others have seen something similar.

All in all though, the upgrade to 2.0.2 hasn't been too bad. I guess I was hoping that it would be trivial, but I guess what can I expect? I did come from 1.2.3 all the way to 2.0.2 and I can't expect everything to just automatically work right out of the box. I has however only been 8 months since I started work on this system and am surprised the versions that we are up to in Rails. I'm excited to see where things are in at in another 8 months!

Sunday, December 9, 2007

Adhearsion

I've been spending a fair amount of time working with the open source PBX system called Asterisk. Calling it powerful in the world of telecommunication doesn't do it justice. It's what I would call a "disruptive technology" that in coming years is going to shake up and open the way that we develop application that interact between our phone and internet. It's a solution to problems that haven't even been thought of yet and the best part that I'm finding is that it's FUN to develop applications in this space!

Well let me re-phrase that... It's FUN when you use Adhearsion! With Asterisk, as it is with other PBX systems for the system to be of any use there must be routing logic on phone calls that are coming in. Asterisk has it's own macro language you can use, but it also provides a way to call out to another process to perform the tasks. This is where Adhearsion steps in. Using Ruby, you are able to create some very neat and sophisticated applications and abstract yourself away from the internals of Asterisk. On top of that, you can easily integrate in Ruby on Rails to provide the functionality of using the internet for your application.

As I mentioned in previous post, I heard Justin Gehtland speak at No Fluff Just Stuff and he talked about contributing to open source and sometimes just reporting a bug or two or working on documentation can provide a great help to a project. Well, a few weeks ago I realized that I have found my project. The Adhearsion project is an open source project lead by Jay Phillips who has written some extremely beautiful Ruby code. Looking over the code is inspiring in itself and I have learned so much in the way of the Ruby language just by reviewing the source. I therefore decided to take it on myself and contribute to the documentation WIKI. I submitted an article on how to combine Adhearsion with Rails and create what I call the "Quiz Show" application. It's my first attempt at writing documentation so it's got some rough edges, but it shows just how powerful and fun working in Adhearsion and Rails can be. Check out the documentation here.

I am also working with JRuby and am planning to contribute to the documentation a section on Adhearsion and JRuby as well. I'm planning in the coming months to do a few a different presentation about Adhearsion at the local Twin Cities Asterisk and Ruby Users of Minnesota Groups. I hope people get as excited about this project as I am. It's going to be really interesting in the coming years to see how open source PBX like Asterisk and open source frameworks like Adhearsion bring the barrier of entry to telecom applications down to a point where a small company like Localtone Interactive can provide competitive solutions for business and integration with other products and services.

Tuesday, November 13, 2007

Localtone Radio Redesign Launched


After many hours of work and help from Mykl Roventine, Localtone Radio has a spiffy new look and some exciting new features.
Check out the new look and sign up if you haven't already done so. Localtone Interactive is very proud to be the only technology company to build and internet radio station where the listeners contribute and vote on the music that is to be played. It's a fresh and new idea in media consumption. Please feel free to contact us if you have any needs like this in your organization.

Sunday, October 21, 2007

Sun Midwest Java Technology Day

Sun had their Midwest Java Technology Day on Tuesday to tout a number of the new technologies they are introducing to the market. I'm excited the Sun has an interest in promoting dynamic languages in the JVM and the keynote by Tim Bray was no exception. He talked about how right now is a perfect time to start you own company. The barriers to entry are the lowest they have ever been in terms of open source software and if you have an idea and are willing to do hard work, you can do it. It was very inspirational for an entrepreneur myself. In not so many words he said, "Leave your boring day job and work in technologies that interest you!". Great advice. I've been in business for myself for over a year now and have absolutely loved it. He also had a number of slides discussing the great advantages of using a Ruby on Rails for your next web application (or start up).

The remainder of the conference was pretty typical with EJB 3.0, Glassfish and the new features in JDK7. I does seem that Sun is getting the message of a more light and agile stack in the frameworks and creating web services in NetBeans running Glassfish is pretty neat. However, the fact that the head technology evangelist at Sun is talking Ruby to CEO's at companies makes me feel good that this Ruby thing might be more than just a fad. I know I've found some great productivity gains when working in Rails and once the managers see the benifits in terms of cost, the services Localtone Interactive provides will be very much in need.