Interesting Ruby’s websites for beginners – cool initiatives

Posted by Mariana De Carli on January 26, 2012

The coolest thing about Ruby is that even though it’s a dynamic and reflective programming language it’s very easy to learn. More and more programmers around the world are interested in learning this new tool for making cool things. We’ve selected 3 interesting websites to help people (kids or adults) to know a little bit more of Ruby’s world.

Kids Ruby (to kids)

 

 

http://kidsruby.com: Kids Ruby is especially focused on kids, with a very easy interface which allows you to see the code, run it, and at the same time see what it outputs. Kids Ruby is also attractive for his Turtle graphics that allows you to draw pictures and have fun by mixing and trying colors. Kids Ruby includes a lot of useful resources and you don’t even need an internet connection to work. Developers also created a complete KidsRuby operating system based on Ubuntu Linux that makes program in Ruby a lot easier for kids.

Rails for zombies

 

http://railsforzombies.org/: Rails for Zombies offers an open-source web framework with all the power of the Ruby language and with no additional configuration needed. In this site you can see tutorial videos which allow you to learn more about Ruby on Rails in just five levels. After seeing each video you’ll be challenged with cool exercises to practice your new skills. So if you’re a zombie and you’re hungry for Ruby’s knowledge this is the perfect site for you.

Try Ruby

http://tryruby.org/: This website brings a very interactive Ruby tutorial; you can test new functions step by step and understand a little bit more about this language. In just 15 minutes and with a very interactive interface you can understand what Ruby is about. This site also allows you to save your progress by sign up for free at Code School.

Now that you have these very easy options to learn Ruby why don’t you try it out and maybe we’ll see you soon as a new member of Moove-IT’s team ;)

It’s about timing baby!

Posted by Andreas Fast on November 15, 2011

Yeah, it’s about timing.

There was a problem in one of our projects at moove-it related to slow processing. There is a daemon spawning new threads to process certain new entries to the database. The entries come from a different system, that’s the reason for this program which processes each new entry. Sometimes at certain hours of a day there are peaks in the entries to the database and the process will fall behind by about 20.000 entries or more. So we started analyzing the code to understand what was happening and why it took so long. We noted that each new thread the daemon spawned took about 5 seconds to complete its task. As we narrowed the measurement we came up with some code that took 5 seconds to execute but it only involved access to the database. So thanks to Aaron Patterson’s (@tenderlove) talk at RubyConf Uruguay about “Who makes the best asado” where he talked about rails and how it manages threads and database connections, we knew where to look.

What he explained is that each new thread requests its own database connection from the connection pool, and if there isn’t a free connection, rails waits for about 5 seconds and if after that there is no free connection it iterates over all the threads to take back the connections of dead threads(more info). See the correlation with the 5 seconds I talked about in the previous paragraph? We immediately suspected that this was the problem. So we started searching the Rails API for a way to release the connection at the end of each thread’s execution. Surprisingly, we didn’t find an easy and understandable explanation anywhere at first googling ;) , so we digged deeper and came up with the following line:

ActiveRecord::Base.connection_handler.clear_active_connections!

The ActiveRecord::Base.connection_handler method returns the connection handler for the current thread and the clear_active_connections method does what it looks like, or from the Rails doc: “Returns any connections in use by the current thread back to the pool, and also returns connections to the pool cached by threads that are no longer alive.”

So this line returns the connections in use by a thread to the pool and enables the new threads spawned by the daemon to use the freed connections. This way we avoid the 5 second wait for rails to free the connections for us.

This one line picked up our performance from processing 1.000 entries in almost 2 hours to processing 10.000 in 5 minutes. Nice huh?!

That’s it. I’m not sure if this is the best way of doing it since this method also “… returns connections to the pool cached by threads that are no longer alive.” I guess this means it does the iteration over all the threads Aaron mentioned, but as you can see I’m happy with the performance improvement. We are using Rails 3.0.5, Aaron said that he will change the behavior, read more about it here.

Special thanks to @cheloeloelo who helped detecting the problems and digging through the Rails API finding the proper method to free the connections.

Image: Suat Eman / FreeDigitalPhotos.net

Second RubyConf in Uruguay – 11th and 12th November

Posted by Gabriela Isnardi on November 01, 2011

We are sponsoring one of the greatest technology events here in Uruguay. The Second RubyConf taking place within less than two weeks, the 11th and 12th November 2011, where many IT experts from all over the world get together in order to be immersed in this dynamic world and and up to date get with the latest trends of Ruby and Agile methodologies.

RubyConf Uruguay 2011

We are hungry for knowledge and refreshment, and we all want to be on the same train.

Please welcome all the new members to this awesome community. And help spreading the news, but even more important, do not miss the opportunity to meet the experts, discuss the future of RoR, and be Rail!

 

Ruby + Rails + Agile – sharing presentations

Posted by Martin Cabrera on July 09, 2011

The last Wednesday we made a workshop in the ORT University.
Pablo Ifran, Gianfranco Zas, Ariel Ludueña and I

We share the presentations to everybody

All_in_One_Agile_Development (in spanish)

Ruby_and_Rails (in spanish)

Workshop of Ruby + Ruby on Rails + SCRUM at ORT University – July 6, 2011

Posted by Martin Cabrera on June 28, 2011

Moove-IT is now part of the Ruby on Rails Workshops and Conferences around the world.

Even when Ruby seems to be the most popular modern programming language in America, there was nowhere in Uruguay you could actually learn it. Moove-IT will give you a heads up on this exciting language and Rails framework on July 6, 2011 (please see ad below).

This will be the first in a series of workshops focusing on Ruby, RoR, Scrum and hands on training exercises.

We are so proud to have made so much progress working with this technology and methodology that we feel the need to contribute to the local Ruby community.

Join us! Be part.

Ruby on rails for mobiles

Posted by sebastian.sassi on May 06, 2011

Time ago, one of our customers asked us to implement a new web project with support for smartphones. The objective was to support the most common operating systems: iOS, android, blackberry, symbian, with the possibility of using the phone capabilities (gps, sound and vibration).
After researching on different frameworks and technologies we have arrived to some conclusions that I would like to share with people who have had the same dilemma of choosing a good framework to use.
I must say that this research was based on data taken from different sources (both official and unofficial), and also having taken some particular decisions while evaluating the alternatives, that do not have to match with your own criteria.

First of all, we classified the available options into two different categories:

  • ‘Native’ Development frameworks: Rhodes, NimbleKit, Titanium (this is new to the list), PhoneGap
  • Javascript libraries: Sencha, JQTouch, JQuery mobile

Rhodes

According to the official description, The Rhodes application framework allows developers to create native mobile applications with portability of editing HTML templates and the power of the Ruby programming language. Applications written in Rhodes exhibit the performance and richness of apps written to the native device operating systems with local data but enable developers to have the productivity of web interfaces in HTML. Developers write their applications once and they then run on all major mobile device operating systems: iPhone, Windows Mobile, Blackberry and more.

Advantages:

  • Programming in Ruby
  • Full access to the Device API (Application looks different in each device)
  • Several devices supported: IPhone, BlackBerry, Android, Windows mobile
  • RhoSync: RhoSync retrieves data via web services (REST or SOAP) from backend enterprise applications for distribution to downstream mobile devices.

Disadvantages:

  • Licensing: It is a commercial product. Costs arround U$S 500 per project.

NimbleKit

NimbleKit says that it is a framework to create applications for iPhone and iPod touch fast. Programmers do not need to know Objective-C or iPhone SDK. All they need is to know how to write an HTML page with Javascript code.

Advantages:

  • HTML, CSS & Javascript

Disadvantages

  • It only works for iphone, ipods & ipads.

Titanium & PhoneGap

From architectural standpoint, these two frameworks are very similar. Titanium and PhoneGap expose the smartphone features through a set of Javascript APIs, while the application’s logic (html, css, javascript) runs inside a native WebView control. Through the javascript APIs, the “web app” has access to the mobile phone functions such as Geolocation, Accelerometer Camera, Contacts, Database, File system, and so on.

The differences:

PhoneGap does not expose the native UI components to javascript. Titanium, on the other hand, has a comprehensive UI API that can be called in javascript to create and control all kinds of native UI controls. Utilizing these UI APIs, a Titanium app can look more “native” than a PhoneGap app. Second, PhoneGap supports more mobile phone platforms than Titanium does. PhoneGap APIs are more generic and can be used on different platforms such as iPhone, Android and Blackberry. Titanium is primarily targeting iPhone and Android. Some of its APIs are platform specific (like the iPhone UI APIs). The use of these APIs will reduce the cross-platform capability of your application.
If your concern for your app is to make it more “native” looking, Titanium is a better choice. If you want to be able to “port” your app to another platform more easily, PhoneGap will be better.

Advantages:

  • Multi device
  • Programming in HTML, CSS & Javascript
  • MIT License

Disadvantages:

  • Some devices native features are not exposed in the API

Sencha

According to the official documentation, Sencha Touch is the first app framework built specifically to leverage HTML5, CSS3, and Javascript for the highest level of power, flexibility, and optimization. They make specific use of HTML5 to deliver components like audio and video, as well as a localStorage proxy for saving data offline. They have made extensive use of CSS3 in our stylesheets to provide the most robust styling layer possible.
Altogether, the entire library is under 80kb (gzipped and minified), and it is trivial to make that number even smaller by disabling unused components or styles.

Advantages

  • Great UI Controls
  • Multi device

Disadvantages

  • Commercial license (U$S 1.800 for 5 developers)

JQTouch
It is “A jQuery plugin for mobile web development on the iPhone, iPod Touch, and other forward-thinking devices.” [1]

Advantages

  • Great UI Controls
  • Multi device
  • MIT License

Disadvantages

  • Is focused on small screen devices
  • It’s a jquery plugin
  • It was created in 2009 by David Kaneda and has been relatively quiet until release of beta 3 (April 24th 2011).

JQuery Mobile
It is a unified user interface system across all popular mobile device platforms, built on jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design.

Advantages

  • Multi device (See http://jquerymobile.com/gbs/) (supports much more devices than JQTouch)
  • Very simple to use
  • John Resig, JQuery’s founder is one of the main developers and it is a high activity project
  • It is not a jquery plugin, it is a new framework
  • Dual licensed under MIT and GPL Version 2

Disadvantages

  • It is still in Alpha version

CONCLUSION
After evaluating the different frameworks, we arrived at the next conclusions:
We should use a framework that generates html + css + js, because this technology guarantees a long term support on different devices
We should use a framework that supports access to devices specific capabilities (i.e. sound, gps, camera, vibration, data, etc.) in case we need them in a near future
Because we prefer unrestrictive licenses (MIT, BSD, LGPL and others) our options are reduced to: PhoneGap, Titanium & JQTouch.

Finally, we choose PhoneGap + JQuery mobile because they are open technologies and support multiple platforms. Also, resulting interfaces are similar across different devices and that is a desired feature for our users.
JQTouch and JQuery mobile are awesome frameworks to develop mobile applications, but we prefer to choose JQuery Mobile since it support much more devices (altough it is in alpha version), has high activity and is not just optimized for WebKit as jQtouch does.
We also think that JQuery Mobile is pretty easy to use, the resulting interfaces are usable and has many components to use.

The rest of the story is pretty easy ( just because we use Ruby on Rails :P ), you should create some helpers that adds the JQuery Mobile features to the pages, or use some existent plugin, you can find a starting guide here: http://goo.gl/5Soyq.

I hope you find this post useful, have a nice coding!

[1]: forward-thinking: Someone who is forward-thinking is thinking progressively and possesses the ability to look beyond the “now” and formulate strategies for future success. They are constantly asking “what’s next?”.

Sources:

Rules Engine – Java(Drools) & Ruby(ruleby)

Posted by Martin Cabrera on December 03, 2010

Today we made one presentation with the whole team of moove-it about rules engine in Java and Ruby.

We talk about Drools and ruleby.

We share the presentation …

Rails security

Posted by Pablo Ifran on October 14, 2010

When you are working with svn (pulling your project from the svn to the web server) and you want to deploy a system into production with apache (mod_rails), you must filter the svn folders (to prevent that other users view your svn files).

To do that task, you must add the following lines to the apache configuration.


<DirectoryMatch "^/.*/\.svn/">
  ErrorDocument 403 /404.html
  Order allow,deny
  Deny from all
  Satisfy All
</DirectoryMatch>

Game for the “Plan Ceibal” // Children managing a neighborhood

Posted by Martin Cabrera on March 16, 2010

ceibal screenshot of the game

We showed the first prototype of the game developed for the “Plan Ceibal” (www.ceibal.org.uy). The game is web based and specially designed for children using a XO computer.

Plan Ceibal

The One Laptop Per Child Association, Inc. (OLPC) is a U.S. non-profit organization set up to oversee the creation of an affordable educational device for use in the developing world. Its mission is “to create educational opportunities for the world’s poorest children by providing each child with a rugged, low-cost, low-power, connected laptop with content and software designed for collaborative, joyful, self-empowered learning.”

“Uruguay is the first country in accept the challenge”

Worldbank.org – Uruguay’s Plan Ceibal: The world’s most ambitious roll-out of educational technologies?

The Game

Moove-IT and El Abrojo (a Uruguayan Social Organization who works with poor children) are working in the development of an online game for the XO computers.

This game is financed by the IMM (Government of Montevideo) and his main objective is promote good habits between children. This tool is an online game in which the children works with themes relative to the daily environment care. Each child works in groups with their classmates and also with other schools in any location of the country.

They will be able to: build houses, create commercial areas, create rural areas, maintain clean the neighborhood, and manage parks, among others things.

The points are generated by answering simple questions and doing simple tests. The tests and the answers are validated by the collective. This means that players themselves determine whether an answer is correct or not.

Here you have an initial slide of the game with some screenshots. (The slide is in Spanish)

We will put this Game on production in April 20, 2010

Ruby Benchmarks 2

Posted by Gian Zas on June 18, 2009

One of the most popular rants against ruby are based on its not so good performance.

Actually has been made improvements on this topic, specially in the new Ruby implementation (Ruby 1.9) based on the YARV virtual machine.

JRuby (Ruby over JVM implementation) has been focused in its performance from its lastest releases. Here at moove-it we are exploring the posibility of use Rails over JRuby in some JEE application servers, so we need some facts about JRuby performance (and other topics like gems compatibility, etc)

The Ruby community has put a set of benchmarks at ruby1.9 trunk: http://svn.ruby-lang.org/repos/ruby/trunk/benchmark/

So, we test with these benchmarks and here are the results!.

The code that run the benchmarks is like that:

block_to_benchmark = lambda { load BENCHMARKS_DIR + '/' + filename}
Benchmark.measure &block_to_benchmark

(yes, we are using the benchmark module bundled with the ruby standard lib)

Benchmark

Ruby1.8

Ruby1.9

JRuby1.3.0

Ruby1.8 /

Ruby1.9

Ruby1.8 /

JRuby1.3.0

bm_app_fib.rb 9.02 4.00 3.83 2.25 2.36
bm_app_mandelbrot.rb 3.36 0.81 1.49 4.14 2.26
bm_app_pentomino.rb 144.24 91.97 105.64 1.57 1.37
bm_app_raise.rb 6.94 6.98 1.63 -1.01 4.27
bm_app_strconcat.rb 2.94 1.63 1.30 1.81 2.27
bm_app_tak.rb 12.27 5.66 4.06 2.17 3.02
bm_app_tarai.rb 9.81 4.83 3.27 2.03 3.00
bm_app_uri.rb 6.59 3.77 3.69 1.75 1.79
bm_io_file_create.rb 7.17 3.12 7.70 2.30 -1.07
bm_io_file_read.rb 2.27 0.61 0.64 3.71 3.54
bm_io_file_write.rb 1.77 10.98 0.31 -6.22 5.64
bm_loop_for.rb 2.97 7.81 7.50 -2.63 -2.53
bm_loop_generator.rb 149.64 3.00 10.95 49.88 13.66
bm_loop_times.rb 4.88 6.88 7.95 -1.41 -1.63
bm_loop_whileloop.rb 11.23 3.67 9.42 3.06 1.19
bm_loop_whileloop2.rb 2.33 0.72 1.89 3.24 1.23
bm_so_array.rb 8.41 7.33 16.17 1.15 -1.92
bm_so_binary_trees.rb 4.50 2.14 2.84 2.10 1.58
bm_so_concatenate.rb 2.49 1.95 3.03 1.27 -1.22
bm_so_exception.rb 7.62 10.42 2.63 -1.37 2.90
bm_so_fasta.rb 13.59 11.77 16.03 1.16 -1.18
bm_so_lists.rb 2.27 1.38 1.48 1.65 1.53
bm_so_mandelbrot.rb 44.55 32.49 49.28 1.37 -1.11
bm_so_matrix.rb 2.69 2.13 1.84 1.26 1.46
bm_so_meteor_contest.rb 52.55 25.17 22.02 2.09 2.39
bm_so_nbody.rb 35.80 26.61 16.78 1.35 2.13
bm_so_nested_loop.rb 6.09 6.88 8.64 -1.13 -1.42
bm_so_nsieve.rb 26.89 13.11 24.69 2.05 1.09
bm_so_nsieve_bits.rb 62.50 46.05 42.55 1.36 1.47
bm_so_object.rb 11.56 11.52 3.11 1.00 3.72
bm_so_partial_sums.rb 80.13 228.91 31.22 -2.86 2.57
bm_so_pidigits.rb 10.33 10.44 7.03 -1.01 1.47
bm_so_random.rb 4.59 12.88 1.86 -2.80 2.47
bm_so_sieve.rb 0.84 0.34 0.63 2.45 1.35
bm_so_spectralnorm.rb 41.86 92.88 20.03 -2.22 2.09
bm_vm1_block.rb 26.22 13.44 27.44 1.95 -1.05
bm_vm1_const.rb 19.02 6.27 17.64 3.03 1.08
bm_vm1_ensure.rb 20.06 5.11 16.19 3.93 1.24
bm_vm1_ivar.rb 17.95 9.50 18.78 1.89 -1.05
bm_vm1_ivar_set.rb 19.22 9.83 21.67 1.96 -1.13
bm_vm1_length.rb 22.95 7.44 18.16 3.09 1.26
bm_vm1_neq.rb 20.81 6.58 14.98 3.16 1.39
bm_vm1_not.rb 14.91 5.58 12.64 2.67 1.18
bm_vm1_rescue.rb 15.72 4.64 21.38 3.39 -1.36
bm_vm1_simplereturn.rb 23.84 9.66 16.05 2.47 1.49
bm_vm1_swap.rb 50.25 5.73 24.38 8.76 2.06
bm_vm2_array.rb 10.72 19.27 5.42 -1.80 1.98
bm_vm2_case.rb 5.06 1.66 4.00 3.06 1.27
bm_vm2_eval.rb 32.20 200.98 69.41 -6.24 -2.16
bm_vm2_method.rb 15.45 9.45 11.36 1.63 1.36
bm_vm2_mutex.rb 5.47 6.34 7.30 -1.16 -1.33
bm_vm2_poly_method.rb 20.61 12.16 21.05 1.70 -1.02
bm_vm2_poly_method_ov.rb 5.00 1.66 4.53 3.02 1.10
bm_vm2_proc.rb 12.00 3.86 6.75 3.11 1.78
bm_vm2_regexp.rb 5.89 19.25 5.63 -3.27 1.05
bm_vm2_send.rb 5.05 2.11 4.38 2.39 1.15
bm_vm2_super.rb 5.75 3.17 4.44 1.81 1.30
bm_vm2_unif1.rb 5.20 1.99 3.61 2.62 1.44
bm_vm2_zsuper.rb 6.87 3.48 5.49 1.97 1.25
bm_vm3_thread_create_join.rb 1.95 7.70 19.13 -3.94 -9.79
bm_vm3_gc.rb 292.30 266.14 0.36 1.10 814.20

.

A looser conclusion may be that Ruby 1.9 is 95% faster than Ruby1.8, and JRuby 1.3.0 is 10% faster than 1.8, in general the new implementations are faster than Ruby1.8,  especially 1.9 (twice as faster).

The benchmarks were under WindowsXP  SP3, 4GB RAM, and a Intel Core 2 duo 2.0GHz. Happy hacking!