teleren/devto huggingface dataset:
Firestore API : Getting started 🎁
Tags: firestore, firebase, realtime
Published: 2021-05-09 10:21:29

![Firestore API : Getting started](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akm5od0383lcbhxvb9zb.png)

####### STEP 1 :
```javascript
const db = firebase.firestore()
```

####### STEP 2 :

- **1. Connect to Collection**
```javascript
const collectionRef = db.collection("users");
```
> `RETURNS` `collectionReference` subset of queryReference
- Not sure why but some how this is **NOT** an async opertation

<!-- This won't show up in the content! -->

> NOTE : Now we will only talk about `collectionReference` object **not** `documentRefernce`

```javascript
// collectionReference have few methods to get the snapshot

collectionRef.get();
```
> NOTE : 
1. All the above operations are ` async ` operations
2. All the collectionReference operations **RETURN** ` querySnapshot `

<!-- This won't show up in the content! -->

> docs: An array that returns all of the documents in the snapshot

```javascript
// querySnapshot has docs methods

collectionRef  //Reference from db.collection("users")
  .get()       // Get method to get query Snapshot
  .then((snapshot) => { // snapshot has docs property
    const data = snapshot.docs.map((doc) => ({ // which returns array
      id: doc.id,
      ...doc.data(), // of DocumentSnapshots, add data() to get JSON
    }));
```

- RECAP : 
```
.data() | .exists
🔺
DocumentSnapshots
🔺
.docs()
🔺
querySnapshot
🔺
.get()
🔺
collectionReference
🔺
.collection()
```

**(OR)**

- **2. Connect to Document**
```javascript
const docRef = db.doc("/users/10")
```

> `RETURNS` `documentReference` subset of queryReference
- Not sure why but some how this is **NOT** an async opertation

<!-- This won't show up in the content! -->

> NOTE : Now we will only talk about `documentRefernce` object **not** `collectionReference`

```javascript
// documentReference have few methods to get the snapshot

docRef.get();
docRef.set();
docRef.update();
docRef.delete();

```

> NOTE : 
1. All the above operations are ` async ` operations
2. All the documentReference operations **RETURN** ` documentSnapshot `

####### DocumentSnapshot :

> Document snapshot have two important methods 
1. .exists
2. .data() 

- RECAP : 
```
.data() | .exists
🔺
DocumentSnapshot
🔺
.get() | .set() | .update() | .delete()
🔺
documentRefernce
🔺
.docs()
```

===============

#### Leverage Realtime

- Instead of promise, it's a subscription

> use `.onSnapshot(cb)` on collection reference

- Whenever data changes, firestore calls the callback with querySnapshot


```javascript
(snapshot) => {
    const data = snapshot.docs.map((doc) => ({
      id: doc.id,
      ...doc.data(),
    })
```
Recursion
Tags: programming
Published: 2021-05-09 10:00:11

What is Recursion?

The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. Recursion involves several numbers of recursive calls. However, it is important to impose a termination condition of recursion. Recursion code is shorter than iterative code however it is difficult to understand. Recursion cannot be applied to all the problems, but it is more useful for the tasks that can be defined in terms of similar subtasks. For Example, recursion may be applied to sorting, searching, and traversal problems. The idea is to represent a problem in terms of one or more smaller problems, and add one or more base conditions that stops the recursion.

What is a Recursive Function?

A recursive function performs the tasks by dividing them into subtasks. There is a termination condition defined in the function which is satisfied by some specific subtask. After this, the recursion stops, and the final result is returned from the function.

How is memory allocation of the Recursive method done?

Each recursive call creates a new copy of that method in the memory. Once some data is returned by the method, the copy is removed from the memory. Since all the variables and other stuff declared inside a function get stored in the stack, therefore a separate stack is maintained at each recursive call.
Writing good commit messages.
Tags: github, git, opensource
Published: 2021-05-09 09:58:39

Commits are the messages which tell other developers that for what the changes were made for. 

**Commit messages are often underrated but actually, they are not.** Every developer out there can make an impact with his/her quality of commit messages.
![zyBU2l6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9laht4knrc2znofq6i6w.png)
 
Suppose you are a maintainer of a project and you are open to considering contributions from others. You would want to have good commit messages that provide you useful information about what has changed and why. Because when things really tend to go perplexing then the revision history is a great resource to find out quickly where exactly things went wrong.

Personally, I feel that great developers do emphasize writing good messages not just for themselves but for others too.

Now, you would have got why it is important to write valuable messages. But now you would be thinking that it's enough Udatta, now please share some standard messages template or so, so that I can also write nice messages.

So, here we go for what you started reading this blog in the first place. I am mentioning some standard messages that you can write so that you get an idea and curate it in your way.

1. **feat** - a new feature
2. **fix** - a bug fix
3. **docs** - changes in documentation
4. **style** - everything related to styling 
5. **refractor** - code changes that neither fixes a bug or adds
                   feature 
6. **test** - everything related to testing
7. **chore** - updating build tasks, package manager configs, 
               etc.

Use this to start the message. Like if we added a `test` for a function which checks leap year, we start with a `test`.
`test: add unit test for leapYearCheck()`

I have covered most of them which are mostly used, and you can comment down if you know some more.

***Thanks For Reading!!***

**Connect With Me**
* [Linkedin](https://www.linkedin.com/in/udattachowdhury/)

**Resources**
* [https://neog.camp/guide/lesson-two]
Functions in C Programming 
Tags: functional, cpp
Published: 2021-05-09 09:44:31

###<b>Why are functions actually Used ?</b><br>
Whenever, we're using a Block of code continuously for a lot of iterations then we needn't repeat the whole code in the main() Function of C. 

#######include<stdio.h> 
int main()
{
    int num;
    scanf("%d",&num);

    if(num == 0)
        printf("Neither positive nor negative\n");
    else if(num > 0)
        printf("Positive\n");
    else
        printf("Negative\n");

    scanf("%d",&num);
    if(num == 0)
        printf("Neither positive nor negative\n");
    else if(num > 0)
        printf("Positive\n");
    else
        printf("Negative\n");

    return 0;
}
This is an Example code without using Functions.

In the above code, We're using the block of code from if-else. This repetitive usage of the same block makes the code hard to navigate through and makes it hard to understand. <br>
So instead we can use functions to avoid repetition of the same block of code.

Now, as we Understood the Limitations.<b> Let's see How to Declare a Function ? </b><br>
Syntax of a Declaring a Function in C : <br>return_type function_name( parameter list ) {
   body of the function
}

<b>Now, Let's see what a Function is ?</b><br>
A function definition in C programming consists of a function header and a function body.

<b>Return Type</b> − 
<br>
- A function has a return value that is the value that is returned to the calling part in any other function.<br>
- The Reuturn type is defined in the Function declaration itself.<br>
- Example: int check(int a );-> in the given Example the return type is integer data type.
<br>

<b>Function Name</b><br> 
- This is the name of the function which the user will be giving. <br>
- It is the name by which it'll called and referred to.

<b>Parameters </b><br>
- The parameters refers to the type, order, and number of the parameters of a function.<br>
- Parameters are optional that is, even if Parameters aren't present in the Function it'll run.
- These are the values that a function that is being called to takes.

<b>Function Body</b> <br>
- The function body contains statements that tell the function what should be done.

<b>Function declaration</b> A function must be declared globally in a c program to tell the compiler about the function name, function parameters, and return type.

#######include<stdio.h>

void check(int n)
{
    if(n == 0)
        printf("Neither positive nor negative\n");
    else if(n > 0)
        printf("Positive\n");
    else
        printf("Negative\n");
}

int main()
{
    int n;
    scanf("%d",&n);
    check(n);

    scanf("%d",&n);
    check(n);

    return 0;
}

Example Code using Function

As we can see in the example code, that using a function makes it more readable to the user and simplifies the process of navigating.
I coded a game with React - Next.js
Tags: react, nextjs, javascript, frontend
Published: 2021-05-09 09:36:56

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

Quoridor - A local multiplayer game

https://quoridor.vercel.app/

Instead of buying the board game, I coded it to play on browser. Sharing it with you if you wanna play with your friends. 
(Online version and maybe a better desing very soon!)

***

**My github profile:**
https://github.com/inancakduvan

**My twitter account:**
https://twitter.com/InancAkduvan
Top 10 Reasons Why New Businesses Fail
Tags: startup, devops, node
Published: 2021-05-09 09:12:40

No one starts a business expecting to fail. Starting a business can be a lot of fun and excitement. Success requires a lot of planning and starting the business the right way.
Many developers are not efficient when it comes to growing their businesses. So it's one thing to be a Developer and another to be able to break into the market and profit from your innovations!
In my podcast below, I've stated some reasons why most fail to profit from their ideas.
👇
https://anchor.fm/dami-okoro/episodes/Top-10-Reasons-Why-New-Businesses-Fail-evo63l
Enjoy! Don't forget to feedback.
Tricky Question
Published: 2021-05-09 08:53:17

1/ Null vs Undefined
In JavaScript, undefined is a type, whereas null an object. It means a variable declared, but no value has been assigned a value. Whereas, null in JavaScript is an assignment value.

2/ Double equal vs Triple equal
Double Equals (==) checks for value equality only. It inherently does type coercion. This means that before checking the values, it converts the types of the variables to match each other. On the other hand, Triple Equals (===) does not perform type coercion. It will verify whether the variables being compared have both the same value and the same type.

3/ Scope
Scope is the accessibility of variables, functions, and objects in some particular part of your code during runtime. In other words, scope determines the visibility of variables and other resources in areas of your code.

4/ Window
JavaScript Window is a global Interface (object type) that is used to control the browser window lifecycle and perform various operations on it.

5/ This keyword
this keyword refers to an object, that object which is executing the current bit of javascript code. In other words, every javascript function while executing has a reference to its current execution context, called this. Execution context means here is how the function is called.

6/ Event Bubble
Event bubbling is a term you might have come across on your JavaScript travels. It relates to the order in which event handlers are called when one element is nested inside a second element, and both elements have registered a listener for the same event.

7/ Event Delegate
JavaScript event delegation is a simple technique by which you add a single event handler to a parent element in order to avoid having to add event handlers to multiple child elements.

8/ Javascript
JavaScript is a text-based programming language used both on the client-side and server-side that allows you to make web pages interactive. Where HTML and CSS are languages that give structure and style to web pages, JavaScript gives web pages interactive elements that engage a user.

9/ Recursion vs Iteration
The concept of Recursion and Iteration is to execute a set of instructions repeatedly. The difference between them is that recursion is simply a method call in which the method being called is the same as the one making the call while iteration is when a loop is repeatedly executed until a certain condition is met.

10/ Arrow Function
Arrow function is one of the features introduced in the ES6 version of JavaScript. It allows you to create functions in a cleaner way compared to regular functions.
Installing Docker on MacOS
Tags: docker, brew
Published: 2021-05-09 08:50:23

Background
-I had issues installing Docker so Looked up how to do it via shell [I used the *Brew package installer], I added a more in depth reference below.

1. Update Brew
 *brew  update*
2. Install doker
 *brew install docker*
3. Install docker machine
 *brew install docker-machine*
4. Install virtualbox
 *brew install --cask virtualbox*

....You might run into issues running the 4th command
- You will have to allow software installation from Oracle blah-blah-blah in your System Preference. Chances are your sytem will pop out that information for you and then do a restart.

**Everything about docker and it's environment is set up already

(More depth follow through)[https://www.robinwieruch.de/docker-macos]
Sequelize belongstomany Example – Nodejs/Expresss
Tags: sequelize, node, express
Published: 2021-05-09 08:49:30

https://loizenai.com/sequelize-belongstomany-example/

Sequelize belongstomany Example – Nodejs/Express

In the previous <a href="https://grokonez.com/spring-framework/spring-boot/how-to-start-spring-kafka-application-with-spring-boot">post</a>, we had setup a <strong>Spring Kafka Application</strong> succesfully by explicitly configuration <strong>Kafka Factories</strong> with <strong>SpringBoot</strong>. But the messages had been used have <strong>String</strong> type. While in the development, <strong>POJO</strong> (Plain Old Java Object) are often used to construct messages. So with the tutorial, <strong>JavaSampleApproach</strong> will show how to use <strong>Spring Kafka JsonSerializer</strong> (<strong>JsonDeserializer</strong>) to produce/consume Java Object messages.

Related articles:
- <a href="https://loizenai.com/rabbitmq-topic-exchange-spring-boot/">RabbitMQ Topic Exchange Spring Boot Example</a>
- <a href="https://loizenai.com/spring-boot-one-to-one-mapping-example/">Spring Boot One to One Mapping Example</a>
- <a href="https://loizenai.com/sequelize-belongstomany-example/">Sequelize belongstomany Example – Nodejs/Express</a>

<!--more-->
<h2>I. Technologies</h2>
– Java 8
– Maven build
– Spring Boot
– Apache Kafka
– Spring Tool Suite editor
<h2>II. Overview</h2>
<img src="https://grokonez.com/wp-content/uploads/2017/06/Spring-Kafka-Application-architecture-2.png" alt="Spring Kafka Application - architecture" width="359" height="397" class="alignnone size-full wp-image-5973" />

In the tutorial, we send and receive Java object messages to/from <strong>Apache Kafka</strong>, so <strong>ProducerFactory</strong> uses <code>JsonSerializer.class</code> and <strong>ConsumerFactory</strong> uses <code>JsonDeserializer.class</code> to serialize/deserialize Java objects to Json bytes.

- <strong>KafkaProducerConfig</strong>:

<pre><code class="language-java">
@Bean
public ProducerFactory<String, Customer> producerFactory() {
    ...
    configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
    return new DefaultKafkaProducerFactory<>(configProps);
}
 
@Bean
public KafkaTemplate<String, Customer> kafkaTemplate() {
    return new KafkaTemplate<>(producerFactory());
}
</code></pre>

- <strong>KafkaConsumerConfig</strong>:

https://loizenai.com/sequelize-belongstomany-example/

Sequelize belongstomany Example – Nodejs/Express
Node.js : Removing extraneous NPM packages
Tags: programming, node, webdev, javascript
Published: 2021-05-09 08:47:04

# Synopsis
```
npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]
```
# Description
This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed.

Extraneous packages are those present in the `node_modules` folder that are not listed as any package's dependency list.

If the `--production` flag is specified or the `NODE_ENV` environment variable is set to production, this command will remove the packages specified in your `devDependencies`. Setting `--no-production` will negate `NODE_ENV` being set to production.

If the `--dry-run` flag is used then no changes will actually be made.

If the `--json` flag is used, then the changes npm prune made (or would have made with `--dry-run`) are printed as a JSON object.

In normal operation, extraneous modules are pruned automatically, so you'll only need this command with the `--production` flag. However, in the real world, operation is not always "normal". When crashes or mistakes happen, this command can help clean up any resulting garbage.

# Summary
To remove extraneous packages (packages that are installed but not in dependency list) run the following command:
```
npm prune
```
To remove all dev packages add `--production` flag:
```
npm prune --production
```

<a href="https://www.buymeacoffee.com/rkycom" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/www-rajeshkumaryadav-com/) and [Twitter](https://twitter.com/rky_com).
Node.js : NPM Behind A Proxy Server
Tags: node, webdev, developer, programming
Published: 2021-05-09 08:40:46

If your internet access is through a proxy server, you might need to modify npm install commands that access remote repositories. npm uses a configuration file which can be updated via command line:
```
npm config set
```
You can locate your proxy settings from your browser's settings panel. Once you have obtained the proxy settings (server URL, port, username and password); you need to configure your npm configurations as follows.
```
$ npm config set proxy http://<username>:<password>@<proxy-server-url>:<port>
$ npm config set https-proxy http://<username>:<password>@<proxy-server-url>:<port>
```
`username, password, port` fields are optional. Once you have set these, your `npm install`, `npm i -g` etc. would work properly.


<a href="https://www.buymeacoffee.com/rkycom" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/www-rajeshkumaryadav-com/) and [Twitter](https://twitter.com/rky_com).
Node.js : Hello World basic routing
Tags: node, webdev, codenewbie, backend
Published: 2021-05-09 08:13:59

Once you understand how to [create an HTTP Server with node](https://dev.to/rajeshkumaryadavdotcom/create-back-end-server-in-node-js-1o4h), it's important to understand how to make it "do"
things based on the path that a user has navigated to. This phenomenon is called, "routing".

The most basic example of this would be to check `if (request.url === 'some/path/here')`, and then call a function that responds with a new file.

An example of this can be seen here:
```javascript
const http = require('http');
function index (request, response) {
 response.writeHead(200);
 response.end('Hello, World!');
}
http.createServer(function (request, response) {

 if (request.url === '/') {
 return index(request, response);
 }
 response.writeHead(404);
 response.end(http.STATUS_CODES[404]);
}).listen(1337);
```
If you continue to define your "routes" like this, though, you'll end up with one massive callback function, and we don't want a giant mess like that, so let's see if we can clean this up.

First, let's store all of our routes in an object:
```javascript
var routes = {
 '/': function index (request, response) {
 response.writeHead(200);
 response.end('Hello, World!');
 },
 '/foo': function foo (request, response) {
 response.writeHead(200);
 response.end('You are now viewing "foo"');
 }
}
```
Now that we've stored 2 routes in an object, we can now check for them in our main callback:
```javascript
http.createServer(function (request, response) {

 if (request.url in routes) {
 return routes[request.url](request, response);
 }
 response.writeHead(404);
 response.end(http.STATUS_CODES[404]);
}).listen(1337);
```
Now every time you try to navigate your website, it will check for the existence of that path in your routes, and it will
call the respective function. If no route is found, the server will respond with a 404 (Not Found). And there you have it--routing with the HTTP Server API is very simple.

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/www-rajeshkumaryadav-com/) and [Twitter](https://twitter.com/rky_com).

<a href="https://www.buymeacoffee.com/rkycom" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
Laravel 8 Custom Reset Password Example
Tags: laravel
Published: 2021-05-09 07:52:13

Hello Dev,

Today our leading topic is laravel custom forgot password example. step by step explain custom password reset laravel. This post will give you simple example of how to create custom forgot password in laravel. step by step explain laravel custom reset password email.

Laravel provide it's own forget password functionality but if you want to create your custom forget password functionality then i will help to creating custom reset password function in php laravel. so basically, you can also create custom forget password with different models too.

you can easily create custom forget password with laravel 6, laravel 7 and laravel 8 version.

few days ago i posted [Laravel 8.x Custom Login and Registration Example](https://www.codecheef.org/article/laravel-7x-custom-login-and-registration-example), from there i will start implement custom reset password function. so let's follow bellow step.

you can see bellow preview of pages:

Today, I will learn you how to custom forgot & reset password in laravel. we will show example of laravel custom forgot & reset password. you can easliy create custom forgot & reset password in laravel. This post will give you simple example of how to create custom forgot password in laravel. step by step explain laravel custom reset password email.

I will help to creating custom reset password function in php laravel. so basically, you can also create custom forget password with different models too.

Here, I will give you full example for simply laravel custom forgot & reset password as bellow.

[Laravel 8 Custom Reset Password Example](https://www.codecheef.org/article/laravel-8-custom-reset-password-example)
Why Javascript is more popular ?
Tags: javascript, frontend
Published: 2021-05-09 07:52:11

**1. Run's on the web.**
It is the default language and browser can only understand Javascript.

**2. Built on V8 Engine**
Instead of using interpreter, it compiles javascript code into machine code at execution by implementing a just-in-time compiler.

**3. Using ES6**
ES6 is the latest version of scripting language standard.

**4. Omnipresence**
Javascript is present everywere

1. Front-end (Js, ReactJS)
2. Back-end (NodeJS)
3. Andriod (ReactNative)
4. Desktop (ElectronJS)

**5. Faster than Ever.**


[Buy me a Coffee](https://www.buymeacoffee.com/sqwebdeveloper)