teleren/devto huggingface dataset:
Writing Maintainable Test : Enforcing test Isolation
Tags: testing, tdd
Published: 2021-11-22 18:51:07

The next few days i will share some good advice that Roy Osherove gives in his book [The Art Of Unit Testing](https://www.amazon.fr/Art-Unit-Testing-Roy-Osherove/dp/1617290890) about Writing maintainable unit test.

in this series i will talk about **test isolation**

## What is the purpose of a unit test ?
> I share the same definition of Roy , the purpose of a unit test is to test a use case in his world , we should really take the ** in his world ** seriously.


## Enforcing Test Isolation
> The basic concept is that a test should always run in its own little world, isolated from even the knowledge that other tests out there may do similar or different things.


so it is just about that, next we will talk about the first anti pattern about maintainable unit test , ** Constrained Test Order **


## Anti Pattern Constrained Test Order
> Indeed when we expect our tests to be run in a certain order, we are saying indirectly that our tests have some dependencies each other , and if the monday morning our tests are passing maybe the friday before going in week it will not pass. look at what Roy says 
<< This problem arises when tests are coded to expect a specific state in memory, in an external resource, or in the current test class—a state that was created by running other tests in the same class before the current test >>


Roy presents two patterns about that anti pattern : 

1. Flow Testing : The fact that the developer wants his tests to run in a specific order.

2. Laziness in Cleanup : A developer is lazy and doesn’t return any state their test may have changed back to its original form.


...And the solution to these patterns: 

1. Flow Testing : I think like him that if our tests should run in a specific order , so we are in the domain of ** integration testing** so for testing that flow choose Integration Testing( i will talk about that in another post maybe :) )

2. Laziness In Cleanup: look what R. Osherove says , i know it is some kind of hard but read **If you’re too lazy to clean up your database after testing, your filesystem after testing, or your memory-based objects, consider moving to a different profession. This isn’t a job for you**


This is all for Today :). Thanks for reading , and we should not forget , our code is not for us , it is for future readers , so even in writing our unit tests we should think abou them.
How Javascript Works and Execution Context?
Tags: javascript, webdev, programming, computerscience
Published: 2021-11-22 18:46:14

**Everything in Javascript happens inside an execution context.**
Execution Context is a container where whole javascript code is executed.
Execution Context has two components:
1)**Memory Component** 2)**Code Component**
Memory Component is also known as **Variable Environment**
Code Component is also known as **Thread of Execution**
![Execution Context Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7925ezfzgapkfylrg0a.PNG)
⭐In Memory component all the variables and functions are stored 
  as a key-value pairs.**
**⭐In Code Component code are executed one line at a time.**

Note:*Javascript is a Synchronous single Threaded Language*
*Synchronous means in order.
*Single Threaded means one command processes at a time.

Reference:@akshaymarch7
VSCode Productivity Hack #1
Tags: vscode, productivity, tutorial, beginners
Published: 2021-11-22 18:21:01

## Coveted Comparisons
![Intro Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/96ox9p3ysqjrzce71e9p.jpg)

Let me paint you a picture; you're working on a project that has several identical configuration files. The difference between these files is that each is used in different environments i.e. one file for the development environment, one file for the staging environment and another for the production environment.

Now wouldn't it be easier if you could open the side by side and make a comparison to see what's present in one and missing in the other ? Well, look no further, for `VSCode` has the all-powerful `Select to compare` and `Compare Selected` feature.

## Steps
1. Right click the first file you want to compare against and click `Select For Compare`
![Select for compare image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pa6bp0uwpylm5l8mgbqk.png)
2. Right the second file, which you want to compare with the first and click `Compare with Selected`
![Compare with selected image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/feqd8aw3f393t65maqpq.png)

3. Voila ! There you have it, two files one beside the other with the diffs.
![Result image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bnjalw06j8kjpvar8xrw.png)
That's all for today folks !
Lighthouse Accessibility Update
Tags: a11y, testing, tooling, todayilearned
Published: 2021-11-22 18:16:22

Lighthouse recently released v 9.0. Along with a [cool new user flow API](https://developer.chrome.com/blog/lighthouse-9-0/#lighthouse-user-flows) and other updates, [related accessibility elements](https://developer.chrome.com/blog/lighthouse-9-0/#related-accessibility-elements) with repeated `aria-labelledby` ids are listed out.

This is super helpful for me! Time was, I would have duplicated ids in my code like so:

```
<h1 id="blue-title"> Title! </h1>
<p id="blue-title"> </p>
<p id="blue-title"> </p>
```

But Lighthouse would only show the pictured warning for `<h1>` so I assumed it was the only one causing the warning, which confused me. 

Now it lists out all the elements causing the error, making it clear where the duplicated ids are. 

> Psssst, helpful hint: If you've been using an id to apply a CSS class, and that's why you duplicated it -- switch to a class!
The ephemeral miniconf - The videos
Tags: perl, conf
Published: 2021-11-22 18:08:27

**The ephemeral miniconf** was last week :sunglasses: It went very well :+1: and it’s time to share all the videos: [[The epehemeral miniconf Youtube channel]](https://m.youtube.com/channel/UCoUiZ7IoTXa1us8jvCyQl6g/videos)

#### [Native GitHub actions in Perl - Juan Julián Merelo Guervós](https://m.youtube.com/watch?v=XNi8FMEI1Wo)

[![Native GitHub actions in Perl](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4mj9zz450226zsypew3.png)](https://m.youtube.com/watch?v=XNi8FMEI1Wo)

#### [Do you really know XML? - Thibault Duponchelle](https://m.youtube.com/watch?v=NgsDI2XeLLY)

[![Do you really know XML?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tkd7fobluwiok1ozmoo.png)](https://m.youtube.com/watch?v=NgsDI2XeLLY)

#### [Automatic Observability - José Joaquín Atria](https://m.youtube.com/watch?v=a6mlym8nVHc)

[![Automatic Observability](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5v8xtmi54jgptj2bdqc.png)](https://m.youtube.com/watch?v=a6mlym8nVHc)

#### [Open Food Facts - Stephane Gigandet](https://m.youtube.com/watch?v=9SOROdmJn4g)

[![Open Food Facts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfesxwfwua9o1mxjlcdf.png)](https://m.youtube.com/watch?v=9SOROdmJn4g)

#### [Cunningham’s Law: A Year of Being Wrong on the Internet - Mark Gardner](https://m.youtube.com/watch?v=mC_FLFH8FMw)

[![Cunningham’s Law: A Year of Being Wrong on the Internet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sz8z4m815ldeidm30ccn.png)](https://m.youtube.com/watch?v=mC_FLFH8FMw)

#### [LemonLDAP::NG - Clement Oudot](https://m.youtube.com/watch?v=6jLaZt_grtM)

[![LemonLDAP::NG - Clement Oudot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/999f56qe1dxyyv5r67jx.png)](https://m.youtube.com/watch?v=6jLaZt_grtM)

#### [Once Upon Perl Acronyms - Thibault Duponchelle](https://m.youtube.com/watch?v=Zdp3rKWq3-I)

[![Once Upon Perl Acronyms](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwx8zbf3suf0lphp0ojs.png)](https://m.youtube.com/watch?v=Zdp3rKWq3-I)

# Your turn to watch/enjoy/like them now 

# :grinning:
¿Cómo crear un juego Play to Earn?
Tags: blockchain, solidity, node, phaser
Published: 2021-11-22 18:08:06

---
title: ¿Cómo crear un juego Play to Earn?
published: true
description: 
tags: blockchain, solidity, nodejs, phaser
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8np2aaun4fqlg52u186j.png
---

Proyectos como Plant vs Undead, Decentraland, Sandbox, Crypto Cars, Axie Infinity han sido el primer arcercamiento con el modelo Play to Earn. En este video vamos a ver que necesitas para crear tu juego que premie a los jugadores con tokens por jugar.

{% youtube NUJP6UMUuoQ %}

## Dependencias

Para este tutorial ocuparás [NodeJs](https://nodejs.org/es/) que recomiendo descargarlo en Linux via [NVM](https://github.com/nvm-sh/nvm#installing-and-updating) , también necesitarás un URL de RPC te recomiendo usar [INFURA](https://infura.io/), y finalmente [Metamask](https://metamask.io/) con fondos de Rinkeby Testnet que puedes conseguir desde el [Faucet](https://faucet.rinkeby.io/).

## 1. Lanza el contrato

Primero bajamos el proyecto Demo.

```bash
git clone https://github.com/FilosofiaCodigo/PlayToEarnDemo.git
cd PlayToEarnDemo/
```

Ahora instalamos las dependencias.

```bash
npm install
```

Antes de lanzar debemos agregar el archivo de configuración `.env` que puedes construir en base al arhivo de ejemplo `.env.example`.

Finalmente lanzamos.

```bash
npx truffle deploy --network rinkeby --reset
```

## 2. Levanta el backend

Primero ingresamos en la carpeta del backend e instalamos las dependencias.

```bash
cd backend
npm install
```

Luego crea un nuevo archivo `.env` pero esta vez en la carpeta `/backend`, este archivo contiene lo mismo que creamos en el paso 1.

También debes copypastear el archivo `./build/MyToken.json` en `./backend/MyToken.json`.

Finalmente edita acorde las variables `CONTRACT_ADDRESS` y `BACKEND_WALLET_ADDRESS` en `./backend/backend.js`.

Ahora levantamos el servidor backend.

```bash
node backend.js
```

## 3. Levanta el cliente

Para poder jugar en el frontend debemos lanzar la web del cliente. Para eso ingresamos en la carpeta del cliente e instalamos la única dependencia de manera global.

```bash
cd client
npm i -g lite-server
```

Igual como lo hicimos antes, debes copypastear el archivo `./build/MyToken.json` esta vez en `./client/MyToken.json`.

Una vez hecho esto lanzamos el juego.

```bash
lite-server
```

Recuerda agregar el contrato a metamask para observar cómo obtienes tokens por jugar.

**¡Gracias por ver este tutorial!**

Sígueme en dev.to y en [Youtube](https://www.youtube.com/channel/UCNRB4tgwp09z4391JRjEsRA) para todo lo relacionado al desarrollo en Blockchain en Español.
Hello guys help me out in java xD
Tags: java, programming, beginners
Published: 2021-11-22 17:45:18

Hello guys i am trying to write some code by java >create an acc with randome number and store it in ArrayList > i made this code > but not working

import java.util.ArrayList;
import java.util.Random;
public class BankAcc {
    public String name;
    public int age;
    public int id;

    public BankAcc(String name,int age, int id){
        this.name=name;
        this.age=age;
        this.id=id;

    }
    public String getName(){
        return name;
    }
    public int getAge(){
        return age;
    }
    public int getId() {
        return id;
    }
    Random random =new Random();
    ArrayList<Integer>arrayList=new ArrayList<Integer>();
    while (ArrayList.size()>6){
        int a=random.nextInt(49)+1;
        if (!arrayList.contains(a)){
            arrayList.add(a);
        }
    }
}
Monster Code: An application made with React, Ruby, SQLite, Sinatra and Active Record
Tags: react, ruby, sql, programming
Published: 2021-11-22 17:34:55

In this blog one can get a more in depth analysis of the application my team made for our phase 3 project in the Flatiron School's software engineering bootcamp. React was used for the front end while Ruby, Active Record, Sinatra, and SQLite were used for the back end. 

#Application Overview
{% youtube zJBS6wsgtH4 %}

#Front-End Login Page Overview
{% youtube pxz_gd2OAfM %}


#Front-End Level Page Overview
{% youtube yWXmHS7d8IM %}

(update: When speaking about state "questionNum" in the "handleSubmit" function, I misspoke. What I should be saying is that we update the level if "questionNum === 2" because there are 3 questions and therefore indices 0-2. At the moment you submit the question with an index of 2 the level will be updated. 

#Front-End High Score Page Overview
{% youtube GWOSHm5AUU8 %}

#Additional Thoughts On React 
{% youtube 6XkpkHzfIXM %}

#Backend Overview
{% youtube MVU6YD4q3iA %}

To checkout the code more in depth, below are the links to the front and back end repos on Git Hub. 

https://github.com/wgotterer/project-react-3

https://github.com/wgotterer/phase-3-sinatra-react-project
If you are new to dynamic programming
Published: 2021-11-22 17:02:50

If you are new to dynamic programming, then you should definetly try out this problem.

## Problem
Problem description
Alice and Bob take turns playing a game, with Alice starting first.

Try it

Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of:

Choosing any 
XX
X with 
0<X<n0 < X < n
0<X<n and 
n%X==0n \% X == 0
n%X==0.

Replacing the number n on the chalkboard with n - x.

Also, if a player cannot make a move, they lose the game.

Return true if and only if Alice wins the game, assuming both players play optimally.

Example 1
Input: n = 2
Output: true
Explanation: Alice chooses 1, and Bob has no more moves.
Exmaple 2
Input: n = 3
Output: false
Explanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves.
Constraints
1<=n<=10001 <= n <= 1000
1<=n<=1000

[Try This](https://www.dsabyte.com/posts/blog/Divisor-Game-a-Dynamic-programming-problem-to-get-started-with-DP/619470fd417f3fe19cb8a97d)
⚡ FREE ACCESS TO APPMASTER.IO BETA ⚡
Tags: beginners, programming, news, webdev
Published: 2021-11-22 16:46:31

We are launching the AppMaster.io Beta program, within which we give developers access to the beta version of the AppMaster.io platform completely free of charge without any functionality restrictions.

Fill in the form to [access AppMaster.io Beta](https://docs.google.com/forms/d/e/1FAIpQLSdK1Z9vQ-2XYTD-kG2hEi22wMuy6dOZ2Lf43ByqZCKeeaoGgw/viewform)

AppMaster.io Beta is a pilot version of the platform that contains the latest and often under-tested functionality with many changes. This is a great opportunity to understand the no-code platform and see if it is suitable for your project, as well as work in beta mode.

What to expect if you participate:

* Work with the newest features, before they are officially released
* Up to 20 platform updates per day
* Collected and published projects work almost as stable as on production
* Up to 20 projects per account, including mobile applications and everything else that works (and doesn't work either)
* Fair-usage policy for all beta accounts - no spam, no brute-force, etc.
* It will be necessary to report the errors encountered
* Unlimited term of use - once you understand how you can make money by developing projects on the AppMaster.io platform - welcome to production.
Divemaster Indonesia
Published: 2021-11-22 16:37:25

Take a professional PADI Divemaster (https://www.bluemarlindive.com/gili_trawangan/padi_courses/) Course or PADI IDC Program on the island of Gili Trawangan with Blue Marlin Dive, the original pioneer of diving around the Gili Islands. Having operated for over 30 years Blue Marlin Dive now operates in 6 locations scattered across Indonesia and offers the full range of recreational, professional and technical diver training options. If you’re looking for real expert training at any level of diving discipline this is definitely the first place to start and make dreams a reality.
Mezon Html Report generator
Tags: php, report, html, generator
Published: 2021-11-22 16:27:46

Hi! Let me introduce eport generator wich I have created for personal use.

To be honest I don't like create reports. It took soooooooo mcuh time. But this class now allows me to do it much faster.

## Pros and cons

[Mezon HTML report generator](https://github.com/alexdodonov/mezon-html-report) allows you to create reports in a simple and pretty way. This tool also shortens time wich you spend on coding.

This package is a part of [Mezon Framework](https://github.com/alexdodonov/mezon)

## Installation

Just type:

```bash
composer require mezon/html-report
```

## Usage
Lets start from creating object of the report generator:

```php
$report = new Html();
```

And since that moment we can add elements to the head or body:

```php
// not that stylesheets are not validated, it is totally on your side
$report->head()->style()->selector('p')->css('color', 'red');
$report->head()->style()->selector('div')->css('color', 'green');;

$report->body()->p('Hello!');
$report->body()->div('World!');

// here we get HTML code in the variable $result
$result = $report->compile();
```

## More complex examples

This example shows that every call creates new tag (except html and body). So if you want to add multyple tags then you need to store tag into variable:

```php
$table = $report->table();
$row = $table->tr();

$row->td()->innerHtml('#1');
$row->td()->innerHtml('Legolas');

$row->td()->innerHtml('#2');
$row->td()->innerHtml('Frodo');

$row->td()->innerHtml('#3');
$row->td()->innerHtml('Aragorn');
```

## Supported tags

For now you can use following tags:

- body
- div
- h1
- h2
- h3
- h4
- h5
- head
- p
- strong
- style
- table
- td
- tr

## Inner HTML

If you need more tags, you can use innerHtml like in the example below:

```php
$report->body()->innerHtml('<script>alert(1);</scrip>');
```

## Learn more
More information can be found here:

[Twitter](https://twitter.com/mezonphp)
[Mezon Framework](https://github.com/alexdodonov/mezon)

It will be great if you will contribute something to [this project](https://github.com/alexdodonov/mezon-html-report). Documentation, sharing the project in your social media, bug fixing, refactoring, or even submitting issue with question or feature request. Thanks anyway )
Unable to lock the administration directory (/var/lib/dpkg/) is another process using it
Tags: ubuntu, aptdpkgpackage
Published: 2021-11-25 17:06:34

---
title: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it
published: true
date: 2021-11-22 16:25:52 UTC
tags: Ubuntu,aptdpkgpackage
canonical_url: https://stackallflow.com/ubuntu/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process-using-it/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">apt</span><span style="font-size: 1.2em; color: initial;">dpkg</span><span style="font-size: 1.2em; color: initial;">package-management</span></p>
</header>

I get this error when trying to use `apt-get`:

```
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?  

```

How can I fix this?

#### Accepted Answer

### This should be used as last resort. If you use this carelessly you can end up with a broken system. Please try the [other](https://askubuntu.com/a/15436/44179) [answers](https://askubuntu.com/a/315791/44179) [first](https://askubuntu.com/a/878982/225694) before doing this.

You can delete the lock file with the following command:

```
sudo rm /var/lib/apt/lists/lock

```

You may also need to delete the lock file in the cache directory

```
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

```

After that, try opening Synaptic again.

The post [Unable to lock the administration directory (/var/lib/dpkg/) is another process using it](https://stackallflow.com/ubuntu/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process-using-it/) appeared first on [Stack All Flow](https://stackallflow.com).
Grid component for specific type of crosswords?
Tags: react
Published: 2021-11-22 16:23:57

I'm looking for a React table or grid component/library for my crosswords, of which you find an example in the image https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r451hhwch2ez13suy8m6.png. 

As you can see, some answer cells have a number. If user inputs e.g. 'U' on the first row in the answer cell with number '21', then 'U' should automatically appear in the second row. Also, the number '21' should still be visible in those cells but in a smaller font size in the bottom right corner. I still haven't found a way to achieve this (maybe with a background for that cell?). Does anyone know a component that can handle this?

I also need keyboard navigation, automatic highlighting of the active row and, when a numbered answer cell is active, all other cells with the same number, should be highlighted.

Additional info: all data (grid size, word length, clues, solutions, numbers for answers cells...) come from a MySQL database.

Many thanks!
React Native Chat App using Socket.io
Tags: reactnative, javascript, node, programming
Published: 2021-11-22 16:19:17

#React Native with Socket.io 

*Let's create a basic chat app using React Native as your frontend and socket as your backend*


##Socket IO

The formal definition is that socket enables real-time, bidirectional event-based communication between the client and the server. It consists of a Node.js server and JS Client

This basically means is that data is transported between server and client in realtime. 


##Basic Socket Event Handlers

* item 1 On - on() listens for a ‘connection’ event and will run the provided function anytime this happens.

`io.on("connection", (socket) => {});`

* item 2 Emit - emit() to send a message to all the connected clients
`io.emit("message", {message,sid,time,rid});`

## Server Code with Socket

The server code is written on a node server using **HTTP** and **express**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s119oygr1b5nnj4rip6s.png)
 
##Client side code with React Native

Using *socket.io-client* connect the client to the server. The **useRef** hook is essential to reference the socket.


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