teleren/devto huggingface dataset:
¿Que es el process.nextTick?
Tags: node, spanish, espanol
Published: 2021-02-12 16:21:36

El process.nextTick es una feature de NodeJS muy útil y importante de saber acerca de su funcionamiento.

¡Cierto! ¿Pero, qué es él?

En NodeJS, cada iteración del Event Loop es conocida como un **tick**. Entonces, el process.nextTick ejecutará una función de callback cuando la iteración actual esté completado.

El process.nextTick no es parte de ninguna parte del Event Loop, en vez de eso, procesará los callbacks programados después de la iteración actual y antes de la seguinte.

Vamos a un ejemplo:

```javascript
process.nextTick(() => console.log('ejecutaré en la iteración seguinte'))

console.log('estoy ejecutando en la iteración actual')
```

Si lo ejecutamos, tenemos este resultado:

```
estoy ejecutando en la iteración actual
ejecutaré en la iteración seguinte
```

Ahora, un ejemplo un poco mas complejo.

```javascript
const server = net.createServer(() => {}).listen(8080);

server.on('listening', () => {});
```

Yo iré crear una estructura similar a esta, creada utilizando el modulo http del Node.

```javascript
class FakeHttpServer extends EventEmitter {
  createServer () {
    return this
  }

  listen (port) {
    this.emit('listening', port)
  }
}

const http = new FakeHttpServer()

http
  .createServer()
  .listen(3000)

http.on('listening', console.log)
```

Ahora, vamos ejecutar este código y ver que él producirá.

No tenemos nada, nuestro **console.log** no fue llamado.

Pero, ¿Por qué? El evento está siendo emitido, mas no conseguimos capturar él.

Esto acontece, por que la función **listen** es completada de forma imediata y síncrona, pero nuestro listener ni fue ejecutado en este momento.

En casos así, el process.nextTick es muy útil.

```javascript
class FakeHttpServer extends EventEmitter {
  ...
  listen (port) {
    ...
    process.nextTick(() => this.emit('listening', port))
  }
}
```

Ahora estamos usando el process.nextTick para programar la emisión del evento para la iteración seguinte del event loop.

Si ejecutamos el código, tenemos la seguinte salida:

```
3000
```

Esta es la porta que pasamos para la función listen. La conseguimos logar agora, por que el código fuera procesado completamente, entonces cuando llegar la iteración seguinte del event loop, el listener ya terá sido ejecutado anteriormente.

El process.nextTick es muy útil cuándo precisamos programar una tarea para ser procesada después que todo el código restante ya esté completado
Delightful Database Design - Mastering MongoDB Queries - Series #11
Tags: database, mongodb, javascript, express
Published: 2021-02-12 16:40:43


### Legend
AF = Aggregation Framework


# Intro

We've covered a lot of powerful features of shaping data that we retrieve from the database, but we've also barely scratched the surface.

Other powerful data manipulation actions we can do:

- joins (using the $lookup operator)
- writing results to new collections (using the $out operator)
- performing unions on dataset (using the $unionAll operator)
- merging datasets (using the $merge operator)

These are all "stage operators". They are stages of our aggregation pipeline, which is our full query, and is represented as an arr of stages. Each stage is a single atomic unit of our database query.

Here is some pseudocode to understand the structure of composing the database query:
```js
const aggregationPipeline = [
 { $stage1 },
 { $stage2 },
 { $stage3 },
]
```

Then we simply make the call to the database using the "aggregate" func.
The aggregate func takes one parameter, the aggregation pipline arr; which is simply an arr of objs called stages.
That's all there is to the "MongoDB Aggregation Framework" (AF) from the bird's eye view:
```js
return await client.db(dbName).collection(collName).aggregate(aggregationPipeline).toArray();
```

## Question and Answer

1.
How does AF compare with other database query systems, like Mongoose or GraphQL.

#### AF vs Mongoose:
The AF is well beyond the capability of Mongoose.
When you're composing AF queries, you're writing queries directly for the MongoDB engine and optimizer. It natively understands the query and optimizes it. AF is the future direction of the MongoDB company and ecosystem. They are pouring tens of thousands of development and research hours into it to make it better every iteration.

#### AF vs GraphQL:
These are two different products.
For example, your GraphQL resolvers can use the AF to retrieve data. GraphQL has it's set of usecases that it is designed for, like bringing various (or disparate) datastores together into a coherent and consistent orchestration.
AF is deceptively simple; But also deceptively powerful and performant. So unless your enterprise usecase calls for a GraphQL-style solution, you may be better off selecting the least amount of moving parts.


## What's Next?

In the next few series of articles, we'll do some advanced and creative data-shaping activities. Taking the AF approach makes this possible.
Installing Windows 10 Terminal
Tags: wsl, windows
Published: 2021-02-12 16:19:43

If you are Linux or MacOS user, then for sure you are used to feature-rich terminals. And probably you cringe a little bit inside every time you have to use Windows command prompt. I feel you, but maybe you don't know yet that Windows 10 offers official (and free) next generation [terminal for Windows](https://docs.microsoft.com/en-us/windows/terminal). Terminal for Windows borrows all the best features from Linux/Unix terminals. 

You can try it really easily! Terminal is available in Windows Store, just find the application in the Store:

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

After installation you should see it as a new application in your run menu:

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

Probably the most important Terminal's feature is a support for multiple tabs. You can open new tab by clicking plus sign at the top of the Terminal window. Or even better, you can click the expand button to choose the terminal type you would like to open in new tab (PowerShell, Command Prompt, Linux distribution like Ubuntu, etc).

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

Microsoft did really great job when it comes to Terminal and they keep adding new awesome stuff with every release. Go give it a try!
How to wait for a request to finish before moving on with Cypress
Tags: cypress, testing, automtion, e2e
Published: 2021-02-12 16:18:12

Today in "**Pinches of Cypress**", learn a mechanism to make your **tests more robust**

Imagine an application for notes' creation.

After logging into the application, the user is redirected to a list of all their notes.

After creating, editing, or deleting a note, it is also directed to the same notes list.

Let's look at an example.

```js
describe('Notes', () => {
  beforeEach(() => {
    cy.intercept('GET', '**/notes').as('getNotes')
    cy.login()
    cy.wait('@getNotes')
  })

  it('successfully creates a note', () => {
    const myNote = 'Buy coffee'

    cy.get('[href="/notes/new"]').click()
    cy.get('#content').type(myNote)
    cy.contains('Create').click()
    cy.wait('@getNotes')

    cy.contains(myNote).should('be.visible')
  })
})
```

In the first line inside of the `beforeEach` function callback, I use `cy.intercept()` to intercept an HTTP request of type `GET` for a route that ends with the string `/notes`, then I create an alias for this request, called `getNotes`.

Then, right after logging into the application, I use `cy.wait()`, passing the alias created previously (`@getNotes`). That way, Cypress will wait for such a request to end before moving on to run the test that successfully creates a note.

Then we arrived at the test itself.

Initially, I store a string in a variable called `myNote`.

Then I perform the steps to create a note, where I first click on a link, I type the note into a text field, and finally, I click on a button that has the text 'Create'.

Before the verification, I call `cy.wait()` again, passing the alias created previously (`@getNotes`) to wait for the request to finish before moving on.

Finally, with the request complete, I check that my note is visible. 🥳

___

Did you like it?

I'm looking forward to hearing your feedback!

___

This post was originally published in Portuguese on the [**Talking About Testing**](https://talkingabouttesting.com/2021/02/12/como-aguardar-um-requisicao-acabar-antes-de-seguir-adiante-com-cypress/) blog.
___

Would you like to learn about **test automation with Cypress**? Get to know my online courses on [**Udemy**](https://udemy.com/user/walmyr).
Blockchain – The Game changer
Tags: blokchain, distributed, gaming
Published: 2021-02-12 16:13:58

---
title: Blockchain – The Game changer
published: true
description: 
tags: blokchain, distributed, gaming
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/07eyef4ttyozgyhwf60u.jpg
---

Blockchains, Distributed Ledgers, Decentralized Registry Technology - those are keywords that have become an integral part of the future visions and expectations for many tech enthusiasts.

There are more than just a handful of case studies and prototypes based on these technologies trying to revolutionize crucial sectors of society like health care, finance, and contract management. 

But what about a more playful approach for its further development? What about making distributed gaming the new game changer of the industry? 

<h2>The Importance of the Topic</h2>
It is necessary and important to tackle the crucial areas which shape our modern society. But how much do we really know about, on one hand the perks and security issues, and on the other hand the real potential of this technology? 

I think that those rather big goals we try to achieve and important matters blockchain is currently somewhat squeezed into, may not be the right approach to learn how to fully make use of and properly tame this new shiny thing everyone wants in their pocket. 

<h2>Kind of kills the Curiosity of the Developers</h2>
Keeping in mind those ambitions to change the world for the better as a developer is both – a motivation to push forward and a curse increasing the likelihood of mistakes. Of course, mistakes can be seen as a learning opportunity, but the question remains - at what cost? 
I barely know a developer who delivers their “best” code not driven by their curiosity. And by putting the weight of the whole industry on their shoulders that curiosity might get a little crushed. 

<h2>And this may be an Opportunity to save it</h2>
Gaming is not for everyone, but it might be the right playground to fully embrace the wonders blockchains, distribution and decentralization have to offer. On top of the lower pressure and less strict functional and non-functional requirements this environment holds, there is also a very open-minded community, always interested to go beyond the known and ready to establish new rules in its game. 

It sure does not change the world the way a revolution in the finance sector would, but it opens a door I would love to see open.

What are your thoughts on this topic? What perks do you see in the emergence of this topic? And what fascinates you the most about those new chances?

I would love to read your opinion on these thoughts.  


*Photo by Jaroslav Nymburský on Pexels*
Spring boot +Docker+ Gitlab - Continuous Integration(CI)
Tags: java, git, spring, devops
Published: 2021-02-12 16:11:57

A simple example to demonstrate, how we can use spring boot, docker and gitlab for build and test using maven, create an image and push it to gitlab repository.

**Step 1 - Create a Gitlab account**
If you already familiar with gitlab then feel free to skip this section, otherwise create a gitlab account by following this link [Link](https://gitlab.com/) 

**Step 2 - Create a New Project in Gitlab**
Once you successfully created Gitlab account then create a new project 

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

**Step 3 - Create a New Spring boot project**
Simple and easiest way to create spring boot project is to visit [start.spring.io](https://start.spring.io/)

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

Once you have the project created, use the choice of your editor to open the project. 

**Step 4 - Add Dockerfile and Update gitlab.ci.yml file**
**Docker file**
```
FROM openjdk:13-alpine
Volume /tmp
ADD /target/*.jar springbootgitlab-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/springbootgitlab-0.0.1-SNAPSHOT.jar"]
```
**gitlab-ci yml file**
```
image: gitlab/dind
services:
  - docker:dind

variables:
  DOCKER_DRIVER: overlay
  SPRING_PROFILES_ACTIVE: gitlab-ci
  USER_GITLAB: sanjaybsm
  APP_NAME: springbootgitlab
  REPO: springbootlabtest

stages:
  - build
  - test
  - docker

maven-build:
  image: maven:3-jdk-8
  stage: build
  script: "mvn clean package -B"
  artifacts:
    paths:
      - target/*.jar

maven-test:
  image: maven:3-jdk-8
  stage: test
  script: "mvn test"
  artifacts:
    paths:
      - target/*.jar

docker-build:
  stage: docker
  script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker build -t registry.gitlab.com/yournameingitlab/springbootlabtest .
    - docker push registry.gitlab.com/yournameingitlab/springbootlabtest
```
*please note test mvn test is added just as an example*

For above project I used packaging as jar since my dockerfile and gitlab yml files configured like that.

**Step 5 - Commit and Push to gitlab!**
`git add .`
`git commit -m "initial commit"`
`git push origin master`

After above step, you should see your gitlab pipeline kicking in!!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nfur1wf8qo7m8n0ucc3m.png)

and also you should see your image available in container registry!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fskw740gsgl5ww7g5pl5.png)

Voila!! you have successfully used gitlab ci/cd pipeline to build, test, create image and push image to gitlab container registry! 

In the next blog I will try to explain how we can download docker image from gitlab and run it from local machine!
6 Technical Challenges in SaaS Development You Should Know
Tags: saas, php, mobileappdevelopment, softwaredevelopment
Published: 2021-02-12 16:04:06

Most of the businesses use SaaS applications in their daily work for emailing, customer management, coding, task scheduling, accounting, among others. It is expected that by 2022, SaaS apps will substitute for [80%](https://www.bettercloud.com/monitor/wp-content/uploads/sites/3/2017/05/2017stateofthesaaspoweredworkplace-report-1.pdf) of all apps used by companies. 

No wonder that there is a boom of SaaS startups now. Unlike custom web apps built specifically for the needs of one company, SaaS is created for many different organizations. The [development of SaaS applications](https://greenice.net/saas-development/) has its peculiarities and challenges that you should consider before starting the development. Let’s revise some of them!

##1. Multi-Tenancy
The notion of multi-tenancy is important for SaaS creation as it allows to drastically cut the expenses for development. Before SaaS architecture was single-tenant, i.e. divided into separate instances and databases for different organizations (tenants). Today, developers use multi-tenant SaaS approaches in which each organization has separate databases but use one common application that can be easily updated. 

##2. Data Security
Modern SaaS uses cloud services like AWS for data storage as the most reliable and secure way. Each organization is authorized to access their data only even if the data of all SaaS users are stored on the same server. 

##3. Customization for Different Users
The SaaS concept implies that the app features should be equally valuable for different users or companies. But, in reality, everyone has their unique needs and SaaS should be flexible to fit as many users' needs as possible.

##4. API Integration
A small organization uses on average [70](https://www.wsj.com/articles/employees-are-accessing-more-and-more-business-apps-study-finds-11549580017#:~:text=Angus%20Loten,-Biography&text=The%20number%20of%20software%20apps,an%20analysis%20by%20Okta%20Inc.) different apps, while large companies may use up to 200 apps. Without automatic data synchronization, it can be a nightmare. So, make sure that your SaaS provides an API for integration with third-party software and [web portals](https://greenice.net/web-development-services/web-portal-development/). 

##5. Easy Updates
Luckily, the times when we needed to buy each new version of the software on a CD have gone. One of the advantages of today’s SaaS is that it can be easily updated online. It's cheap and easy for users.

##6. Various Payment Methods
Giving users a selection of payment methods and a variety of tariffs makes them more eager to try the app. It's a good practice to give users a free trial period or propose to use a freemium way of payment. 

Though there are many ways to [build a SaaS application](https://greenice.net/develop-saas-application-complete-guide/) depending on each team's individual processes, the above-mentioned challenges are similar for all and should be well-thought-out in the requirements in advance.
The Small Things : A Fable
Tags: codlesscode, fable
Published: 2021-02-12 15:14:33

My take on:  
http://thecodelesscode.com/case/1


The Small Stuff

For three days and for three nights, the Tech Lead had not  been seen from outside of his cubicle. But the smell of his Chinese take-out could be.  

On the fourth day the bravest of the junior devs,  approached the Tech Lead's cube. With great caution he entered. 

The junior dev found the Tech Lead at his a whiteboard. The whiteboard surface reflected a lifetime of bombardment of diagrams and flowcharts. A single dataflow diagram remained. 

The junior dev recognized it as a minor component, of a vast system. A system that the department were placed in charge to maintain. The junior dev sheepishly asked what the Tech Lead was working on.

At that monument Tech Lead broke out of  his trace. “There is a defect, and I am considering the best way to repair it.”

The junior dev said, “You often speak about the importance of setting priorities. How, then, can you obsess about something so tiny and unimportant?”

Without saying a word, the Tech Lead raised his chop sticks and grabbed the junior dev by the pinkie finger. With a lowering of his hand the junior dev went from a standing position to a setting position. In that moment, the novice was enlightened.


What did you think ? 

Justin 
https://twitter.com/CodeByJustin
Understand Animation fill mode 🤯🤪
Tags: css, tutorial, codenewbie, todayilearned
Published: 2021-02-12 15:43:57

Hey coding people

Hope you are doing well in your journey :)

This post is a part of our "20 Days of CSS animation post".

{% link https://dev.to/atulcodex/20-days-of-css-animation-post-3g8d %}

The "animation-fill-mode" is used to set the animation ending position of an element I mean @keywords to position OR default element position. But keep in mind we can't set @keyframes from position via animation fill mode.

Please play around with this codepen, So you can feel the difference.

{% codepen https://codepen.io/atulcodex/pen/jOVVgXM %}

The use of "none" is nothing, no fill effect.

animation-fill-mode: none;


The "forwards" and "both" mode will set the element at keyframes to position.

animation-fill-mode: forwards;


The "backwards" mode will set the element at the default element position.

That's all for this post And if you are interested to learn CSS you can join [E-Learning platform](https://www.eduonix.com/UHJvZHVjdC0xMzE1MDIw).
Animations other property🌙
Tags: css, codenewbie, tutorial, todayilearned
Published: 2021-02-12 15:37:01

Hey party people

Hope you are doing well in your journey :)

This post is a part of our "21 Days of CSS animation post"

{% link https://dev.to/atulcodex/20-days-of-css-animation-post-3g8d %}

In this post, we are learning about three different animation properties which are as follows.
- animation-timing-function
- animation-direction

{% codepen https://codepen.io/atulcodex/pen/ZEBBKRm %}

The use of "animation-timing-function" is it will add little speed animation function like fast when the star, slow when the end, etc. This property has four different values like "linear", "ease", "ease-in", "ease-out", "ease-in-out".


In "animation-direction" we can add animation start and end position like starting point and endpoint. Four property has three different values which are as follows 
- normal
- reverse
- alternate
- reverse-alternate


That's all for this post And if you are interested to learn CSS you can join [E-Learning platform](https://www.eduonix.com/UHJvZHVjdC0xMzE1MDIw).
Quick reference : algorithm complexities ( Big O, linear, .. )
Tags: tutorial, programming, codenewbie, productivity
Published: 2021-02-12 15:35:22

Algorithm complexity denotes the number of steps/operations taken by an algorithm to complete a function with an input size of "n". 
This is an important concept used for optimizing and comparison of algorithms. 
Below are the concepts defined in simple ideations for quick reference. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/i5e0lz31yp9nh1s2t1j0.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xrzhp7onphtim4hauwkv.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8pm7me8et7x6dpmdy8p9.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pkajysdpxfjx2j9leirq.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cts4o1pes6meb17xydlq.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d1ozvy97b1zjayy6qt4k.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0nazjg8618ge4ylxdjwv.jpg)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oyr3xxhkwxv4p08xoms0.jpg)

For this and more content on react and other programming topics, you can download and use the microideation app for free ( no mandatory registration). You have the ability to view related ideations or to freeze an interesting topic/subject and follow.

https://play.google.com/store/apps/details?id=com.microideation.app

More details
https://www.microideation.com
Why you should create your own PHP MVC Framework
Tags: php, mvc, laravel, webdev
Published: 2021-02-12 15:33:22

So its very clear that using a framework to build up your website is an important thing, you can save a lot of time and energy by using one like  Laravel or code igniter 3, but there's one thing  that web developers beginners should understand and its the MVC architecture and how does it work, and in order to understand it you should build your own MVC framework, so when you use another advanced framework you know what you are doing and you know the role of the controller, the model and the view and why they exist, sure you can read about that but there's nothing better than learning by practice, back to 2015 when I first created my first own MVC framework, I gain a lot of experience and my php skills dramatically improved. 

The reason beginners get stuck to understand frameworks and take a long time to learn the basics is that they don't really understand the MVC architecture, once you get used with it, everything becomes easy. 

Here are the things I learnt by that:

I learnt how to create a validation system.
How does routing work.
I knew about .htaccess.
I learnt how to use PDO.
I built a query builder which made my code very organized and easy to read.
I created a views system with basic PHP and HTML templating. 
I learnt about flashing error messages using session.

So now when ever I use a framework I know what I'm doing when writing code, and in final its a was great learning curve, I advice every beginner to take the experience and put some efforts to do so, YouTube is full of courses you just need determination.

https://www.buymeacoffee.com/achour