<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>ruby-desenvolvimento &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/ruby-desenvolvimento/</link>
	<description>Feed of posts on WordPress.com tagged "ruby-desenvolvimento"</description>
	<pubDate>Sun, 19 May 2013 13:51:54 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[CarrierWave - limit file size (plus gif fix)]]></title>
<link>http://fabianosoriani.wordpress.com/2012/11/10/carrierwave-limit-file-size-plus-gif-fix/</link>
<pubDate>Sat, 10 Nov 2012 20:06:58 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2012/11/10/carrierwave-limit-file-size-plus-gif-fix/</guid>
<description><![CDATA[CarrierWave has an awesome abstraction API. It is simple, clear and extensible. But has some critica]]></description>
<content:encoded><![CDATA[<p><a href="https://github.com/jnicklas/carrierwave" target="_blank">CarrierWave</a> has an awesome abstraction API. It is simple, clear and extensible. But has some critical vulnerability specially when combined with <strong>image processing</strong>, such as, ImageMagick when resizing an image will consume exponencial <strong>memory size</strong> and any upload can easily make your process crash, when not processed safely. Also, it is not pretty good to combine <strong>.gif</strong> out of the box, because it makes a collection out of the file.</p>
<p><strong>Friendly advice beforehand;</strong> Using <a href="http://filepicker.io/" target="_blank">http://filepicker.io/</a> may be a way better idea if you are hosting in Heroku, just make sure if fits your constraints before get hard work done.</p>
<h3>Solution Spec</h3>
<h4>Hard limit file size of the request, so the process don&#8217;t block for too long, and don&#8217;t blow memory!</h4>
<p>If you behind a server such as <strong>Apache or Nginx</strong>, you can impose a limit to the request size, and you should!</p>
<p>Unless you are in Heroku, and afaik, there is no way to do that, at least just yet. So yes, this can be a major security breach for Rails apps on Heroku.</p>
<h4>Given a successful upload, pre-validate size.</h4>
<p>The &#8216;official&#8217; solution attempt to <strong>validate the size after</strong> the file have been processed. It doesn&#8217;t help, since when processing an image rather large (6Mb image consumed 2GB memory in my case) your process will be killed! Letting your website down for some time, and letting your users down as well.</p>
<h4>For gifs, take only the first image (less memory consumption too)</h4>
<p>When processing .gifs it seems to make a vertical frameset will all the images in the sequence, so it looks like a movie roll, which is not what most people want. Lets just extract the first frame.</p>
<p>Interestingly enough, I found that the processor is invoked for all frames in the .gif. (<a href="https://github.com/cldwalker/debugger" target="_blank">thanks debugger</a>!)</p>
<h3>Solution code</h3>
<p>This code takes care the mentioned specs (except for the request size limit), and I think the great advantage is that it avoids opening a file as Image if it fails the size constraint. As well as being very efficient with gifs (only acting on the first frame).<br />
It works on Heroku, with integration for S3, and should work on Amazon Cloud and other VPS.</p>
<p>The shortcome is about handling the exception which is a bit messy involving controller-side logic in a non-automated AR fashion.</p>
<p><strong>Controller</strong></p>
<pre class="brush: ruby; title: ; notranslate" title="">
  def create
    begin
    @post = Post.new(params[:post])
    rescue Exception =&#62; e
      if e.message == 'too large'
        redirect_to news_path(err: 'file')
      else
        raise e
      end
    end
   #...
</pre>
<p><strong>uploader</strong></p>
<pre class="brush: ruby; title: ; notranslate" title="">
# encoding: utf-8


class NewsUploader &#60; CarrierWave::Uploader::Base

  include CarrierWave::RMagick

  include Sprockets::Helpers::RailsHelper
  include Sprockets::Helpers::IsolatedHelper


  def store_dir
    &#34;uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}&#34;
  end

  def pre_limit file
    #require 'debugger'; debugger
    if file &#38;&#38; file.size &#62; 5.megabytes
      raise Exception.new(&#34;too large&#34;)
    end
    true
  end

  def only_first_frame
    manipulate! do &#124;img&#124;

      if img.mime_type.match /gif/
        if img.scene == 0
          img = img.cur_image #Magick::ImageList.new( img.base_filename )[0]
        else
          img = nil # avoid concat all frames
        end
      end
      img
    end
  end

  version :large, if: :pre_limit do
    process <img src='http://s1.wp.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly_first_frame
    process :convert =&#62; 'jpg'
    process :resize_to_limit =&#62; [1280, 1024]
  end

  # Create different versions of your uploaded files:
  version :small, if: :pre_limit do
    process <img src='http://s1.wp.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly_first_frame
    process :convert =&#62; 'jpg'
    process :resize_to_limit =&#62; [360, 360]
  end


  # For images you might use something like this:
  def extension_white_list
    %w(jpg jpeg gif png)
  end

end
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby's fear-cancer]]></title>
<link>http://fabianosoriani.wordpress.com/2011/11/11/rubys-fear-cancer/</link>
<pubDate>Fri, 11 Nov 2011 13:25:34 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2011/11/11/rubys-fear-cancer/</guid>
<description><![CDATA[This video: High Performance Ruby: Threading Versus Evented by Dr Nic Williams, Engine Yard It meant]]></description>
<content:encoded><![CDATA[<h2>This video: <a href="http://vimeo.com/31204217">High Performance Ruby: Threading Versus Evented by Dr Nic Williams, Engine Yard</a></h2>
<p><strong>It meant so much to me!</strong></p>
<p>For around 4 months I&#8217;ve been using Node.js, and before that, for 3 years, programming Rails.</p>
<p>As soon as I started on Node.js, I could feel that something was different. My little Computer Science bachelor conscience was starting to tell me: now you are <em><strong>starting</strong></em> to do it right <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But then, lets go back, Ruby&#8217;s syntax is lovely.. Rails API is sugar! But still, it&#8217;s <strong>neverland</strong>. Why??</p>
<p>It does not fit real world! It is a thin layer of happiness, so delicate, that we feel <strong>fear</strong> of touching it and <strong>breaking</strong> it. So what we puny humans do? We delegate it to those genius heroes who will be able to take that code and maybe squeeze a few more couples of requests/sec!</p>
<p>But not even that is the <em>cancer</em> I mean.</p>
<p>The cancer here is represented by clown hosting the video. &#8220;<em>Oh those scientific articles mess with our head and stuff O.o Let me chew that evil reality and I will give you the RIGHT (sugar coated) solution!</em>&#8221; and all other non fun nor assertive statements. By the way, <em>he may be</em> referring to the <a href="http://www.kegel.com/c10k.html" target="_blank">C10K problem</a>, and <a href="http://www.google.com.br/search?q=c10k+threads+problem" target="_blank">alike</a>, articles.</p>
<p>The problem here is, VP  EngineYard and want ppl addicted on his junk. He does not host Node.js.</p>
<p>Ruby always had so many language implementations to solve some important language problems, as well as servers. This is not the first time a good solution for ruby is born (JRuby+Trinidad), but why would they share it before if he could have people paying for so much RAM?</p>
<p>The reason I believe he felt compelled to share it now, is that Node.js unoptimized code can outperform Rails by a LOT,  under 150Mb.</p>
<p>But my main problem is <strong>fear of complexity</strong>. The host talks about it all over the initial part of the video. <em>He refers his audience under constant fear of it&#8217;s own ignorance all the time</em>. This is a awful, and that&#8217;s how I felt using <strong>Rails</strong>. Such a large stack, complex language design, only understanding the framework code itself was hard task.</p>
<p>To keep people in bliss ignorance he just goes like: &#8220;Oh I promissed evented? We are past that, right?! HAAAA&#8221; so just be happy and keep the <em>status quo</em>. You would&#8217;t want to mess your pretty little head with <em>asynchronous code</em>, would you?</p>
<p>I like Node.js, besides performance, language is simple; it is JavaScript, open Objects, closure and more. Of course, don&#8217;t assume well-written JS is something easy to do. No great code in any modern language is easy to achieve.</p>
<p>If you&#8217;ve developed Rails, you have concepts of MRI, thin, mongrel, jruby, 1.8.7, 1.9.2, rubinius, unicorn, and LOT MORE, whilst in node.js world all that stands for: node.js. <strong>It is a unification point for language and server</strong>.</p>
<p>What about gems?  npm, a easier system of distributing packages.</p>
<p><strong>Wrapping it up</strong>, node.js is no silver bullet, it just made me realize the problems I had while programming ruby, as much as ruby did it for me on php. If nothing else, node.js helped improve ruby&#8217;s community by adding options to the web development mainstream.</p>
<p>Would I work with Rails again? If a employer would point me that out as the only chosen solution, then yes, and I&#8217;d probably try that stack, but I prefer confidence instead of fear.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[When to Ruby on Rails, when to Node.js]]></title>
<link>http://fabianosoriani.wordpress.com/2011/09/11/when-to-ruby-on-rails-when-to-node-js/</link>
<pubDate>Mon, 12 Sep 2011 00:56:48 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2011/09/11/when-to-ruby-on-rails-when-to-node-js/</guid>
<description><![CDATA[(update) Take this post as a naive overview, it may not reflect the most accurate reality Hello! I a]]></description>
<content:encoded><![CDATA[<p><em>(update) Take this post as a naive overview, it may not reflect the most accurate reality</em> </p>
<p>Hello!</p>
<p>I am trying to do a sort of <strong>indirect comparison</strong> between Rails and Node.js. The very main reason of being indirect, is that <strong>Rails is a Framework</strong>, while <strong>Node.js is an implementation of a programming language</strong> with custom libraries.</p>
<p>If it were be to put in a simple phrase, <strong>Rails is resourceful</strong> and <strong>Node.js is light and fast</strong>.</p>
<p>Lets elaborate some..</p>
<h3><strong>Rails</strong></h3>
<p>Is the most complete open-source framework available (that I know of)! Big companies use it. It can do lots of stuff well, in an organized manner; this meaning, Rails is more than just MVC, it has a full stack of features well-integrated, at the same time being very modular. <em>Some</em> of the features included out of the box:</p>
<ul>
<li>Database adapter for the majority of them, supporting plug your own.</li>
<li>Database migrations, so multiple dev can sync and experiment with their DB.</li>
<li>Powerful engines for Views, Controllers and Models.</li>
<li>Support to code generator.</li>
<li>Has structure to all sorts of tests and friendly to TDD.</li>
<li>Really awesome documentation.</li>
<li>Model has all kinds of hooks, validations and associations.</li>
<li>Controller has support to handle XML/JSON in the same action that serves HTML.</li>
<li>Gems that integrate, for instance, Memcached, MongoDB, Auth and lots more.</li>
</ul>
<div>So Rails is war-proven, capable of integrating lots of features together without harass. There is also a very cool post of Fabio Akita in the refs. about how it made possible to develop systems in periods before impossible.</div>
<h3>Node.js</h3>
<p>Two things make this platform suitable for web:</p>
<p>Its engine, V8 is very fast! In a very loose average, 8 times faster than Python (or even up to 200 at peak). Python already outperforms Ruby (ref. bottom)</p>
<p>Second point; and this argument is separated from the above, is that it async-driven (is built around reactor pattern). As in the case, requests can be performed in parallel, without any blocking I/O. A single server can handle a lot. (update) And with &#62;0.6.0 Cluster API, it can scale to use all of available CPU cores.</p>
<p>So, it is a very new sort of backend language, but huge players, besides Joyent, who invented it, are adopting it, including LearnBoost and LinkedIn, which has an awesome article about using. The language, and it&#8217;s main web framework, Express, deserve a list of features (you can check more info in the references below).</p>
<ul>
<li>It´s web server is able to handle a HUGE number of connections out of the box</li>
<li>Various libraries can be run on browser, the same as in the server</li>
<li>Very friendly to Websockets (real-time web apps)</li>
<li>Lots of libraries are being ported to it from other langs.</li>
<li>Express, inspired in ruby´s Sinatra; is very light on memory but also very powerful</li>
</ul>
<div>Running a simple benchmark against a single server instance, I were able to get 587 req/s accessing MySQL without any external cache support. This number could scale, if I used Cluster to spawn at least a process per processor.</div>
<h3>Summarizing, When to use each?</h3>
<p><strong>Rails</strong> really shines when..</p>
<ul>
<li>The database is complex in terms of associations.</li>
<li>The app structure is well defined.</li>
<li>Business rules are complex, and validation is needed.</li>
<li>When the number of requests isn´t the a decisive factor.</li>
<li>Administrative interfaces.</li>
<li>Many developers in parallel keep the DB up-to-date with migrations</li>
<li>The database to be used is undefined, or may vary.</li>
</ul>
<div>What about <strong>Node.js</strong>?</div>
<div>
<ul>
<li>APIs</li>
<li>Real-time web/mobile apps.</li>
<li>Application that should scale to lots of concurrent requests.</li>
<li>Little memory footprint</li>
</ul>
</div>
<p><strong>This being said, there is no reason at all, a web-site or service can´t easily integrate both</strong>.</p>
<p><em>&#8211; I&#8217;d appreciate if you could leave a comment, either to talk about your case, or add up.</em></p>
<p><span class="Apple-style-span" style="font-weight:bold;">References</span></p>
<p>&#160;</p>
<p>UPDATE: <a href="http://www.mikealrogers.com/posts/a-new-direction-for-web-applications-.html">http://www.mikealrogers.com/posts/a-new-direction-for-web-applications-.html</a></p>
<p><a href="http://guides.rubyonrails.org/">http://guides.rubyonrails.org/</a></p>
<p><a href="http://railscasts.com/">http://railscasts.com/</a></p>
<p><a href="http://blog.heroku.com/archives/2011/6/22/the_new_heroku_2_node_js_new_http_routing_capabilities/">http://blog.heroku.com/archives/2011/6/22/the_new_heroku_2_node_js_new_http_routing_capabilities/</a></p>
<p><a href="http://nodejs.org/">http://nodejs.org/</a></p>
<p><a href="http://akitaonrails.com/2011/04/16/twitter-muda-de-ruby-para-java-ruby-e-3x-mais-lento-que-java">http://akitaonrails.com/2011/04/16/twitter-muda-de-ruby-para-java-ruby-e-3x-mais-lento-que-java</a></p>
<p><a href="http://venturebeat.com/2011/08/16/linkedin-node/">http://venturebeat.com/2011/08/16/linkedin-node/</a></p>
<p><a href="http://blog.bossylobster.com/2011/08/lesson-v8-can-teach-python-and-other.html">http://blog.bossylobster.com/2011/08/lesson-v8-can-teach-python-and-other.html</a></p>
<p><a href="https://github.com/LearnBoost">https://github.com/LearnBoost</a></p>
<p><a href="http://www.readwriteweb.com/hack/2011/01/how-3-companies-are-using-node.php">http://www.readwriteweb.com/hack/2011/01/how-3-companies-are-using-node.php</a></p>
<p><a href="http://twitter.com/#!/FlockonUS/status/104655096956190720">http://twitter.com/#!/FlockonUS/status/104655096956190720</a></p>
<p><a href="https://github.com/LearnBoost/cluster">https://github.com/LearnBoost/cluster</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Leaving Google AppEngine for Rails and going Heroku]]></title>
<link>http://fabianosoriani.wordpress.com/2011/06/02/leaving-google-appengine-for-rails-and-going-heroku/</link>
<pubDate>Fri, 03 Jun 2011 01:19:41 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2011/06/02/leaving-google-appengine-for-rails-and-going-heroku/</guid>
<description><![CDATA[Hey all Introduction (goal) I&#8217;ve been projecting for sometime my tag based search engine for s]]></description>
<content:encoded><![CDATA[<p>Hey all</p>
<h3>Introduction (goal)</h3>
<p>I&#8217;ve been projecting for sometime my tag based search engine for sometime now. And while it is something relatively simple, query performance still have a great impact on that matter.</p>
<p><a href="http://fabianosoriani.files.wordpress.com/2011/06/ggg.png"><img class="aligncenter size-medium wp-image-374" title="ggg" src="http://fabianosoriani.files.wordpress.com/2011/06/ggg.png?w=300&#038;h=57" alt="" width="300" height="57" /></a></p>
<p>It should be a project, with roots in <a href="http://en.wikipedia.org/wiki/Gamification" target="_blank">gamification</a>; and I choose Ruby on Rails, and not GAE&#8217;s Python or Java framework due I do not want to be stuck in a hosting platform for whatsoever reason.</p>
<h3>AppEngine, what&#8217;s great?</h3>
<p>AppEngine has many, <a href="http://code.google.com/appengine/whyappengine.html">cool things</a>. Those including some that should make my life a lot simpler</p>
<ul>
<li>Generous elastic <a href="http://code.google.com/appengine/docs/quotas.html">free quota</a> for all stuff I needed</li>
<li>BigTable, with stable performance (it is suppost to perform so well with thousand entry through a million )[<a title="this does not prove a thing ;)" href="http://gaejava.appspot.com/" target="_blank">demo</a>]</li>
<li>They have the <a href="http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html">type List</a> in DataStore, witch is exactly what I need to make a good queries</li>
<li>Should scale seamless, no pain</li>
<li>Have a great panel, that allows easy data manipulation, and great reports.</li>
</ul>
<div>Besides, it is clear that Google is investing heavy on that product, which is a huge plus.</div>
<h3>AppEngine, what is bad, for Rails?</h3>
<p>After building <a href="http://fabianosoriani.wordpress.com/2010/12/11/creating-a-rails-2-3-8-on-google-app-engine/" target="_blank">my hello world on GAE</a>, things looked awesome; a proof of concept right there! Rails 2.3.8 running smooth.</p>
<p><img class="aligncenter" title="jruby gae" src="http://code.google.com/p/appengine-jruby/logo?cct=1288280276" alt="" width="72" height="55" /></p>
<p>But then it began.. migration, data backup, gems like omniauth, sorta elaborated queries.. where to look for all those stuff? Rubygems system is disabled, and no doc is easily found, if any doc is around. So I got to go build conceptual proofs  for all those things?</p>
<p>So it happens, that their <a href="http://code.google.com/p/appengine-jruby/wiki/RunningRails" target="_blank">landing page for Rails</a>, is stale for years; a big turn down! And still it hard to find some decent support for Rails (@woodie <a href="https://gist.github.com/825451" target="_blank">does help</a> in docs, but can&#8217;t be accepted as the only source)</p>
<p>Recently they&#8217;ve announced a they are going beta with the <a href="http://blog.golang.org/2011/05/go-and-google-app-engine.html" target="_blank">Go language</a>;  what sounds really great, still in practice it mean Ruby won&#8217;t be getting support (if ever) in a very long while.</p>
<h3>So, Heroku and why</h3>
<p>For being a Computer Scientist . I am a big fan of Google capacity of execution and performance for years, but the downsides have been just too great too keep on. So let&#8217;s check <a href="http://www.heroku.com/" target="_blank">Heroku</a>.</p>
<ul>
<li>I had prior experience there</li>
<li>Heroku offers Rails out of the box, working with Omniauth.</li>
<li>They also have a free quota to try (1 dyno ~ 10-50req/sec)</li>
<li>240MB from MongoLab</li>
<li>Nice <a href="http://addons.heroku.com/" target="_blank">features</a></li>
<li>Robust and elastic scalable (dyno charge per hour)</li>
</ul>
<h3>Final Considerations</h3>
<p>The pro in this scenario, is that they take Rails with all gems I could need, no harass there, things just work! And if I grow tired of then, I can just switch host <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Why not a <strong>VPS</strong>? I&#8217;ve had <a href="http://linode.com" target="_blank">Linode</a> for sometime now, they have some great management panel; but the concern about the O.S. security and app scalability is considerable.. Sure is cool to config all my features from the ground; but considering business, this kind of setup must be taken professionally.</p>
<p>Google AppEngine, or GAE,<strong> is a great platform,</strong> for their supported languages. If I were to host there, I would definitely <a title="Go programming Language" href="http://golang.org/" target="_blank">learn Go</a>, for all great features intended, and the attention Google is giving it.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Migrating from SQLite to Mysql on Rails 3]]></title>
<link>http://fabianosoriani.wordpress.com/2011/05/01/migrating-from-sqlite-to-mysql-on-rails-3/</link>
<pubDate>Sun, 01 May 2011 20:26:35 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2011/05/01/migrating-from-sqlite-to-mysql-on-rails-3/</guid>
<description><![CDATA[Common sense on developers use to say: Don&#8217;t use sqlite on production, because it sux in perfo]]></description>
<content:encoded><![CDATA[<p>Common sense on developers use to say: Don&#8217;t use sqlite on production, because it sux in performance.</p>
<p>Well, for a system with around 20 users that should be no problem at all in the begin, right? &#8211; Right but also <strong>Wrong</strong>!</p>
<p>I&#8217;ve tested using the system on the same settings, but for some reason, after a while the reading on the Database by Rails became very inconsistent. While in console I would find some recently created objects by <a href="http://rufus.rubyforge.org/rufus-scheduler/" target="_blank">Rufus Scheduler</a>, the web app would not see then until the server was restarted! Weird results, but a price to pay for not listening the common sense =)</p>
<p><strong>The solution</strong> would be to migrate the schema and data to some easy to use Mysql. Schema as widely known is extremely easy to migrate on Rails framework (if used properly).</p>
<p>Searching for solutions for migrating data from different databases may be a pain, but given a great Rails tool it is rather simple! Introducing the <a href="https://github.com/ludicast/yaml_db" target="_blank">gem yaml_db</a>, made by the Heroku people.</p>
<p>As the commands are simple as <em>:dump</em> and <em>:load</em>, I don&#8217;t see why go longer in the explanation.</p>
<p>The whole process took less than 2 hours, including a small bug fix in a non-agnostic code =)</p>
<p><em>At service of <a href="http://twitter.com/#!/bbrains" target="_blank">BananaBrains</a>, <a href="http://fire.bananabrains.net" target="_blank">FIRE the social soccer game RPG</a>.</em></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Desenvolvimento web, Porque Aprender Rails?]]></title>
<link>http://fabianosoriani.wordpress.com/2011/04/17/desenvolvimento-web-porque-aprender-rails/</link>
<pubDate>Sun, 17 Apr 2011 22:06:46 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2011/04/17/desenvolvimento-web-porque-aprender-rails/</guid>
<description><![CDATA[[ESSE É UM POST MASHUP] Isso quer dizer que vou me focar em retransmitir bons argumentos de referênc]]></description>
<content:encoded><![CDATA[<h3>[ESSE É UM POST MASHUP]</h3>
<p>Isso quer dizer que vou me focar em retransmitir bons argumentos de referências que respeito.</p>
<p><strong>Argumentos </strong><a href="http://www.quora.com/Ruby-on-Rails/Why-do-so-many-startups-use-Ruby-on-Rails" target="_blank">Porque muitas Startups Usam Rails?</a></p>
<p>Mas e a <strong>Performance</strong>? <a href="http://www.akitaonrails.com/2011/04/16/twitter-muda-de-ruby-para-java-ruby-e-3x-mais-lento-que-java" target="_blank">Twitter muda de Ruby para Java. Ruby é 3x mais lento que Java.</a></p>
<p>Corroborando, o que realmente importa, o <strong>processo </strong><a href="http://www.azarask.in/blog/post/the-wrong-problem/" target="_blank">You Are Solving The Wrong Problem</a></p>
<p>Venho desenvolvendo Ruby, mas não exclusivamente isso à mais de 2 anos, tenho <strong>muito</strong> o que aprender ainda. As ferramentas de <strong>Console</strong> são extremamente úteis, aconselho abusar delas, seja como 1ª linguagem ou migrando de outras como Java, C++.</p>
<p>Sigam <a href="http://twitter.com/flockonus" target="_blank">pessoas legais</a> no Twitter para se manter informados <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Input BULKY de dados por Google Docs(spreadsheet)]]></title>
<link>http://fabianosoriani.wordpress.com/2011/03/04/input-bulky-de-dados-por-google-docs-spreadsheet/</link>
<pubDate>Fri, 04 Mar 2011 21:34:23 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2011/03/04/input-bulky-de-dados-por-google-docs-spreadsheet/</guid>
<description><![CDATA[Precisando ler dados de uma planilha de Google Docs pelo Rails 3? https://github.com/gimite/google-s]]></description>
<content:encoded><![CDATA[<p>Precisando ler dados de uma planilha de Google Docs pelo <strong>Rails 3</strong>?<a href="https://github.com/gimite/google-spreadsheet-ruby" target="_blank"> https://github.com/gimite/google-spreadsheet-ruby</a> <strong>muito fácil</strong>!</p>
<p>Como a documentação da gem está muito bem feita nem vou me preocupar em explicar isso, mas vou dar uma sugestão de uso.</p>
<p>Temos essa necessidade grande junto à um cliente de importar uma quantidade massiva de dados, então ele me sugeriu importar de uma planilha, o resultado foi esse modelo:</p>
<p><a href="http://fabianosoriani.files.wordpress.com/2011/03/bulky.png"><img class="aligncenter size-medium wp-image-342" title="Bulky" src="http://fabianosoriani.files.wordpress.com/2011/03/bulky.png?w=300&#038;h=175" alt="" width="300" height="175" /></a></p>
<p>Como o meu objetivo aqui foi bastante específico, vou só passar uma idéia geral do modelo:</p>
<ul>
<li>As celulas azuis são usadas pelo usuário para inserir dados</li>
<li>As celulas cinza são de uso exclusivo do sistema para feedback</li>
</ul>
<p>O sistema está muito crú ainda, mas pode ser uma boa fazer uma Gem com isso. Vou deixar em anexo o Model e o Controller que usei para fazer a importação de dados &#8216;bulky&#8217;.</p>
<p><a href="https://gist.github.com/855729" target="_blank">Model GIST</a></p>
<p><a href="https://gist.github.com/855734" target="_blank">Controller GIST</a></p>
<p>A idéia no código é que cada linha pode ser julgada por 3 resultados distintos:</p>
<ul>
<li>CADASTRADA: é considerada já persistida e ignorada futuramente</li>
<li>INVÁLIDA: Por já ser cadastrada, dada uma condição de busca</li>
<li>IGNORADA: No caso de linha vazia (<em>invisível</em>)</li>
</ul>
<p>O que eu considero de mais legal nesse sistema é a capacidade de interação bi-lateral: O usuário fornece uma quantidade massiva de dados e o sistema responde com possíveis problemas.</p>
<p><strong>Sugestão:</strong> Retornar na coluna de erros: <em>registro.errors</em> é bastante interessante pra casos onde uma validação elaborada ocorre, e o usuário tem capacidade de entender uma mensagem um tanto &#8220;confusa&#8221; <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Abraços!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Creating a Rails 2.3.8 on Google App Engine]]></title>
<link>http://fabianosoriani.wordpress.com/2010/12/11/creating-a-rails-2-3-8-on-google-app-engine/</link>
<pubDate>Sat, 11 Dec 2010 03:59:50 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/12/11/creating-a-rails-2-3-8-on-google-app-engine/</guid>
<description><![CDATA[Just hosted a experiment on Google App Engine, and it is so cool! = D It is only a shame they only s]]></description>
<content:encoded><![CDATA[<p>Just hosted a experiment on Google App Engine, and it is so cool! = D</p>
<p>It is only a shame they only support Python and Java and there is no native support for Ruby.<br />
As there are these programmers that just can&#8217;t take NO for an answer, luckily, there is <a href="https://gist.github.com/269075" target="_blank">this post from Woodie</a>, he uses JRuby for getting the job done, along with a gem called <strong>rails_appengine</strong>.<br />
Just be sure to read some of my comments by the bottom about some patches if things go wrong with you (<em>I&#8217;m using Ubuntu 10</em>).</p>
<p>The first surprise you get as you start your app, and start playing with this framework mod, is that is a MVC for sure, but there is no ActiveRecord (or migrations).. how come?!<br />
It happens to be that AppEngine does not support MySQL or any of the regular DBs, instead it uses its own proprietary solution, <strong>DataStore</strong>. In order to access it, the solution provided is TinyDS, that you can learn a lot more on this <a href="https://github.com/takeru/tiny_ds/blob/master/examples/basic/app.rb">github file by Takeru</a>; although it is a Sinatra app, the code to query is the exact same.<br />
After understanding some of that I got surprised by the declaration of a type called :list, that looks very much like an Array, I wonder if there are different methods to update and query it..</p>
<p>App Engine also has services for storing large files, images, caching, tasks, e-mail, among other handy services! Besides, <em>the free-quotas are large</em>.<br />
Unfortunately, as this version is, there is no directly bind (or if so, there is no documentation about) for all those services provided.<br />
On that same example from Takeru however, one can observe it requires &#8216;appengine-apis/memcache&#8217;, and uses it on the app. I tried myself and found success using it, what leads me to believe that the services may be accessed likewise.</p>
<p>For the moment I&#8217;m pretty happy with today&#8217;s progress, it was extremely easy to deploy, <a href="http://findgamesdb.appspot.com/" target="_blank">my app</a>. Just be sure to setup the WEB-INF/app.yaml with the proper app-id.</p>
<p>For those who have interest the account is free and enabled for any Google Account, make your here. I will just leave the warning, for the time being that this thing seems pretty &#8216;green&#8217;, I just would be very careful planing to develop any complex App to host over this Ruby implementation because it looks like I could hit a dev wall at anytime.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Rails User Action Logger]]></title>
<link>http://fabianosoriani.wordpress.com/2010/11/01/rails-user-action-logger/</link>
<pubDate>Mon, 01 Nov 2010 23:20:34 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/11/01/rails-user-action-logger/</guid>
<description><![CDATA[Hi! The problem: I need to log my user&#8217;s actions on the site ( a game) so I can Datamine it la]]></description>
<content:encoded><![CDATA[<p>Hi!</p>
<p><strong>The problem:</strong> I need to log my user&#8217;s actions on the site ( a game) so I can Datamine it later, It is also very desirable to investigate each user individually.</p>
<p><strong>My solution: </strong><em>(still primitive)</em> A ruby lib that is able to accumulate some actions (in a array) and then append it to a log  File. A<em>after_filter</em> @ <em>application_controller</em> that auto-logs every action taken. The action can set a custom warn level, and a custom message.</p>
<p>I made a GIST with this. <a href="http://gist.github.com/659039" target="_blank">link1</a> <a href="http://gist.github.com/659043" target="_blank">link2</a></p>
<p><strong>Usage:</strong> The usage is actually automatic, but you can custom with 2 options on a Action, Example:</p>
<pre class="brush: ruby; title: ; notranslate" title="">
def create
    @user_session = UserSession.new(params[:user_session])
    
    @bf_errors = 10
    @bf_minutes = 10
    #logger.info &#34;&#62;&#62;&#62;&#62; #{@bfw.to_s}, #{session['create_number']}&#34;
    
    if @bfw = brute_force_warning
      captcha = verify_recaptcha(:model =&#62; @user_session, :message =&#62; &#34;Favor digite as letras que aparecem distorcidas&#34;)
      if (@bfw == :active &#38;&#38; !captcha)
        @warn = 8
        @action_obs = &#34;#{@bf_errors} per #{ @bf_minutes} minutes. Email:#{@user_session.try( :email)}, pass: #{@user_session.try( :password)}. &#34;
        render :action =&#62; &#34;login&#34;
        return true
      end
    end
</pre>
<p><strong>Discussion:</strong> I chose JSON for being very extremely easy to parse on JavaScript, which has great Libs for data visualization.<br />
I considered the rails Buffered Logger, Beanstalk and direct File Write, but I believe the method I&#8217;m using is way faster than those. My assumption is because all I do is native to Ruby, with minimal memory use, and disc access.</p>
<p><strong>TODO:</strong><br />
. A plugin that handles this.<br />
. A controller-action-view to visualize this Data =)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Installing rails 3.0.0 on Ubuntu 10.4]]></title>
<link>http://fabianosoriani.wordpress.com/2010/09/21/installing-rails-3-0-0-on-ubuntu-10-4/</link>
<pubDate>Tue, 21 Sep 2010 18:06:23 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/09/21/installing-rails-3-0-0-on-ubuntu-10-4/</guid>
<description><![CDATA[How I did all Wrong I had ruby 1.8.7 and Installed RVM as ROOT, not the gem I did the above without]]></description>
<content:encoded><![CDATA[<p><strong>How I did all Wrong</strong></p>
<ul>
<li>I had ruby 1.8.7 and Installed RVM as ROOT, not the gem</li>
<li>I did the above without knowing about the working of RVM</li>
<li>I had ruby 1.8 and 1.9 installed, and the gem had a confused env</li>
<li>Lots of other confusing paths and installs<strong><br />
</strong></li>
</ul>
<p>Now, the good part.. Simple rails 3.0 install</p>
<p><strong>How I did it work*:</strong></p>
<ul>
<li>Removed RVM by the great command <em>sudo rvm implode</em></li>
<li>Also ruby1.9, <em>sudo aptitude remove ruby1.9</em></li>
<li>Updated my gems:</li>
</ul>
<blockquote><p><code>sudo gem install rubygems-update<br />
gem env &#124; grep 'EXECUTABLE DIRECTORY'<br />
sudo `gem env &#124; grep 'EXECUTABLE DIRECTORY' &#124; ruby -e "puts  gets.split(': ', 2).last"`/update_rubygems</code></p></blockquote>
<ul>
<li>Installed Rails 3.0.0, <em>sudo gem install rails -v3.0.0</em></li>
<li>Made a project on rails, <em>rails new dum; cd dum<br />
</em></li>
<li>Installed mysql gem, <em>bundle install</em></li>
<li><em>rails server</em></li>
</ul>
<p><strong>Great Refs:</strong><br />
<a href="http://blog.costan.us/2010/04/rails-3-development-setup-for-ubuntu.html">http://blog.costan.us/2010/04/rails-3-development-setup-for-ubuntu.html</a><br />
<a href="http://stackoverflow.com/questions/3558656/how-to-remove-rvm-ruby-version-manager-from-my-system">http://stackoverflow.com/questions/3558656/how-to-remove-rvm-ruby-version-manager-from-my-system</a><br />
<a href="http://stackoverflow.com/questions/3722701/getting-crazy-over-rails-3-rvm-gems">http://stackoverflow.com/questions/3722701/getting-crazy-over-rails-3-rvm-gems</a><br />
<a href="http://rubyonrails.org/screencasts/rails3/active-relation-active-model"> http://rubyonrails.org/screencasts/rails3/active-relation-active-model</a></p>
<p><strong>*</strong>: <del datetime="2010-11-01T23:03:04+00:00">I have not tried it for real, with several gems, I will update if anything fails</del> It is all working just fine</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby Benchmarking CASE WHEN x HASH]]></title>
<link>http://fabianosoriani.wordpress.com/2010/06/07/ruby-benchmarking-case-when-x-hash/</link>
<pubDate>Mon, 07 Jun 2010 16:45:57 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/06/07/ruby-benchmarking-case-when-x-hash/</guid>
<description><![CDATA[Greetings, Today I found a resuld I did never expected, it goes like this&#8230; Intro: I thought: i]]></description>
<content:encoded><![CDATA[<p>Greetings,</p>
<p><em>Today I found a resuld I did never expected, it goes like this&#8230; </em></p>
<p><strong>Intro:</strong> I thought: in a hash there must have a hash function that is somehow costly  to map a <strong>key</strong> to a <strong>value</strong>, right? And while learning C in my grad, I were taught that SWITCH CASE was a very fast and optimized structure.</p>
<p>So.. If i get the ruby&#8217;s equivalent CASE WHEN to map a <strong>key</strong> to a <strong>value </strong>dynamically<strong> </strong> that should be really fast! <strong>Dead Wrong</strong>!</p>
<p>I benchmarked 3 ways: A fixed CASE WHEN, a evalued CASE WHEN, and the friendly HASH, and got these results:</p>
<p>@ <strong>ruby 1.8.7</strong> (2009-06-12 patchlevel 174) [i486-linux]</p>
<pre>      user     system      total        real
CASE WHEN         1.370000   0.130000   1.500000 (  1.507988)
EVAL CASE WHEN  15.110000   0.440000  15.550000 ( 15.548754)
HASH[:sym]       1.000000   0.140000   1.140000 (  1.147406)</pre>
<p>@ <strong>ruby 1.9.1</strong>p243 (2009-07-16 revision 24175) [i486-linux]</p>
<pre>      user     system      total        real
CASE WHEN         0.710000   0.000000   0.710000 (  0.707460)
EVAL CASE WHEN  34.460000   0.010000  34.470000 ( 34.460126)
HASH[:sym]       0.410000   0.000000   0.410000 (  0.416476)</pre>
<p>The <strong>source</strong> is here:</p>
<pre class="brush: ruby; title: ; notranslate" title="">
require	'benchmark'

Benchmark.bm do&#124;b&#124;
 vdd = {:a =&#62;	'amor',
 :b	=&#62; 'valor',
 :c	=&#62; 'honestidade',
 :d	=&#62; 'tabela',
 :e	=&#62; 'sinceriadade'
 }

 b.report('CASE WHEN       ') do
	1_100_000.times {
		valor_unico = [:a,:b,:c,:d,:e][rand(4)]
		case valor_unico;	when :a then	'amor';	when :b then	'valor';	when :c then	'honestidade';	when :d then	'tabela';	when :e then	'sinceriadade';	else	false; end;
	}
end

 b.report(&#34;EVAL CASE WHEN &#34;) do
	$tree = 'case valor_unico;	'
	vdd.each	{	&#124;k,v&#124;	$tree	&#60;&#60; &#34;when :#{k} then	'#{v}';	&#34;	}
	$tree &#60;&#60;	'else	false; end;'
	def case_when(v)
		valor_unico	=	v
		eval $tree
	end

	1_100_000.times { case_when(	[:a,:b,:c,:d,:e][rand(4)]	)	}
 end

 b.report(&#34;HASH[:sym]     &#34;) do
	1_100_000.times { vdd[	 [:a,:b,:c,:d,:e][rand(4)]	]	}
end
end
</pre>
<p>And the <strong>Conclusion</strong> is: Using a Hash can be pretty fast, since it must be really optimized structure in Ruby!<br />
The CASE WHEN felt slow compared to the hash, <em>as weird as may be</em> <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> .<br />
Hashes still have the advantage of very simple reading, writing and updating for the programmer, they also append values easily.</p>
<p><strong>Improving:</strong> A potencial future test would be to make a hash that is way bigger than this, the results could change a little.<br />
Other idea is mapping the key for something other than a Symbol, like a String or a custom Object.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[CanTweet - A rails, twitter and html5 canvas experiment]]></title>
<link>http://fabianosoriani.wordpress.com/2010/04/01/cantweet-a-rails-twitter-and-html5-canvas-experiment/</link>
<pubDate>Thu, 01 Apr 2010 15:20:06 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/04/01/cantweet-a-rails-twitter-and-html5-canvas-experiment/</guid>
<description><![CDATA[Welcome to 1 of the coolest post I&#8217;ve done =) Me and my friend @pirelenito(+blog) we&#8217;re]]></description>
<content:encoded><![CDATA[<p>Welcome to 1 of the coolest post I&#8217;ve done =)</p>
<p>Me and my friend <a href="http://twitter.com/pirelenito">@pirelenito</a>(<a href="http://blog.pirelenito.org/">+blog</a>) we&#8217;re coding yesterday, he wanted to learn Rails, and I get something new, the result was <a href="http://www.cantweet.citrons.com.br/">this marvelous creation: the CanTweet</a></p>
<p>The highlights inner work of the code is basically how we get the info from Twitter ruby API and convert the twits length into the new Canvas tag element from HTML5,</p>
<p>Here is a small snip from our lib PV created:</p>
<pre class="brush: ruby; title: ; notranslate" title="">
require &#34;twitter&#34;

class TwitRetriever
  COUNT = 50
# ...
def sizes
    twits = []
   Twitter::Search.new.containing(@keyword).per_page(COUNT).fetch.results.each do &#124;r&#124;
      twits.push r.text.size
    end
    twits
  end
end
</pre>
<p>And finally we draw in the canvas using the functions:</p>
<pre class="brush: jscript; title: ; notranslate" title="">

var graph = document.getElementById(&#34;graph&#34;)
var context = graph.getContext(&#34;2d&#34;)
context.strokeRect()
context.strokeStyle = &#34;rgb(r,g,b)&#34;
context.beginPath()
context.lineTo(x, y)
context.stroke()
</pre>
<p><strong>Resources:</strong><br />
CANVAS<br />
- <a href="https://developer.mozilla.org/en/HTML/Canvas" rel="nofollow">https://developer.mozilla.org/en/HTML/Canvas</a><br />
- <a href="https://developer.mozilla.org/en/Canvas_tutorial" rel="nofollow">https://developer.mozilla.org/en/Canvas_tutorial</a><br />
- <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#2dcontext" rel="nofollow">http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#2dcontext</a></p>
<p>TWITTER API<br />
- <a href="http://twitter.rubyforge.org/" rel="nofollow">http://twitter.rubyforge.org/</a><br />
- <a href="http://github.com/jnunemaker/twitter" rel="nofollow">http://github.com/jnunemaker/twitter</a><br />
- <a href="http://rdoc.info/projects/jnunemaker/twitter" rel="nofollow">http://rdoc.info/projects/jnunemaker/twitter</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby Interpolation with gem interpolator (basic)]]></title>
<link>http://fabianosoriani.wordpress.com/2010/02/23/ruby-interpolation-with-gem-interpolator/</link>
<pubDate>Tue, 23 Feb 2010 17:54:19 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/02/23/ruby-interpolation-with-gem-interpolator/</guid>
<description><![CDATA[So, ruby already has lots of stuff done so you don&#8217;t have to reinvent the wheel and so is with]]></description>
<content:encoded><![CDATA[<p>So, ruby already has lots of stuff done so you don&#8217;t have to reinvent the wheel and so is with Mathematical Interpolation!</p>
<p><a href="http://interpolator.rubyforge.org/">Interpolator</a> implements ways for you to do linear, cubic, lagrange and spline interpolation easyly.</p>
<p>Check this short example:</p>
<pre class="brush: ruby; title: ; notranslate" title="">
# a curve that rise and fall fast
t = Interpolator::Table.new 0.1 =&#62; 2, 0.4 =&#62; 3, 0.8 =&#62; 10, 1.0 =&#62; 12, 1.2 =&#62; 11, 1.4 =&#62; 8
# LINEAR
 t.style = 1
 [0, 0.5, 1.0, 1.5, 2.0].each {&#124;x&#124; puts( t.interpolate(x)) }	
1.66666666666667
4.75
12.0
6.5
-1.0

# LAGRANGE
 t.style = 2
 [0, 0.5, 1.0, 1.5, 2.0].each {&#124;x&#124; puts( t.interpolate(x)) }
2.47619047619048
5.125
12.0
5.75
-13.0

# LAGRANGE 3
 t.style = 3
 [0, 0.5, 1.0, 1.5, 2.0].each {&#124;x&#124; puts( t.interpolate(x)) }
3.64021164021164
4.57936507936508
12.0
6.0625
-3.00000000000003

# CUBIC
 t.style = 4
 [0, 0.5, 1.0, 1.5, 2.0].each {&#124;x&#124; puts( t.interpolate(x)) }
1.99712997129971
4.39777444649446
12.0
6.36704335793358
7.50922509225093

# SPLINE
 t.style = 5
 [0, 0.5, 1.0, 1.5, 2.0].each {&#124;x&#124; puts( t.interpolate(x)) }
1.30687830687831
4.45535714285714
12.0
6.875
35.0000000000001

</pre>
<p>There you go, a simple use of the Interpolator, very nice lib..<br />
For tests about performance I don&#8217;t have any result or benchmark, but sure would be cool post <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://rubygems.org/gems/interpolator">Get the gem</a></p>
<p>Interpolação linear com biblioteca em ruby, fácil!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby invocando o método da minha classe e do pai também]]></title>
<link>http://fabianosoriani.wordpress.com/2010/02/09/ruby-invocando-o-metodo-da-minha-classe-e-do-pai-tambem/</link>
<pubDate>Tue, 09 Feb 2010 12:52:39 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/02/09/ruby-invocando-o-metodo-da-minha-classe-e-do-pai-tambem/</guid>
<description><![CDATA[Dada a chamada de um método de instância da classe filho (herda), Como invocar um método de instânci]]></description>
<content:encoded><![CDATA[<p>Dada a chamada de um método de instância da classe filho (herda),</p>
<p>Como invocar um método de instância de mesmo nome no pai</p>
<p>De dentro do método filho ??</p>
<p>- A resposta é <em><strong>super</strong></em> e fácil <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   <a href="http://forum.rubyonbr.org/forums/1/topics/927">+Tópico completo</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Iniciando Ruby!]]></title>
<link>http://fabianosoriani.wordpress.com/2010/01/10/iniciando-ruby/</link>
<pubDate>Sun, 10 Jan 2010 18:12:50 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/01/10/iniciando-ruby/</guid>
<description><![CDATA[Salve galera! Começando aqui com o tema mais batido que pode haver no blog de qq programador que usa]]></description>
<content:encoded><![CDATA[<p>Salve galera!</p>
<p>Começando aqui com o tema mais batido que pode haver no blog de qq programador que usa <strong>ruby</strong>, i.e., Começando a Usar Ruby!</p>
<p><em>Já lí vários desses posts e posso afirmar, nenhum deles me levou, ou levou qq um que conheço, a programar ruby, pois só a <span style="text-decoration:underline;"><strong>necessidade</strong> pode levar alguem se </span></em><em><span style="text-decoration:underline;">self.motivar!</span> mas esse aqui é realmente bom porque cobre o mais essencial, ou seja: </em></p>
<h4 style="text-align:center;">Ruby não é sinonimo de Rails nem de WebDev !!!!</h4>
<p><strong><a href="http://pothix.com/blog/development/comecando-a-falar-de-ruby" target="_self">&#62;&#62; Leia o post de PotHix</a></strong></p>
<h4 style="text-align:center;">- Ruby é açucar sintático <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </h4>
]]></content:encoded>
</item>
<item>
<title><![CDATA[MeuPonto - Personal Time Tracking ]]></title>
<link>http://fabianosoriani.wordpress.com/2010/01/10/meuponto-personal-time-tracking/</link>
<pubDate>Sun, 10 Jan 2010 17:47:19 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/01/10/meuponto-personal-time-tracking/</guid>
<description><![CDATA[Conforme comentei no ultimo post apresento.. *rufar de tambores* .. MeuPonto! Será que MeuPonto serv]]></description>
<content:encoded><![CDATA[<p>Conforme comentei no ultimo post apresento.. *rufar de tambores* .. <a href="http://github.com/flockonus/MeuPonto" target="_blank"><strong>MeuPonto</strong></a>!</p>
<p><strong>Será que MeuPonto serve para você???</strong></p>
<p>- Se você trabalha em um sistema de Banco de Horas, gosta de ruby e linha de comando (bash), então <em>SIM!</em></p>
<p><strong>Sua boca já esta salivando, e seu cérebro grita: COMO USAR ??</strong></p>
<p>- <em>Puta merda é simples! </em>Depois de instalado (<em>o que só requer 1 passo</em>), você pode usar comandos do tipo:</p>
<blockquote><p><strong>meuponto in</strong> <em>#=&#62; Você acabou de registrar entrada!</em></p>
<p><strong>meuponto out</strong> <em>#=&#62; Você acabou de registrar saída!</em></p>
<p><strong>meuponto hoje</strong> <em>#=&#62; Exibe relatório diário</em></p></blockquote>
<p>Logo teremos outras opções como relatório por data, semana e mês um interface HTML <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Baixa já o seu! é gratis!  &#62;&#62;<a href="http://github.com/flockonus/MeuPonto" target="_blank"> <strong>MeuPonto</strong></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Novo emprego e MeuPonto]]></title>
<link>http://fabianosoriani.wordpress.com/2010/01/10/novo-emprego-e-projeto-meu-ponto/</link>
<pubDate>Sun, 10 Jan 2010 17:29:00 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2010/01/10/novo-emprego-e-projeto-meu-ponto/</guid>
<description><![CDATA[Salve! - Rising from the dead blog&#8217;s graveyard Trabalho novo, rotina nova! Pois bem, comecei a]]></description>
<content:encoded><![CDATA[<p>Salve!</p>
<p><em>- Rising from the dead blog&#8217;s graveyard <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /><br />
</em></p>
<p>Trabalho novo, rotina nova! Pois bem, comecei a trabalhar <a href="http://www.guenka.com.br/" target="_blank">@Guenka</a> uma empresa de software moderna. Mas pq moderna? Eles tem departamento de desenvolvimento com Rails, pesquisa e outro de inovação em web! <strong>Nice humn?!</strong></p>
<p>Andei trabalhando num projetinho que surgiu do meu esquema de trabalho com banco de horas, e como estive aprendendo Git, resolvi conciliar as coisas e criei uma espécie de máquina de ponto pessoal em Ruby no <a href="http://github.com/flockonus" target="_blank">GitHub</a>.</p>
<p>Mais a respeito no <a href="http://fabianosoriani.wordpress.com/2010/01/10/meuponto-personal-time-tracking/" target="_self">próximo post</a>!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[dev Dia -&gt; ruby Statemachine part 1]]></title>
<link>http://fabianosoriani.wordpress.com/2009/10/05/dev-dia-ruby-statemachine-part-1/</link>
<pubDate>Mon, 05 Oct 2009 23:13:02 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2009/10/05/dev-dia-ruby-statemachine-part-1/</guid>
<description><![CDATA[Having so much fun right now! There´s been long before i had any fun on programming anything like I´]]></description>
<content:encoded><![CDATA[<p>Having so much fun right now! There´s been long before i had any fun on programming anything like I´m enjoying now <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />   the code is pretty nice so far!</p>
<ul>
<li><a href="http://www.codeproject.com/KB/aspnet/JsOOP1.aspx">Object Oriented JS</a></li>
<li><a href="http://www.sergiopereira.com/articles/prototype.js.html" target="_blank">Prototype Lib</a></li>
<li><a href="http://www.openjsan.org/doc/k/ka/kawasaki/XML/ObjTree/0.24/lib/XML/ObjTree.html" target="_blank">XML.ObjTree (JSAN) Lib</a></li>
<li>TDD ( i believe <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</li>
<li>Aptana Studio</li>
</ul>
<p>Some Snippets:</p>

		<style type='text/css'>
			#gallery-172-2 {
				margin: auto;
			}
			#gallery-172-2 .gallery-item {
				float: left;
				margin-top: 10px;
				text-align: center;
				width: 33%;
			}
			#gallery-172-2 img {
				border: 2px solid #cfcfcf;
			}
			#gallery-172-2 .gallery-caption {
				margin-left: 0;
			}
		</style>
		<!-- see gallery_shortcode() in wp-includes/media.php -->
		<div data-carousel-extra='{"blog_id":3656200,"permalink":"http:\/\/fabianosoriani.wordpress.com\/2009\/10\/05\/dev-dia-ruby-statemachine-part-1\/","likes_blog_id":3656200}' id='gallery-172-2' class='gallery galleryid-172 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>
			<dt class='gallery-icon landscape'>
				<a href='http://fabianosoriani.wordpress.com/2009/10/05/dev-dia-ruby-statemachine-part-1/ds-code-preview1/' title='ds code preview1'><img data-liked='0' data-reblogged='0' data-attachment-id="173" data-orig-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview1.png" data-orig-size="670,525" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="ds code preview1" data-image-description="" data-medium-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview1.png?w=300" data-large-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview1.png?w=670" width="150" height="117" src="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview1.png?w=150&#038;h=117" class="attachment-thumbnail" alt="ds code preview1" /></a>
			</dt></dl><dl class='gallery-item'>
			<dt class='gallery-icon landscape'>
				<a href='http://fabianosoriani.wordpress.com/2009/10/05/dev-dia-ruby-statemachine-part-1/ds-code-preview2/' title='ds code preview2'><img data-liked='0' data-reblogged='0' data-attachment-id="174" data-orig-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview2.png" data-orig-size="815,289" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="ds code preview2" data-image-description="" data-medium-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview2.png?w=300" data-large-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview2.png?w=815" width="150" height="53" src="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview2.png?w=150&#038;h=53" class="attachment-thumbnail" alt="ds code preview2" /></a>
			</dt></dl><dl class='gallery-item'>
			<dt class='gallery-icon landscape'>
				<a href='http://fabianosoriani.wordpress.com/2009/10/05/dev-dia-ruby-statemachine-part-1/ds-code-preview3/' title='ds code preview3'><img data-liked='0' data-reblogged='0' data-attachment-id="175" data-orig-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview3.png" data-orig-size="446,151" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="ds code preview3" data-image-description="" data-medium-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview3.png?w=300" data-large-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview3.png?w=446" width="150" height="50" src="http://fabianosoriani.files.wordpress.com/2009/10/ds-code-preview3.png?w=150&#038;h=50" class="attachment-thumbnail" alt="ds code preview3" /></a>
			</dt></dl><br style="clear: both" /><dl class='gallery-item'>
			<dt class='gallery-icon portrait'>
				<a href='http://fabianosoriani.wordpress.com/2009/10/05/dev-dia-ruby-statemachine-part-1/ds-site-preview1/' title='ds site preview1'><img data-liked='0' data-reblogged='0' data-attachment-id="176" data-orig-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-site-preview1.png" data-orig-size="282,406" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="ds site preview1" data-image-description="" data-medium-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-site-preview1.png?w=208" data-large-file="http://fabianosoriani.files.wordpress.com/2009/10/ds-site-preview1.png?w=282" width="104" height="150" src="http://fabianosoriani.files.wordpress.com/2009/10/ds-site-preview1.png?w=104&#038;h=150" class="attachment-thumbnail" alt="Early Result" /></a>
			</dt>
				<dd class='wp-caption-text gallery-caption'>
				Early Result
				</dd></dl>
			<br style='clear: both;' />
		</div>

<p>To get the XML into HTML I built a really small ruby script that convert the file into a JS var and considering using the same script on the website to remove some of the &#8216;garbage&#8217; out of the XML and print it on the page.</p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:0;width:1px;height:1px;"><a href="http://www.openjsan.org/doc/k/ka/kawasaki/XML/ObjTree/0.24/lib/XML/ObjTree.html" rel="nofollow">http://www.openjsan.org/doc/k/ka/kawasaki/XML/ObjTree/0.24/lib/XML/ObjTree.html</a></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Dia-&gt;Statemachine: The tools]]></title>
<link>http://fabianosoriani.wordpress.com/2009/10/02/dia-statemachine-the-tools/</link>
<pubDate>Fri, 02 Oct 2009 22:03:03 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2009/10/02/dia-statemachine-the-tools/</guid>
<description><![CDATA[First of all, download DIA! =D Select UML for the sheet pallet. Only a reduced set of the tools will]]></description>
<content:encoded><![CDATA[<p>First of all, <a href="http://projects.gnome.org/dia/" target="_blank">download DIA</a>! =D</p>
<p>Select <strong>UML</strong> for the <strong>sheet</strong> pallet. Only a reduced set of the tools will be interpretated, the <strong><span style="color:#ff0000;">X</span></strong>´s will be ignored.</p>
<p>These is the selection of tools available:</p>
<div class="wp-caption aligncenter" style="width: 508px"><a href="http://fabianosoriani.files.wordpress.com/2009/10/tools.png"><img class=" " title="dia - rubystatemachine" src="http://fabianosoriani.files.wordpress.com/2009/10/tools.png?w=498&#038;h=475" alt="dia - rubystatemachine" width="498" height="475" /></a><p class="wp-caption-text">dia -&#62; ruby statemachine</p></div>
<p>Ok! A quick note about the arrows, is that the 3 of those can be used under any TRANSITION circunstances (since all connect state with state), but you will see if you try, some arrows fit better in the indicated manner.</p>
<div id="attachment_169" class="wp-caption aligncenter" style="width: 327px"><img class="size-full wp-image-169" title="simple ex" src="http://fabianosoriani.files.wordpress.com/2009/10/simples-ex.png?w=317&#038;h=421" alt="simple ex" width="317" height="421" /><p class="wp-caption-text">simple ex</p></div>
<ul>
<li>So that is a very basic example, it is valid, notice that you need to indicate a BEGINNING connected with a STATE since the XML has no defined order among the elements.</li>
<li>Not all TRANS are required to declare an action,  the EVENT alone is ok, but if your going to declare both  use  <strong>/</strong> to separate &#60;  <strong><em>event_name / run_action</em></strong> &#62;</li>
<li>On STATES you may use the fields: <strong><em>Entry action</em></strong> and <strong><em>Exit action</em></strong> they will trigger respectively <strong><em>on_enter</em></strong>,<strong><em> on_exit</em></strong></li>
</ul>
<p><em><br />
</em></p>
<p><strong><em>Soon part 2</em></strong></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Converting Dia diagram to Ruby StateMachine =)]]></title>
<link>http://fabianosoriani.wordpress.com/2009/10/02/converting-dia-diagram-to-ruby-statemachine/</link>
<pubDate>Fri, 02 Oct 2009 16:58:53 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2009/10/02/converting-dia-diagram-to-ruby-statemachine/</guid>
<description><![CDATA[Hello !!! After a loooong while I decided to dev something just so I don´t get too rusty! The concep]]></description>
<content:encoded><![CDATA[<p>Hello !!!</p>
<p>After a loooong while I decided to dev something just so I don´t get too rusty!</p>
<p><strong><span style="color:#333399;">The concept<span style="color:#333399;"> is</span></span><span style="color:#333399;">:</span></strong> <a href="http://statemachine.rubyforge.org/" target="_blank">Statemachine</a> is a fine implementation of FSM for ruby (<em><a href="http://blog.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/" target="_blank">act_as_state_machine</a> is also an option</em>). The author  wrote a <a href="http://blog.8thlight.com/statemachine">nice guide </a>for layperson (or forgetful like me <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ) BUT <strong>still something is missing</strong>! In all examples there are diagrams, those are very necessary for us to understand what to implement in the machine, but a huge one´s mat get really confusing. <strong>The solution</strong> would be to convert the Diagram into Ruby code!</p>
<p><strong><span style="color:#333399;">The plan:</span></strong> Dia is a great and easy to use diagramming tool, <em>win and linux able</em>, it´s save file is in XML.What i´m gonna do is make a JS that is able to parse it´s code and generate ruby =)</p>
<p><strong><span style="color:#333399;">Execution:</span></strong></p>
<ol>
<li>Make a definition of the simbols accepted by the conversion. Document it (blog).</li>
<li>Understand the <em>.dia</em> XML, what is gonna be used inside?</li>
<li>Make a website that receives a file <em>.dia</em></li>
<li>Make a response page with the contents</li>
<li>In this page, JS will read, convert (the XML inside <em><span style="text-decoration:underline;">.dia</span></em>) and return a ruby code for the <a href="http://statemachine.rubyforge.org/" target="_blank">statemachine</a> in a <em>textarea</em>.</li>
<li>In future (<em>since the future is unknown this may never happen..</em>) there will be no upload to the server, a Flash reads the content and return to JS.</li>
</ol>
<p><strong><span style="color:#333399;">Purpose:</span></strong> I love ruby lang, every Computer Science student must at least once use a <strong>Finite State Machine</strong>, <em>maybe</em> this interface will make things more attractive so he have a taste of ruby programming..</p>
<p>Long automata&#8217;s description may be very boring and error prone this should make the assembly easier.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby script to remove svn folders]]></title>
<link>http://fabianosoriani.wordpress.com/2009/03/19/ruby-script-to-remove-svn-folders/</link>
<pubDate>Thu, 19 Mar 2009 22:53:52 +0000</pubDate>
<dc:creator>fabianosoriani</dc:creator>
<guid>http://fabianosoriani.wordpress.com/2009/03/19/ruby-script-to-remove-svn-folders/</guid>
<description><![CDATA[This code is so useful and pretty easy too when we want to remove recursively recursive the .svn fol]]></description>
<content:encoded><![CDATA[<p>This code is so useful and pretty easy too when we want to remove recursively recursive the .svn folders from a project we want to send.</p>
<p>The credit of the original code is <a href="http://codesnippets.joyent.com/user/HelgeG">@HelgeG</a> guy</p>
<p>This was only enhanced to make a warning first and count the kills, still under testing.</p>
<pre class="brush: ruby; title: ; notranslate" title="">
require 'find'
require 'fileutils'

puts &#34;\n\t\t\t! WARNING !\n\nYou are about to remove .SVN from this folder and all sub-folders&#34;
puts &#34;# This program is to be used on a backup folder, no way back! \nCONTINUE?&#34;
resp = gets

if resp.include?('s') &#124;&#124; resp.include?('y')
	i = 0
	Find.find('./') do &#124;path&#124;
	  if File.basename(path) == '.svn'
		FileUtils.remove_dir(path, true)
		i += 1
		Find.prune
	  end
	end
	puts &#34;#{i} .svn folders were deleted along with their juice..&#34;
	sleep 3
end
puts &#34;Bye&#34;
sleep 1
</pre>
<p><strong>Use on your own Risk!</strong></p>
]]></content:encoded>
</item>

</channel>
</rss>
