teleren/devto huggingface dataset:
Today I learned `git diff master..feature`
Tags: todayilearned, bash, git
Published: 2020-03-13 21:08:59

---
title: Today I learned `git diff master..feature`
published: true
date: 2020-03-13 04:08:00 UTC
tags: todayilearned, bash, git
canonical_url: https://waylonwalker.com/blog/today-i-learned-git-diff-feature-master/
---

Today I learned how to diff between two branches.

```
git diff master..feature
```

Sometimes we get a little `git add . && git commit -m "WIP"` happy and mistakenly commit something that we just can't figure out. This is a good way to figure out what the heck has changed on the current branch compared to any other branch.

## Example

Let's create a new directory, initialize git and toss some content into a readme.

``` bash
mkdir git-diff
git init
echo "hello there" > readme.md
git add . && git commit -m "hello there"
cat readme.md
```

After all of that, we have a git repository on our local machine with a single file `readme.md` that contains the following.

``` txt
hello there
```

##  Create a branch and ✍ edit
![git branch icon](https://dev-to-uploads.s3.amazonaws.com/i/h5cgvxp0gy1xtm4kj6pl.png)

Let's checkout a new branch called Waylon and change the word `there` to `Waylon` in our `readme.md` file, then diff it.

``` bash
git checkout -b Waylon
echo "hello Waylon" > readme.md
git add . && git commit -m "hello Waylon"
git diff
```

``` diff
- hello there
+ hello waylon
```

At this point we have one commit.  Things are really straightforward, and our diff will be the same between the last commit and the master branch since.  Let's make another commit by adding the date.

``` bash
echo "hello waylon\n\n$(date)" > readme.md
cat readme.md
git diff
```

``` diff
hello Waylon
+
+ Fri 13 Mar 2020 04:23:21 PM DST
```
👆 At this point, our diff doesn't tell us the whole story between our current state and master, only between our current state and our last commit.  Let's commit our changes and compare our branch to master.

``` bash
git add . && git commit -m "add date"
git diff master..waylon
```

``` diff
- hello there
+ hello Waylon
+
+ Fri 13 Mar 2020 03:43:21 PM DST
```

## Git is powerful

I learn small tricks like this often with git.  Many times I forget about it and have to come back to re-learn. Sharing my thoughts gives me a better chance of remembering.

### [Newsletter](waylonwalker.com/newsletter)

I recently started a newsletter, you can keep up with all of the things I am working on with a monthly-ish newsletter.  Sign up at [waylonwalker.com/newsletter](waylonwalker.com/newsletter)
Showing Intruders with Python
Tags: python, showdev, learning
Published: 2020-03-13 03:45:04

Well that took longer than expected. 
Remember his to do things in python wasn’t to bad, not was scanning the network for unknown MAC addresses. The hardest part for me was sending the message to my discord server. 

To get the MAC address I had to run the script as root. But that way the web-hooks wouldn’t work. So if I just ran the script in normal python mode the web-hooks would work but the MAC address would come through. It was all very frustrating. 

But I finally figured it out. Instead of getting the MAC addresses through nmap, it had to grab all the IP addresses nmap saw and then use arp call on the IP to get the MAC. It's not exactly how I want it to work, it's slower than just using nmap to get them, but hey this is the only way I could get both parts working consistently.

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

Is this a perfect solution? Far from it. I'm sure there's better ways to do this but for my purposes, learning and not having a ton of time, it works for me.

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

If you're interested here's the link to the repo. I'm open to suggestions if you have any ideas to make it better!

https://gitlab.com/keskidev/tabatha
Enums & Switch
Tags: Swift, Enums, Switch, Enumerations
Published: 2020-03-13 03:36:56

When building an app, one might consider using an enum/ enumeration instead of a String or Int to limit the choices a user can pick from. Expecting the user to input their choice via String or Int opens the door to millions of possibilities. Instead, create a new type with an enum where instances of that type can only have values correlating to one of the specified cases. Each possible value in an enum is called case. When using enums, it’s always clear what the possible values are and what they mean. Enum values can be compared using ==, or a switch statement to test for all possible values. 

A switch statement is another way of making decisions in your code. They can be used to switch any type of value but work especially well with enums. One thing to note about switch statements is that they must be exhaustive, meaning every possible case in the enum must be dealt with. To handle an unspecified value, use a default case. 
Finally, like structs, you can add calculated properties and methods to enums.
Day 93 : Understand
Tags: hiphop, code, coding, lifelongdev
Published: 2020-03-13 02:59:57

_liner notes_:
- Professional : Today we presented the projects we have been working on 
the past couple of days for out internal hackathon. Like I said in a previous post, I was working on a simpler online OBS that meetup organizers can log into to stream their events to otech.events. I ran into an issue demoing at first because I think I had to many things streaming and screen sharing between the meeting and the project I made. In the end, I was able to get it working. There was a slight issue in the live stream, but I think that was because of all the aforementioned connections, plus my WiFi is not the greatest. So yeah, here is the recording of the live stream of using the project I made for the demo session:
{% youtube Cg40SVMmAfk %} 

- Personal : Planned to go to the OrlandoJS meetup, but it was cancelled because of the Coronavirus. I can understand where they are coming from and think they did the responsible thing.

![An island with a large mountain in the middle of smaller islands surrounding it and large mountain range in the distance in Lofoten Islands, Norway](https://dev-to-uploads.s3.amazonaws.com/i/pjj9u1l0y3p3hp5csev6.png)

For the rest of the night, I'll probably put together the radio show for this week.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube MouC40EsCUU %}
Algorithm 101: The max product of three numbers in an array
Tags: algorithm, codility, maxproduct, triplet
Published: 2020-03-13 01:47:50

This question appears in Codility.com, it is about finding the maximum product from three numbers in an array of integers.
Below is the full question
![codility question](https://res.cloudinary.com/kingsconsult/image/upload/v1584062964/codility1_wqtbw5.png)
This is my simple solution in python

``` 
def solution(A):
    # write your code in Python 3.6
    A.sort()
    if A[-1] < 0:
        prod = (A[-1] * A[-2] * A[-3])
    elif A[0] * A[1] > A[-2] * A[-3]:
        prod = (A[-1] * A[1] * A[0])       
    else:
        prod = (A[-1] * A[-2] * A[-3])
    return prod
```
This is my explanation
First of all, I sort the array to have the elements in an ascending order
secondly, if the last element in the array is less than 0, that means all the elements in the array are negative, therefore, the maximum product will be the product of the last three elements
thirdly, I consider the situation where the product of two negative is greater than the product of the second to the last and third to the last (remember in mathematics that - * - = +)
lastly, if all the other conditions are not satisfied, therefore the maximum product will be the product of the last three elements
Setting up your computer for Data Science
Tags: python, jupyter, bash, linux
Published: 2020-03-13 01:28:32

Before you start this I'd recommend that you use Linux or the Macintosh operating system for data science as it a better option than using Microsoft Windows

- Install Anaconda
     There's usually a controversy between using Anaconda or Pypi for data science based on experience and research I have found that Anaconda is a better option because virtual environments are built directly into it and its compatibility with R.
* After downloading the file from the official website https://www.anaconda.com/distribution/
* Navigate to the directory
* Run the installation with "bash <filename.sh>" and follow the on-screen prompts


- Install common python packages for Data Science 
For macOS or Linux anaconda's virtual environment is activated using the following command :
     conda activate
and it is deactivated using the following command :
     conda deactivate


- Jupyter Notebook 

Jupyter Notebook is a tool for doing interactive data science work in your browser. Jupyter notebook is activated in your bash terminal 
* Type the following command jupyter notebook .  A browser window will open, showing the Juptyer environment. By default, you will be in a file browser view.  In the file browser, find where you have a Jupyter notebook. If you don't have materials for a course or tutorial that you have downloaded, you can download this fun Jupyter notebook and then open it in the file browser.  Click on one of the notebooks (*.ipynb) files to get started!

- To stop Jupyter notebook:
    Ctrl+c is used to stop the Jupyter notebook server running on your machine.
Metodos Virtuales en Java
Tags: java, beginners, ocp
Published: 2020-03-13 01:24:34

_"Java virtual method" son metodos que una subclase hereda de una clase padre y que pasan a ser sobrescritos dandole un comportamiento polimorfo. Este proceso tambien es comunmente llamado sobreescritura de metodos._

Para que un metodo sea valido para ser sobreescrito no pueden ser de tipo staticos ni finales y como minimo deben tener `protected` como modificador de acceso.

Supongamos que tenemos la siguente Clase padre `Mammal`

```java
public class Mammal {
    
    
    public void swim() {
        System.out.println("A mammal swimming");
    }
}

```

Estas dos subclases `Elephant` y `Hippo` que heredan de `Mammal` y sobreescriben el metodo `public void swim()` de la misma.

```java
public class Elephant extends Mammal {
    
    @Override
    public void swim() {
        System.out.println("An Elephant swiming");
    }
}

public class Hippo extends Mammal {
    
    
    @Override
    public void swim() {
        System.out.println("A hippo swiming");
    }
}
```
Si ejecutamos el siguente ejemplo podemos ver como obtenemos resultados distintos llamando el mismo metodo de la clase `Mammal` cuando asignamos a la variable una nueva instancia de cada subtipo.

```java
...
public static void main(String ...args) {
        
        
        Mammal mammal = new Elephant();
        mammal.swim();
        
        mammal = new Hippo();
        mammal.swim();
        
    }
```

al final obtenemos.


```
An Elephant swiming
A hippo swiming
BUILD SUCCESSFUL (total time: 1 second)

```






_Gracias por tomarte el tiempo para leer. Saludos Cordiales :)_
Running One-on-One meetings remotely
Tags: leadership, remote, management, productivity
Published: 2020-03-13 01:15:17

---
title: Running One-on-One meetings remotely
published: true
description: Now that Remote and WFH are a reality for many, we need to strike a good strategy to maintain communication and alignment within our organizations.
tags: leadership, remote, management, productivity
---

With the recent events worldwide, many have been put in a position that was potentially not even an option before, working remotely from home (WFH).

Some of us are lucky enough that WFH was already a reality, part or full time. So we already have mechanism and processes put in place to enable a good performance. But for those whom this is an out of the blue, brand new experience, things might not run so smoothly.

As a leader in my organization, it is one of my responsibilities to run frequent One-on-One (1on1) meetings with my team members. In them we discuss matters like current projects, career prospects, growth and learning opportunities, etc.

I still prefer, when possible, to run these kind of meetings in person. However, in our current situation, that might not be possible. What's important is that we don't disrupt or stop the flow of these very important interactions with our team members.

The way I approach running 1on1s remotely is by relying on good technology. Here are the different aspects, and associated products, I use to run mine.

**Videoconferencing**

It is very important that we can talk and see each other. We use a Google Meet, part of the Enterprise GSuite but now [promised to all](https://cloud.google.com/blog/products/g-suite/helping-businesses-and-schools-stay-connected-in-response-to-coronavirus).

We also have a paid Slack account that allows us to have video conferencing and screen sharing capabilities. This is very helpful too for other types of activities, like collaboration on tasks and projects.

**Meeting Notes**

As part of your 1on1s you should be sharing an agenda, the notes taking during the meeting, and track the actions that came of it.

We use [15five](https://www.15five.com) and I'm very happy with it. Besides the above mentioned needs to run 1on1s, it also offers all other manner of features regarding employee empowerment. Like 360 reviews, OKRs, etc.

But sometimes a simple shared document could be all that is needed. I recommend it to be in a format that can not only be shared, but co-authored as well. A 1on1 is a two-way communication process.

**Conclusion**

There is no one way to approach this, but it is good to share ideas and experiences.

This is how I'm managing mine, what are you doing on yours?
React Native Props
Published: 2020-03-13 00:54:22

A maioria dos componentes pode ser personalizado quando criados, com parâmetros diferentes. Esses parâmetros de criação são chamados props, abreviação de propriedades.
Por exemplo, um componente básico do React Native é o Image. Ao criar uma imagem, você pode usar um suporte nomeado source para controlar a imagem exibida.
```react
import React, { Component } from 'react';
import { Image } from 'react-native';

export default class Bananas extends Component {
  render() {
    let pic = {
      uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
    };
    return (
      <Image source={pic} style={{width: 193, height: 110}}/>
    );
  }
}
```
Observe as chaves ao redor {pic} – elas incorporam a variável pic no JSX. Você pode colocar qualquer expressão JavaScript dentro de chaves no JSX.

Seus próprios componentes também podem ser usados props. Isso permite criar um único componente usado em muitos locais diferentes do seu aplicativo, com propriedades ligeiramente diferentes em cada local. Basta consultar this.props em sua função render. Aqui está um exemplo:
```react
import React, { Component } from 'react';
import { Text, View } from 'react-native';

class Greeting extends Component {
  render() {
    return (
      <View style={{alignItems: 'center'}}>
        <Text>Hello {this.props.name}!</Text>
      </View>
    );
  }
}

export default class LotsOfGreetings extends Component {
  render() {
    return (
      <View style={{alignItems: 'center', top: 50}}>
        <Greeting name='Rexxar' />
        <Greeting name='Jaina' />
        <Greeting name='Valeera' />
      </View>
    );
  }
}
```
Usar name como suporte permite personalizar o Greeting componente, para que possamos reutilizá-lo para cada um de nossos cumprimentos. Este exemplo também usa o Greeting componente em JSX, assim como os componentes internos. O poder de fazer isso é o que torna o React tão legal – se você deseja ter um conjunto diferente de primitivos da interface do usuário para trabalhar, basta inventar novos.

A outra coisa nova acontecendo aqui é o View componente. A View é útil como um contêiner para outros componentes, para ajudar a controlar o estilo e o layout.

Com props e os básicos Text, Image e View componentes, você pode construir uma grande variedade de telas estáticas. Para saber como fazer seu aplicativo mudar com o tempo, você precisa aprender sobre o [Estado](https://dev.to/alexandrefreire/react-native-state-5aeh).

Texto traduzido de https://facebook.github.io/react-native/docs/props
React Native State
Published: 2020-03-13 00:48:57

Existem dois tipos de dados que controlam um componente: props e state. props são definidos pelo pai e são corrigidos durante a vida útil de um componente. Para dados que vão mudar, temos que usar state.

Em geral, você deve inicializar state no construtor e chamar setState quando desejar alterá-lo.

Por exemplo, digamos que queremos criar texto que pisque o tempo todo. O próprio texto é definido uma vez quando o componente piscante é criado, portanto, o texto em si é a prop. O “se o texto está ativado ou desativado no momento” muda com o tempo, de modo que deve ser mantido state.
```react
import React, { Component } from 'react';
import { Text, View } from 'react-native';

class Blink extends Component {

  componentDidMount(){
    // Toggle the state every second
    setInterval(() => (
      this.setState(previousState => (
        { isShowingText: !previousState.isShowingText }
      ))
    ), 1000);
  }

  //state object
  state = { isShowingText: true };

  render() {
    if (!this.state.isShowingText) {
      return null;
    }

    return (
      <Text>{this.props.text}</Text>
    );
  }
}

export default class BlinkApp extends Component {
  render() {
    return (
      <View>
        <Blink text='I love to blink' />
        <Blink text='Yes blinking is so great' />
        <Blink text='Why did they ever take this out of HTML' />
        <Blink text='Look at me look at me look at me' />
      </View>
    );
  }
}
```
Em um aplicativo real, você provavelmente não definirá o estado com um timer. Você pode definir o estado quando tiver novos dados do servidor ou da entrada do usuário. 

Você também pode usar um contêiner de estado como Redux ou Mobx para controlar seu fluxo de dados. Nesse caso, você usaria Redux ou Mobx para modificar seu estado, em vez de ligar setState diretamente.

Quando setState é chamado, o BlinkApp renderiza novamente seu componente. Ao chamar setState no Timer, o componente será renderizado novamente toda vez que o Timer funcionar.

O estado funciona da mesma maneira que no React, portanto, para obter mais detalhes sobre como lidar com o estado, você pode consultar a [API React.Component](https://reactjs.org/docs/react-component.html#setstate) . 

Texto traduzido de https://facebook.github.io/react-native/docs/state
Use Sourcery to review your Python code on GitHub!
Published: 2020-03-13 14:15:18

---
title: Use Sourcery to review your Python code on GitHub!
published: true
description: Get an instant quality boost to your open source codebase.
date: 2020-03-13 00:00:00 UTC
tags: 
canonical_url: https://sourcery.ai/blog/sourcery-github/?utm_souce=Blog&utm_medium=RSS
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/3bdppamujlkek3g3nssm.png
---


We're excited to announce that Sourcery is now available as a GitHub app!

It is currently available for public repos - and will always be totally free for open source.


* **Easy setup** - Get started quickly with out-of-the-box GitHub integration.

* **Check your whole codebase** - On installation Sourcery will open a pull request for each of the installed repos suggesting changes across the whole codebase.

* **Ensure great quality** - Sourcery will review every pull request from then on and suggest improvements. 

* **Apply the changes instantly** - Just merge the Sourcery pull requests to boost your code quality straight away.



To get it for free just sign up [here](https://github.com/apps/sourcery-ai/installations/new)!
City Builder in Unity3D | Part 1
Tags: youtube, game, city, builder
Published: 2020-03-12 23:58:24

Hey!
I started a series in YouTube, in this series I'm writing a City Builder Game,
Come, Watch and leave a Like and Subscribe :)

{% youtube DkDlhbl1x04 %}

> Like this post? 
> Support me via [Patreon](https://www.patreon.com/eranelbaz)
> Subscribe to my [YouTube Channel](https://www.youtube.com/channel/UCVUNeBGM5wZJKcOx0QwAaTA?sub_confirmation=1)
Coding In Quarantine
Tags: watercooler
Published: 2020-03-12 23:45:41

*No, I don't have coronavirus. In fact I'm the safest possible place (for now).*

About a year back, my wife and I registered our details for [FluCamp](https://flucamp.com/). Just after Christmas they gave me a call and asked if I wanted to participate in a preventative drug trial for Respiratory syncytial virus. 

"Yummy", I said.

Fast forward two months and now I'm currently quarantined in Whitechapel, London. I've been in this room for the last four days, with ten more to go.

Not something I'd admit to my LinkedIn network exactly, but y'all seem cool.

I haven't told any of my clients, and have spent each day answering emails, building websites and growing my knowledge of javascript through online courses.

It's a bit weird being locked in a box - when was the last time you spent two weeks in one room? But stranger still is how reasonably smoothly everything still runs when cut off from the outside world.

Even so, turning on the TV each morning and seeing the latest #coronavirus news is a little scary. It seems to be really doing a number on the UK and I'm of course worried about my friends and family.

Anyway, just wanted to share. If anyone has any questions, feel free.
What do you call modern (frontend?) dependency architecture? 
Tags: architecture, javascript
Published: 2020-03-12 23:24:14

If I google 'dependency architecture' I get a bunch of results like [this one](https://www.informit.com/articles/article.aspx?p=2832399), which has either this circle model: 

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

Or this n-tier layered one. (To be fair, the [source of this image](https://rules.ssw.com.au/do-you-use-a-dependency-injection-centric-architecture) is criticising this approach for not supporting dependency injection). 

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


It seems to me that these diagrams are more relevant to conventional monoliths, where you seperate out your data access logic, your application logic, your frontend logic. 

However, I'm thinking about in the context of microservices, and modern SPAs where there's a lot more logic happening on the frontend. 

[This talk by Monica Lent](https://youtu.be/TqfbAXCCVwE?t=907), where she's talking specifically about frontend architecture is what I have in mind. 

Any suggestions, new key words to google? Or is the onion/n-tier architecture just are relevant to microservices and SPAs?
Work From Home
Tags: help, personal, slimcoder
Published: 2020-03-12 22:31:27

---
title: Work From Home
published: true
description: 
tags: help , personal , slimcoder
---
Guy's today is work from home day for me because of coronovirus.

I am from Pakistan so i want to ask this question with all of you.
So what do you think is work from home is good thing to do? 

I think today will be productive day for everyone from my company.
Because working from home is good choice and no time waste at all.
Identifying Deprecated Go Modules with Gocheckit
Tags: go, devops, security
Published: 2020-03-12 22:25:51

Identifying Deprecated Go modules is not supported by default by the Go ecosystem so I created a small tool (Gocheckit) to help me identify potentially Deprecated modules for a Go project. You can find the tool and more info here on Github here https://github.com/brompwnie/gocheckit.

I'll probably write a proper post at a later point describing the tool and processes in more detail.