<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Felipe Brigatto</title>
    <description>The latest articles on DEV Community by Felipe Brigatto (@felipebrigatto).</description>
    <link>https://dev.to/felipebrigatto</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F39345%2F2977b1d1-7443-4b70-ab6b-d59bb9d9e4ee.jpg</url>
      <title>DEV Community: Felipe Brigatto</title>
      <link>https://dev.to/felipebrigatto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/felipebrigatto"/>
    <language>en</language>
    <item>
      <title>Using Roku without its controller</title>
      <dc:creator>Felipe Brigatto</dc:creator>
      <pubDate>Wed, 18 Oct 2017 11:11:17 +0000</pubDate>
      <link>https://dev.to/felipebrigatto/using-roku-without-its-controller-c62</link>
      <guid>https://dev.to/felipebrigatto/using-roku-without-its-controller-c62</guid>
      <description>&lt;h3&gt;
  
  
  Using Roku without its controller (on a trip)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fWnYDPvp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/830/1%2AEmEzNWePSqi5jfhdmucBng.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fWnYDPvp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/830/1%2AEmEzNWePSqi5jfhdmucBng.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So… I decided to trip with my girlfriend and one stuff that we like to do is watch some Netflix or Anime. We noticed that packed only: roku, ac adapter and HDMI cable, no controller!&lt;/p&gt;

&lt;p&gt;Without a controller, we could do nothing: can’t select app, can’t connect do Wi-Fi, even the common things like play a YouTube video from smartphone wasn’t possible…&lt;/p&gt;

&lt;p&gt;After some precipitation, we started Googling… But no success, was all about with the same Wi-Fi network using the controller app. Great, we discovered that there is an app to controll the Roku! Now, how to make it work???&lt;/p&gt;

&lt;p&gt;More google and no success. I solved this problem and decided to write the solution here, to help travelers :)&lt;/p&gt;

&lt;p&gt;You’ll need &lt;strong&gt;2 (two) smartphones&lt;/strong&gt; to make this happen.&lt;/p&gt;

&lt;p&gt;First, with smartphone A create an Ad-hoc network with the same SSID (wireless name) and Password from your home, don’t need the 3G/4G enabled to this work. With this ad-hoc the roku’ll connect automatically, it “thinks that’s in home so why not auto connect?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_gRT-ETV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/391/1%2A85I5eEzUSOJWn1au3I0Rxg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_gRT-ETV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/391/1%2A85I5eEzUSOJWn1au3I0Rxg.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Second, on the smartphone B download the controller app then connect to the ad-hoc network. This smartphone should connect automatically too, since it’s your Wi-Fi from home. And now the app will find for and a Roku in the network… Boom! Founded!&lt;/p&gt;

&lt;p&gt;Now just go to setting on Roku and connect to the Wi-Fi from hotel/airbnb/place you are to not end your 3G/4G plan before the trip. Just turn off ad-hoc on smartphone A to not drain your battery and connect both smartphone to the hotel/airbnb/place’s Wi-Fi.&lt;/p&gt;

&lt;p&gt;That’s all! That simple. I don’t know how didn’t find this on Google :(&lt;/p&gt;

&lt;p&gt;Don’t forget to enjoy your trip.&lt;/p&gt;

</description>
      <category>wifi</category>
      <category>trip</category>
      <category>tips</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Java x Ruby: Differences for beginners</title>
      <dc:creator>Felipe Brigatto</dc:creator>
      <pubDate>Tue, 02 May 2017 20:51:15 +0000</pubDate>
      <link>https://dev.to/felipebrigatto/java-x-ruby-differences-for-beginners-eba</link>
      <guid>https://dev.to/felipebrigatto/java-x-ruby-differences-for-beginners-eba</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fproxy%2F1%2AzVdJoDXQMbh91HasFKCuTg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fproxy%2F1%2AzVdJoDXQMbh91HasFKCuTg.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of my first programming experience with Ruby on Rails was pleased. Obviously each language has it’s own way to write vicious code, so I’ll share my first steps with Ruby.&lt;/p&gt;

&lt;p&gt;The basic difference is you don’t initialize objects, we can use own structs to initialize. In Java, there is something not like, but is a beginning:&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Java
int[] vector_ = new int[5];
int[] vector_pre_defined = {1,2,3,4,5};

// Ruby
vector = []
vector_pre_defined = [1,2,3,4,5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Structurally seem the same, but in Ruby we can increment easily:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vector &amp;lt;&amp;lt; 1 # [1]
vector &amp;lt;&amp;lt; [2,3] # [1,[2,3]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Java, we need to create an ArrayList to do almost the same thing than Ruby:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ArrayList&amp;lt;Integer&amp;gt; vector = new ArrayLista&amp;lt;Integer&amp;gt;;
vector.add(1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With that we got freedom of when and what insert new element into Array.&lt;/p&gt;

&lt;p&gt;Now come a practical example: we have a JSON about an order from e-commerce, in it there is shipping info not yet filled. We need to fill it based on this rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If carrier is blank, add shipping_method if is filled, otherwise add blank String&lt;/li&gt;
&lt;li&gt;If carrier and method are filled, add them concatenated.&lt;/li&gt;
&lt;li&gt;Otherwise, add blank String.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not thinking too much, in Ruby we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if not order.shipping_carrier
 values &amp;lt;&amp;lt; order.shipping_method || ""
elsif order.shipping_carrier &amp;amp;&amp;amp; order.shipping_method
 values &amp;lt;&amp;lt; order.shipping_carrier + " - " + order.shipping_method
else
 values &amp;lt;&amp;lt; ""
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if !order.getShippingCarrier() {
 if order.getShippingMethod() value = order.shipping_method;
 else value = “”;
} else if order.shipping_carrier &amp;amp;&amp;amp; order.shipping_method {
 value = order.shipping_carrier + " - " + order.shipping_method;
} else
 value = "";
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using a sequential logic, those codes are hard to read and didn’t use advantages of both languages!&lt;/p&gt;

&lt;p&gt;To start refactoring in Ruby, there is a compact function of Arrays, that returns without null values, so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[order.shipping_method, order.shipping_carrier].compact
# [“Method”] # if shipping_carrier blank
# [“Carrier”] # if shipping_method blank
# [“Method”,”Carrier”] # if both are filled
# [] # if both are blank
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this, we guarantee we have an information as a result to our little method. If both values are blank, it satisfies the basic rule.&lt;/p&gt;

&lt;p&gt;Com isso garantimos ter sempre a informaÃ§Ã£o Ãºtil, mesmo se estiver nula teremos um array vazio. que podemos converter para uma String vazia. EntÃ£o com nosso novo array, podemos juntar seus valores usando o mÃ©todo join.&lt;/p&gt;

&lt;p&gt;There is one more function to use: &lt;code&gt;join()&lt;/code&gt; that let use a String to concatenate String.&lt;/p&gt;

&lt;p&gt;Finally, with one line we satisfy all conditions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;values &amp;lt;&amp;lt; [order.shipping_method, order.shipping_carrier].compact.join(" - ")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That was my every first code in Ruby a year ago, I started in Java, and that was a paradigms break, because there are many manners to write a descent code and only practice (and cultural) will turn bad code into good ones.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://medium.com/skyhub-labs/java-x-ruby-diferen%C3%A7as-ao-programar-8fb675b2cde" rel="noopener noreferrer"&gt;&lt;em&gt;medium.com&lt;/em&gt;&lt;/a&gt; &lt;em&gt;on May 2, 2017 in Portuguese.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>rails</category>
      <category>introduction</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
