teleren/devto huggingface dataset:
Como começar a estudar Java?
Tags: java, junior, career, developer
Published: 2020-02-27 14:04:54

Escrito por [Leila Farias](github.com/leilasoliveira) especialmente para @elasprogramam

Parabéns pra você que escolheu Java para ser a sua linguagem de programação! :smile: Você se tornará uma excelente javeira!

Mas... OK. Você já deu o primeiro passo, para onde seguir? Como estudar? Que materiais usar?

Vou falar aqui sobre minha experiência.

Quando decidi estudar a linguagem Java, ainda na faculdade, busquei por vários materiais de estudo e cai no site da Caelum (escola de treinamentos em TI).
Eles tinham uma página do site dedicada para disponibilizar apostilas gratuitamente sobre várias tecnologias. Por sorte, eles ainda têm essa página para download das apostilas e você poderá baixá-las, clicando [aqui](https://www.caelum.com.br/apostilas).

Usei a apostila **Java e Orientação a Objetos** e **Java para Desenvolvimento Web**. As apostilas falam um pouquinho de lógica de programação, mas se estiver difícil acompanhar, recomendo a leitura do artigo [Lógica de programação: a base de tudo](01-por-onde-comecar/logica-de-programacao.md).
Você pode usar esta minha experiência para sair do lugar e começar seus estudos, ou pode procurar por outros materiais semelhantes (em outro artigo, farei um compilado de sites com materiais de estudo para linguagem Java).

_A dica que vale pra tudo é_: faça **TODOS** os exercícios, exemplos, pesquise suas dúvidas no [Stackoverflow](https://pt.stackoverflow.com/) (certamente alguém já passou pelos mesmos problemas que você), nos grupos de programação (sempre pesquise primeiro antes de publicar sua pergunta), etc. Aproveite e estude um pouco de Git (é meio que obrigatório nos dias de hoje, viu!) e suba seus códigos no GitHub para todos verem seu talento!

**_Dica bônus_**: crie _um projeto seu_ com a tecnologia que estiver usando. Por exemplo, faça um sistema para uma biblioteca usando Java para Web, imagine e anote todos os cenários possíveis (para emprestar livros, o sistema deve ter uma relação de livros catalogados, como seria o cadastro desses livros?). Aqui, não apenas Java você estudará, mas também banco de dados, front-end (html, css, javascript). É bem mais legal estudar desta forma, na minha opinião, você acaba aprendendo uma stack inteira (palavrinha da moda para conhecimento desde o front-end até o back-end).

Aqui vai uma lista de algumas tecnologias que você vai ouvir falar e que com certeza vai estudar a maioria delas:
- JSF
- Hibernate
- Spring Framework
- VRaptor
Javascript Array Condensing
Tags: challenge, javascript
Published: 2020-02-27 13:57:06

I have a cool challenge idea in Javascript.

Let's say you have an array of integers that can be any size.  For example...
```javascript
arr = [0, 0, 0, 4, 5, 1, 0, 5, 2, 0, 5];
```

I challenge you to write a method that shifts all values greater than 0 to the front of the array.  So the result would be...
```javascript
arr = [4, 5, 1, 5, 2, 5, 0, 0, 0, 0, 0];
```

GO!
What's the worst code you have seen by a senior dev?
Tags: discuss, javascript, learn
Published: 2020-02-27 13:49:07

Hey all! So, I was going through a project codebase handled by a 4 year experienced dev and found a silly code and laughed out of hell seeing it. It is as follows,

```
if(data.isRequired === true)
```

Thought of sharing here. Sometimes, as we grow, we forget the basics and all good. By no means, I doubt the dev, but it is very important to review code :)
Ruby/GTK3 - Switch
Tags: ruby
Published: 2020-02-27 13:35:10

---
title: Ruby/GTK3 - Switch
published: true
description: switch widgets with ruby/gtk3
tags: ruby
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/yfil99wa4c2ys8wvgvsm.png
---

`gem install gtk3`

# Switch

A Gtk.Switch is a widget that has two states: on or off.
You can use the `notify::active` signal. 

![Lots of switches](https://dev-to-uploads.s3.amazonaws.com/i/v0ikakjckw9h7nmnmaey.png)

```ruby
require 'gtk3'

class SwitcherWindow < Gtk::Window
  def initialize
    super
    set_title 'Switch Demo'
    set_border_width 10

    grid = Gtk::Grid.new
    grid.set_column_spacing 6
    grid.set_row_spacing 6
    add grid

    4.times do |i|
      2.times do |j|
        switch = Gtk::Switch.new
        switch.signal_connect('notify::active') { |s| on_switch_activated s }
        switch.set_active [true, false].sample
        grid.attach switch, i, j, 1, 1
      end
    end
  end

  def on_switch_activated(switch)
    state = switch.active? ? 'on' : 'off'
    puts "Switch was turned #{state}"
  end
end

win = SwitcherWindow.new
win.signal_connect('destroy') { Gtk.main_quit }
win.show_all
Gtk.main

```

* [Python example](https://python-gtk-3-tutorial.readthedocs.io/en/latest/button_widgets.html#id5)
try-catch
Tags: python, beginners
Published: 2020-02-27 13:30:39

Errors can happen if a <a href="https://python.org">Python</a> program is running. There are many types of errors, like a "couldn't open file error" or "zero division error".

If an error pops up, that doesn't mean your program should crash. 

So how do you stop it from crashing?

You can use the <a href="https://pythonbasics.org/try-except/">try-except</a> code. Other programming languages like C# or Java call this the try-catch block.

You can use this to *catch* errors (sounds better than *to except*). Some code examples listed below:

```python
try:
    for i in range(5):
        print(5/i)
except:
    print("Zero division")

print("End program")
```

For opening a file, where the filename is given as user input:

```python
>>> filename = input("Enter file:")
Enter file:test.txt
>>> try:
...     with open(filename) as f:
...         lines = f.read()
... except:
...     print("Couldn't open file")
... 
Couldn't open file
>>> 
```

Doing some maths, catch different types of exceptions:

```python
a,b=1,0
try:
    print(a/b)
    print('10'+10)
except TypeError:
    print("Cannot add, values are incompatible data types")
except ZeroDivisionError:
    print("Divided by zero")
```

You can apply this for function calls too, or inside functions.

```python
try:
    start()
    accel()
    turn()
except:
    print("Car error")
```
Daily Challenge #196 - Flou
Tags: challenge
Published: 2020-02-27 13:30:17

---
title: Daily Challenge #196 - Flou
published: true
series: Daily Challenge
description: Find your flow to solve the game Flou
tags: challenge
---
To play the game, you'll start with a gameMap, like this one:
<pre>
+----+
|.B..|    +,-,| --> The boundary of game map
|....|    B     --> The initial color block
|....|    .     --> The empty block
|..B.|    It is always a rectangular shape
+----+
</pre>

The goal of the game is to move the blocks in a way that would fill in the empty spaces. 

**Moving Rules** 
- Each block can only move once. 
- If it hits an obstacle, the block will make a 90 degree right turn. It will stop if it's path is still blocked. 
- Specify the direction of movement for each color block (Left, Right, Up, Down).

**Output**
- Your output should be a 2D array.
- Each subarray should contain 3 elements: [rowIndex, columnIndex, diretion]. `rowIndex` and `columnIndex are 0-based, diretion should be one of "Left", "Right", "Up" and "Down".

For the gameMap above, the output should be [[0,1,"Down"],[3,2,"Up"]].

Not all testcases have a solution, if there is no solution, please return a boolean value false.

For the gameMap above: we can move block A downward, which would make it turn right once it hits the walls, and it will stop next to where we started. We can move B up for the same 
<pre>
+----+
|aAbb|  # First colered block is designated 'A'
|aabb|
|aabb|
|aaBb|  # Second colored block is designated 'B', etc.
+----+
The output should be [[0,1,"Down"],[3,2,"Up"]].
</pre>

Awesome, so now we have all the spaces colored. If you want to see a live version of this game, you can play it here: https://www.bgames.com/puzzle-games/flou/

###Tests

<pre>
+----+
|B...|
|....|
|....|
|....|
+----+

+----+
|.AB.|
|....|
|....|
|....|
+----+

+----+
|B...|
|A...|
|....|
|....|
+----+
</pre>

Good luck! 

***
_This [challenge](https://www.codewars.com/kata/5a93754d0025e98fde000048) comes from myjinxin2015 on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
DevRel Metrics: Orbit and Funnel
Tags: devrel, podcast
Published: 2020-02-27 13:24:54

Trick question of the week:
*Is the funnel, AAARRRP or Orbit the best framework for your metrics?*

This week, we're back to discussing metrics. Always a difficult subject, as still, there is no perfect recipe for DevRel metrics.
The most popular frameworks are:

- "Devrel Qualified Leads" which we discussed with Mary Thengvall in our [first episode] (https://www.developermarketingpodcast.com/?utm_source=devto&utm_medium=Podcast&utm_campaign=Josh) 
- "The funnel" which has been long used in marketing 
- The "AAARRRP framework" aka "Pirate Metrics" and 
- The Orbit model, which Josh Dzielak presents in our latest episode.

**Why is the Orbit model a great fit for DevRel, compared to the funnel?** Well, for starters, it also considers the big impact of the community.  Something that the funnel does not.

Does the Orbit model have enough *gravity* to be your favourite? [Listen to the episode and find out] (https://www.developermarketingpodcast.com/?utm_source=devto&utm_medium=Podcast&utm_campaign=Josh).

**Josh Dzielak** *is a software engineer for over 15 years. He enjoys building tools for developers and creating resources that help ensure their success. Currently, he's the co-founder of Orbit, helping companies win the hearts and minds of developers. Previously, he was the Developer Relations Lead at Algolia, the VP Engineering at Keen IO and a principal engineer at Disney.*

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ees7kbupii4flc0n1uio.png)
Exercism Ruby - Resistor Color Duo
Tags: exercism, ruby
Published: 2020-02-27 13:16:40

---
title: Exercism Ruby - Resistor Color Duo
published: true
description: If you want to build something using a Raspberry Pi, you'll probably use resistors. For this exercise, you need to know two things about them...
tags: exercism, ruby
series: Exercism Ruby
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--vZNNvhQv--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/ugyvp6xn69upc1u5evqa.png
---


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/afv87q7cc50f8qfbk74z.png)

If you want to build something using a Raspberry Pi, you'll probably use resistors. For this exercise, you need to know two things about them:

* Each resistor has a resistance value.
* Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read. To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. Each band has a position and a numeric value. For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15.

In this exercise you are going to create a helpful program so that you don't have to remember the values of the bands. The program will take color names as input and output a two digit number, even if the input is more than two colors!

The colors are mapped to the numbers from 0 to 9 in the sequence: Black - Brown - Red - Orange - Yellow - Green - Blue - Violet - Grey - White

From the example above: brown-green should return 15 brown-green-violet should return 15 too, ignoring the third color.

source [Maud de Vries, Erik Schierboom](https://github.com/exercism/problem-specifications/issues/1464)

```rb
require 'minitest/autorun'
require_relative 'resistor_color_duo'

# Common test data version: 2.1.0 00dda3a
class ResistorColorDuoTest < Minitest::Test
  def test_brown_and_black
    assert_equal 10, ResistorColorDuo.value(["brown", "black"])
  end

  def test_blue_and_grey
    assert_equal 68, ResistorColorDuo.value(["blue", "grey"])
  end

  def test_yellow_and_violet
    assert_equal 47, ResistorColorDuo.value(["yellow", "violet"])
  end

  def test_orange_and_orange
    assert_equal 33, ResistorColorDuo.value(["orange", "orange"])
  end

  def test_ignore_additional_colors
    assert_equal 51, ResistorColorDuo.value(["green", "brown", "orange"])
  end
end
```

```rb
class ResistorColorDuo
  COLORS = {
    "black"  => "0",
    "brown"  => "1",
    "red"    => "2",
    "orange" => "3",
    "yellow" => "4",
    "green"  => "5",
    "blue"   => "6",
    "violet" => '7',
    "grey"   => '8',
    "white"  => "9"
  }.freeze

  def self.value bands
    "#{COLORS[bands[0]]}#{COLORS[bands[1]]}".to_i
  end
end
```

It was great! because first I thought to use the positions array but suddenly I was thinking in hashes and finally I use it.
Daily Developer Jokes - Thursday, Feb 27, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-02-27 13:00:21

---
title: "Daily Developer Jokes - Thursday, Feb 27, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Thursday%2C%20Feb%2027%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258b2d77d4.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What's the second movie about a database engineer called?

___A:___ The SQL.
 -->
Shared Focus
Tags: development, devops
Published: 2020-02-27 14:02:51

---
title: Shared Focus
published: true
date: 2020-02-27 13:00:09 UTC
tags: Development,DevOps
canonical_url: https://chrislayers.com/2020/02/27/shared-focus/
---

A common issue I see when discussing DevOps with teams or organizations is the presence of Organizational Silos. Organizational Silos are made up of all types of people. Sometimes its a job type, like developers, qa, or infrastructure. Sometimes its a department, like accounting, or hr. Whatever the composition of these silos, they usually impact organizational performance and the ability to deliver value to end users.

![](https://chrislayers.files.wordpress.com/2020/02/1200px-silos_in_a_distillery1.jpg?w=1024)

This happens over time, with members of the silo identifying with each other, viewing those not in the silos as outsiders. Depending on the business, the silos can lose trust in the business overall and tighten ranks around their silo. The silos can turn into walled fortresses. When the silos get in the way, the silos are more focused on their own success than the success of the organization.

This can also happen with leaders. Leaders trying to turn their areas into fiefdoms. Leaders concerned about their power, responsibilities, or bragging rights. Either way, like the silos, situations like this can lead to groups concerned about their success, instead of the success of the organization.

## Common Goals

To really succeed, to improve and to grow as an organization, everyone needs to share some common goals and shared focus across the organization. How do we bring value to users? Sure, Dept A can release X feature or function, but if it depends on Dept B to work, it brings no value. If developers can write lots of code, does that benefit the user if it isn’t tested? If that code doesn’t have resources to run on? If you’re writing code no-one wants? Or systems are built and configured but there’s nothing to run.

When everyone is working towards common goals and have a shared focus, the whole is greater than the sum of the parts. I was introduced to some of these ideas as “The First Way”. I read about this in [“The Phoenix Project: A Novel about IT, DevOps, and Helping Your Business Win” by Gene Kim](https://itrevolution.com/book/the-phoenix-project/) and “[The DevOps Handbook](https://itrevolution.com/book/the-devops-handbook/)“. The ways were also in a blog by Gene Kim called “[The Three Ways](https://itrevolution.com/the-three-ways-principles-underpinning-devops/)“. If you haven’t read either of these books, please go read The Phoenix Project.

![](https://itrevolution.com/wp-content/uploads/2017/01/TPP_3rd_3D_layered_010318-e1553022345260-488x700.jpg)
React Lifecycle Methods Explained
Tags: javascript, react, reactnative, webdev
Published: 2020-02-27 12:57:07

In this post, we'd discuss the lifecycle of a typical React Component.

Each component in React has several lifecycle methods that you can override to run code at particular times in the process. Lifecycle methods can be used in ES6 Class Components but not in functional  components.

![Lifecycle of A React Component](https://dev-to-uploads.s3.amazonaws.com/i/u9oj57ygu7tw0ivpqrzy.jpg)

*1. Mounting*
In the process of mounting a component, a component goes through four lifecycles methods in the following order:
  a. constructor()
  b. getDerivedStateFromProps()
  c. render()
  d. componentDidMount()

*2. Updating*

In the case where props or state of a component changes, a component goes through 5 stages in the following order:
 a. getDerivedStateFromProps()
 b. shouldComponentUpdate()
 c. render()
 d. getSnapshotBeforeUpdate
 e. componentDidUpdate()

*3. Unmounting*
A component has only one lifecycle method in the unmounting stage.
 a. componentWillUnmount()

**Lifecycle Methods Explained**

1. `constructor(props)`: This method is called when the component is first initialized. ( This is where you can set initial state values and bind class methods)

2. `render()`: This method is a lifecycle method that returns elements as an output of the component. This method must always be treated as a pure function(Meaning it must not modify the component state). It takes input as props and state and returns a new/modified element.

3. `componentDidMount()` is called when the component gets mounted. Here, you can perform async requests to fetch data from an API server.

4. `shouldComponentUpdate(nextProps, nextState)`: This method gets called everytime a component updates due to state or prop changes. The component and all it's children will render or not depending on what is returned from this method.

5. `getSnapshotBeforeUpdate(prevProps, prevState)`: In certain cases, the component needs to get information from the DOM before it is potentially changed. This method allows us to do that.

6. `componentDidUpdate(prevProps, prevState, snapshot)`: This a lifecycle method that is invoked immediately after updating, but not for the initial render. You can use it as to perform DOM operations or to perform more asynchronous requests. If your component implements the getSnapshotBeforeUpdate() method, the value it returns will be received as the snapshot parameter.

7.`componentWillUnmount()` is called before you destroy your component. You can use this lifecycle method to perform any cleanup tasks.

`componentDidCatch(error, info)` was introduced in React 16 to enable catching of errors easily in components.
CSS Nugget: Text Divider in Flexbox
Tags: css, tutorial, beginners, webdev
Published: 2020-02-27 12:53:54

In this tutorial, we'll create a fluid text divider with a single `<div>`, with the help of Flexbox and pseudo-elements.

##Preview
{% codepen https://codepen.io/codyhouse/pen/zYGwxzV %}

##HTML
The structure is super simple: a single `<div>` containing the label of the divider.

```html
<div class="text-divider">Text divider</div>
```

##CSS
We can use the ::before and ::after pseudo-elements to create two lines on both sides of the label. Because we set the display property of the .text-divider equal to flex, we can apply `flex-grow: 1` to the pseudo elements to have them occupy all the available space.

```scss
.text-divider {
  display: flex;
  align-items: center; // align text and lines vertically
}

.text-divider::before,
.text-divider::after {
  content: '';
  height: 1px;
  background-color: silver;
  flex-grow: 1; // both lines will expand to occupy the available space
}
```

A final touch would be using a CSS custom property to set the gap between the label and the lines:

```scss
.text-divider {
  display: flex;
  align-items: center;
  --text-divider-gap: 1rem; // set a customizable gap between label and lines
}

.text-divider::before,
.text-divider::after {
  content: '';
  height: 1px;
  background-color: silver;
  flex-grow: 1;
}

.text-divider::before {
  margin-right: var(--text-divider-gap);
}

.text-divider::after {
  margin-left: var(--text-divider-gap);
}
```
My first Chrome extension
Tags: chrome, extension
Published: 2020-02-27 12:45:20

Hi people, how are you doing?

I’m here to show you my first published extension for Chrome Browser. It’s called Tabs Manager, and as the name says, it’s used to manage your tabs. I’ve made this extension because often I find myself with so many opened tabs that it’s hard to find the right tab.

To solve this problem, I’ve made an extension to help me search for my tabs. In the first version, the only function available is the search function, in which you can open the tabs list and filter by the name. When you find the right tab, you can press Enter and go directly to the tab.

The design was made and implemented by my friend Rodrigo. His work can be found @ [Behance](https://www.behance.net/disselliroa3a3)
The source code is available @ [GitHub](https://github.com/vkhashimoto/tabs-manager)
The extension is available @ [Chrome Web Store](https://chrome.google.com/webstore/detail/hpbdklemeflghbepnmlljhfpcjjiifmi)



I hope that this extension can be useful for you as it is to me.
Any feedback and help is welcome.

Thank you for your attention.
Best regards,

vkhashimoto