teleren/devto huggingface dataset:
Create and use a result captor in Mockito
Tags: java, mockito, testing
Published: 2022-05-13 15:02:11

> Today I will show you how to create a Mockito captor

In [Mockito](https://site.mockito.org/) it exists the possibilty to use [ArgumentCaptor](https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#21) to allow developers to verify the arguments used during the call of mocked method, but not the result itself.
Indeed, in the current release of Mockito it's not possible to capture it and my solution to do that is to build a ResultCaptor class which implements the Answer interface and generify it for more conveniance.

Let's take a look.

## Create the ResultCaptor class

```
public static class ResultCaptor<T> implements Answer<T> {
    private T result = null;

    public T getResult() {
        return result;
    }

    @Override
    public T answer(InvocationOnMock invocationOnMock) throws Throwable {
        //noinspection unchecked
        result = (T) invocationOnMock.callRealMethod();
        return result;
    }
}
```

In this quite simple implementation we see that the ResultCaptor class implements the Answer interface which force to override the answer method. We use this "interceptor" to call the real method of spied bean and capture the result to store it in the current context.

## Use the ResultCaptor class

```
ResultCaptor<ServiceResult> serviceResultCaptor = new ResultCaptor<>();
var message = new Message("id", "hello all!");
doAnswer(serviceResultCaptor).when(serviceSpy).sendMessage(message);
// do the call
var serviceResult = serviceResultCaptor.getResult();
assertThat(serviceResult).isNotNull();
assertThat(serviceResult.getWhatever()).isEqualTo("Whatever");
```
And that's it !

## Let me try it

If you want a Spring boot example you can clone the repository [github.com/ulrich/mockito-result-captor-demo](https://github.com/ulrich/mockito-result-captor-demo)

_Crédit photo : https://pixabay.com/fr/users/jackmac34-483877/_
Ultimate Guide on Developer Burnout
Published: 2022-05-13 14:55:41

As the Mental Health Awareness Month is ongoing let's talk about developer burnout 🌿

**Fact #1** Statistics. [67% (sic!) respondents confirm](https://www.indeed.com/lead/preventing-employee-burnout-report) Covid19 made burnout problem even worse. 

**Fact #2** Burnout might be early stage of depression.

That’s why it is CRUCIAL:

- **For managers** - catch early signs of burnout of employees & build mental health program 
- **For employees** - be aware of symptoms of #burnout and take care of their mental health

Vectoly has prepared the most detailed [Ebook](https://www.getace.io/ebooks/developer-burnout?utm_source=devto&utm_campaign=ebook_promo) ever (it's FREE) on developer burnout, where you'll find: 

- What is developer burnout?
- How to spot it?
- Top 10 reasons for developer burnout
- Best practices & tools to prevent burnout

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3w6zyhej7sil1kevdnxt.png)

[GET EBOOK FOR FREE](https://www.getace.io/ebooks/developer-burnout?utm_source=devto&utm_campaign=ebook_promo)
What was your win this week?
Tags: discuss, weeklyretro
Published: 2022-05-13 14:54:00

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

Hey there! 


Looking back on this past week, what was something you were proud of accomplishing?

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Fixing a tricky bug
- Getting a new haircut... or whatever else might spark joy ❤️ 

---

Have a wonderful weekend!


![Ninja Turtles dancing with the words "Have a good weekend!" below them](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p4nk4db7c6gqk7wvyel2.gif)
Install NVM/Node on MAC OS
Tags: nvm, node, mac, webdev
Published: 2022-05-13 14:48:57

1- Install homebrew
```sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

2- Installing brew to environment
```sh
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
```

3- Now, close the terminal and open a new terminal.

4- Installing NVM,
```sh
brew install nvm
```

5- Installing latest node version
```sh
nvm install node
```

6-Installing specific node version say 16.15.0
```sh
nvm install 16.15.0
```

7- Listing all the install node versions
```sh
node ls
```

8- Switching to specific node version
```sh
node use 16.15.0
```
Paracetamol.js💊| #116: Explica este código JavaScript
Tags: javascript, webdev, spanish, discuss
Published: 2022-05-13 14:48:02

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Avanzado</mark></center>

```js
function asyncFn(){
 return new Promise((resolve, reject) => {
   (true)
    ? setTimeout(() => resolve("Bien!"),3000)
    : reject(new Error("Mal"))
 });
}

async function result(){
  try{
    const res = await asyncFn();
    console.log(res)
  }catch(err){
    console.log(err.message)
  }
}

result();
console.log("Hola mundo")
```

A. `Mal`
B. `Hola mundo`, `Bien!`
C. `Bien!`, `Hola mundo`
D. `Promise { <pending> }`

Respuesta en el primer comentario.

---
¿Es necesario tener título para Trabajar como desarrollador?
Published: 2022-05-13 14:42:13

---
title: ¿Es necesario tener título para Trabajar como desarrollador? 
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yyu7j7rc7ybutymi2iz3.jpg)


Si te ha gustado el contenido, no olvides compartir y seguirme en twitter [@luismejiadev](https://twitter.com/luismejiadev)

**Artículos relacionados**

- [Antes de abandonar la universidad lee estos 5 consejos](https://dev.to/luismejiadev/antes-de-abandonar-la-universidad-lee-estos-5-consejos-2fa6)
🍔Animated Menu Toggle Button | Html CSS & Javascript
Tags: html, css, beginners, javascript
Published: 2022-05-13 14:34:45

Create An Animated Menu Toggle Button | Html CSS & Javascript, step-by-step from scratch.

***

{% youtube U3QMh9wpV0E %}

***

**Source Code:**

A Simple Markup:

```html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Animated Menu Toggle Button</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<div class="toggle">
    <span></span>
    <span></span>
    <span></span>
</div>

<script src="app.js"></script>
</body>
</html>
```

Then a Couple of Lines of CSS:
```css
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #e9ecef;
}

.toggle{
    position: relative;
    width: 70px;
    height: 70px;
    background: #fff;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
}

.toggle span{
    position: absolute;
    width: 40px;
    height: 4px;
    background: #4263eb;
    border-radius: 4px;
    transition: 0.5s;
}

.toggle span:nth-child(1){
    transform: translateY(-15px);
    width: 25px;
    left: 15px;
}

.toggle.active span:nth-child(1){
    width: 40px;
    transform: translateY(0px) rotate(45deg);
    transition-delay: 0.125s;
}

.toggle span:nth-child(2){
    transform: translateY(15px);
    width: 15px;
    left: 15px;
}

.toggle.active span:nth-child(2){
    width: 40px;
    transform: translateY(0px) rotate(315deg);
    transition-delay: 0.25s;

}

.toggle.active span:nth-child(3){
    transform: translateX(60px);
}
```

**Follow us on YT**
https://bit.ly/3oBQbc0
Macarons — Building a chat roulette app for Slack
Tags: showdev, slack, laravel
Published: 2022-05-13 14:29:28

Last year we tapped into building Slack apps. 
Our first project was our decision record app [Loqbooq](https://loqbooq.app). And while building a Slack app looks simple on first glimpse, it turned out to be very challenging. Especially user management and shared channels caused a lot of headache for us.

When we had finally achieved building and releasing our first Slack app, we thought it would be much easier to build another one based on that.

And so we did.

**Within just a few weeks we build [Macarons](https://macarons-roulette.app), a chat roulette app to connect teams.**  
We know there are already quite a few chat roulette apps for Slack like Donut, Snack or Hallway.  
But we found those either too complicated, too expensive, or missing important features.

Macarons is simple to setup but at the same time comes with some neat features that make chat roulettes more fun for everybody:

**🧁 Quick and Easy**
Just add the Macarons app to a Slack channel and it will automatically pair off random members for (virtual) coffees.

**🎰 Control the Odds**
For each channel you can control how often and when chat lotteries happen, as well as how many people should be matched together.

**🧊 Ice Breakers**
Let Macarons get conversations started with predefined ice breakers or set your own custom topics for each round.

**🏖 Take a skip day**
Independent of a channels meeting interval, each user can always individually pause their participation or decide to only take part every other time.


**You can try Macarons for free and we really appreciate any feedback:  
[macarons-roulette.app](https://macarons-roulette.app)**
A beginners first look at useState()
Tags: react, usestate, jsx
Published: 2022-05-13 14:26:43

When first learning javascript, you may want to know how to make certain things happen when somebody clicks a button perhaps, or even mouses over a specific point on your web page. After learning that this is done with addEventListeners, in my case, I moved on to react.js and ignorantly assumed you would use the same functionality for user interaction. Instead of an addEventListener, React has it's own function for user interactivity called useState(). 


useState may be one of the most useful functions, which is called a "hook", that allows you to plug into different functionality in your code to be able to change the state of that code. 

For instance, if you were coding out a button and decided you wanted the button to change it's inner text with an onClick function, this could be done by simply setting a state of...


```
const [isClicked, setIsClicked] = useState(false)
```


In this example, I have created a state for whether or not the button has been clicked and then a setter function (setIsClicked) to alter that state. To actually change the button, you would create a handle click function that would change the state...


```
const handleClick = () => {
    setIsClicked(isClicked => !isClicked)
}
```


This callback function simply calling the setter function, and inside of the setter function, we changing the boolean of the state, so since we initially set our useState to false, it will now be true. However, there is one more step to completing our process of setting up useState.


Next we have to set our button to an if statement and in our case we are going to use a ternary, which is just a more minimal version of an if, else statement. So let's code that ternary...


```
{isClicked ? <button>In Cart</button> : <button>Add To Cart</button> }
```


In our ternary we simply wrote that if the button had been clicked (if our state switched to true) then we would want our button to display "In Cart". If the state hadn't changed and was still false, the button would contain the text, "Add To Cart". 

This is a very simple and easy way to set up state in react. It can look scary and believe me, it was scary for me to at first, but it's one of those things that with time you will begin to understand it more, just know anytime you have a piece of code you want your user to be able to interact with, useState will be your go to. 

You can see why useState is so important because your web application could have dozens of points for user interactivity. 


Aside from buttons, useState can also be used to change things such as search bars, inputs, displaying database or api information, mouseover events and a whole list of others. useState is an extremely efficient and powerful hook in react.js which is why it is so crucial to learn. So put in some practice with it and get that web application rolling!


Oh! and happy coding!
Azure App Service
Tags: pass, azure, cloud, iaas
Published: 2022-05-13 14:25:04

App Service Web Apps is a fully managed compute platform that is optimized for hosting websites and web applications. This platform-as-a-service (PaaS) offering of Microsoft Azure lets you focus on your business logic while Azure takes care of the infrastructure to run and scale your apps. It available for windows or Linux.

## Azure App Serivce
Azure App Services are extremely useful for developers. It offers Web Apps, API Apps, Mobile Apps and Function Apps (that run Azure Functions). These apps are incredibly powerful and can literally get you up and running in minutes. They provide a host of amazing features like (auto)scaling, easy authentication, offline sync (for Mobile Apps), hybrid connections and much, much more. One feature that these apps share is probably the most underrated one that many people don’t know about.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3kr6e73pqeuoqabsj15d.png)
Node v18, Redux v8 and new plugins - Frontend News #25
Tags: frontend, react, typescript, redux
Published: 2022-05-13 14:16:45

{% youtube T_zP5K9WcAY %}
Hi! How about some frontend news before the weekend? The newest episode with a bunch of updates and releases just arrived on our channel  👇

What’s in Frontend News #25?
🟣 Node v18.0 release
🟣 Jest 28: changes and features
🟣 New Figma Plugin For Storybook
🟣 Typescript 4.7 BETA
🟣 React-Redux v8.0.0
🟣 React Native 0.68
🟣 Firefox 100


Enjoy, you can read the article at [Frontend House](https://frontendhouse.com/frontend-news/node-v18-redux-v8-and-new-plugins-frontend-news-15).
Symfony, Elasticsearch - builder pattern and DTO search criteria object - Part 4 Tutorial
Published: 2022-05-13 13:57:23

Hi, the 4th article devoted to the theme: “How to work with ElasticSearch using Symfony PHP framework” already ready for reading. Here will speak about how to transform our requests parameters at the DTO criteria object. All details are here: "[Symfony, elasticsearch - builder pattern and DTO search criteria object](https://sergiiblog.com/symfony-elasticsearch-builder-pattern-and-dto-search-criteria-object/)". Have a pleasant reading.
Learn to Code by Making Hip Hop Beats
Tags: python, programming, beginners, computerscience
Published: 2022-05-13 13:53:34


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8am1jdean4y0stn9lrm8.jpg)
Code Beats uses a different approach to teaching computer programming. By creating hip-hop beats, we can teach the foundational concepts of computer programming in an engaging and motivating way. In classes held by computer science professors and music professionals, we use TunePad to code the songs using Python. We had more than 300 students registered for our last summer camp, with participants 12 years old on average. Participants were 57.4% male, 40.1% female, and 2.5% preferring not to say. Almost two-thirds of the participants (64.8%) were non-white, with 37.6% self-identified as African-Americans. By the end of this summer camp, students declared to enjoy the experience and were proud of their work products.

Check out the video here: [NSF STEM for All Video Hall](https://stemforall2022.videohall.com/presentations/2340)
Breves.it - a service that can help you to avoid uninteresting job position
Tags: showdev, sideprojects
Published: 2022-05-13 13:52:56

---
title: Breves.it - a service that can help you to avoid uninteresting job position
published: true
tags: #showdev #sideprojects
---
Hi,
after getting tired of numerous cognitive interviews for job positions that did not match my profile, I decided to build a service that helps me select potentially interesting job positions and those to avoid without having to do cognitive interviews.
The service is very simple but very useful. It allows the user to write a questionnaire to share with a recruiter / headhunter, and based on the answers, decide whether or not to continue with the cognitive interview.

The service is available [here](https://breves.it/?campaign=devto) and it is completely free.


feedbacks are appreciated :)
Uninstall Node on MAC OS
Tags: mac, node, uninstall, webdev
Published: 2022-05-13 13:51:51

Open your MAC terminal.

1- Go to directory.

```sh
cd /usr/local/include/
```

2- Delete node folder.

```sh
sudo rm -rf node
```

3- Go to directory.

```sh
cd /usr/local/lib
```

4- Delete folder node_modules

```sh
sudo rm -rf node_modules
```

5- Go to directory.

```sh
cd /usr/local/bin
```

6- Delete other related folders.

```sh
sudo rm -rf node npm npx
```
Activate links of Laravel Blade based on current route name
Tags: laravel, blade, php, composer
Published: 2022-05-13 13:48:54

Consider a navigation menu with a bunch of links and you are trying to activate them based on the current active route name. In normal case you have to return the `currentRouteName()` from the controller or maybe in view composer or any other place. I have wrote a simple Laravel composer package that makes it a little bit simpler.
You can take a look it here: [https://github.com/tuytoosh/active](https://github.com/tuytoosh/active).
For installation use composer require command like this:

```
composer require tuytoosh/active

```
Then use `@active()` directive in your blade files.

```
<a href="#" class="@active('home')">Home page</a>

```
Without this package you have to write sth like this:

```
<a href="#" class="@if(Route::getCurrentRouteName() == 'home') active @endif">Home page</a>

```
After version `1.7.0` You are able to define an array of route patterns like this:
```
class="@active(['admin.dashboard', 'user.dashboard'])"
```
If you find it use full give a star :)
Thank you for reading.
Storage vs Memory vs Calldata - Understanding Data Locations in Solidity
Tags: solidity, web3, tutorial
Published: 2022-05-13 13:46:32

---
title: Storage vs Memory vs Calldata - Understanding Data Locations in Solidity
published: true
description: Storage vs Memory vs Calldata - Understanding Data Locations in Solidity
tags: Solidity, Web3, tutorial
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0u7kgpr6cxkenq1c7lv2.png
canonical_url: https://www.jenniferbland.com/storage-vs-memory-vs-calldata-understanding-data-locations-in-solidity/
---

Solidity provides value types and reference types. Reference types are arrays, mappings and structs. Value types are all other data types like string, int, and boolean. When you define a reference type you have to define the "data location" to determine where the data is stored. The three data locations are `memory`, `storage` and `calldata`. In this article I will be explaining the difference between them.


## Memory

Variables stored in memory are not written to the blockchain.  To be stored in memory a variable has to be defined inside a function. These variables are temporary and will be destroyed once the function has completed.

Memory variables are mainly used for assisting in performing some type of calculation or operation during the life of the function. Once the function is complete these variables are no longer needed so they are removed from memory.

Since these variables only exist during the execution of the function, they are not accessible from outside anywhere outside the function.

## Storage

Unlike a memory variable, any variable defined as storage is written to the blockchain. Since these variables are written to the blockchain they are persistent. 

A storage variable can be access from anywhere inside the smart contract and can possibly be also accessed outside the smart contract.

All global variables are by default storage variables.

Any variable defined as storage will incur gas fees since it is written to the blockchain.


## Calldata

**Calldata** is only valid for parameters of external contract functions. Calldata is a non-modifiable, non-persistent area where function arguments are stored. It behaves mostly like memory.

Any variable defined as calldata cannot be modifiable. In simple terms this means that you cannot change the value of the state of that variable. This is why this data type is assigned to parameters of functions. The data passed into the function is not modified but will be used within the function and a new variable will be returned.
VR Coding Mock Interview - Longest substring w.o repeating characters
Tags: programming, beginners, tutorial
Published: 2022-05-13 13:46:15

[Check out the video
](https://www.youtube.com/watch?v=z4IA8GOGhM4)

Verdict: No Hire Score: 2/5

The candidate is a bright and well-spoken engineer that was able to work through the problem, but only after several hints. The number of hints paired with the lack of confidence around runtime analysis lead this to be a no hire!

Advice
The candidate should add some more structure to how he approaches interview problems. He has a natural intuition that is helping him get 60% of the way there, but adding some more structure to his interviews with an improved confidence around runtime analysis would get him across the finish line!

A helpful structure for solving DSA problems: bit.ly/3JDuSjV

Do you have any advice for the candidate? Let us know in the comments.

Rating Coding: 4 Communication: 3 Problem Solving: 2 Inspection: 2 Review: 1

What Went Well

Was able to code quickly
Able to articulate his ideas
Started by writing examples and reasoning through them
Well spoken
What Needs Improvement

improve confidence on Big O analysis.
Had issues identifying the sliding window pattern that leads to the optimal solution
Additional investigation out of the gate. Asking questions about input/output would help
The candidate went silent at times when thinking. I had to ask to see what was going on in their head
Didn't review his code
0:00 Inspection 4:57 Strategy 30:44 Coding 35:45 Didn't review

Studying for programming interviews? Join [Hackpack](https://www.hackpack.io/)