teleren/devto huggingface dataset:
Python none and null difference
Tags: python, beginners
Published: 2020-01-30 12:19:24

The keywords *Null* and *None*. If you are new to programming you may think they mean zero, they do not. On first sight they look alike, so what's the difference?

In many programming languages (C, Java, SQL, JavaScript) there is a Null value. Sometimes explicitly spelled as NULL or null. 

Not so in <a href="https://python.org">Python</a>, Python does not have a null value.

```python
>>> x = null
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'null' is not defined
>>> 
```

## None type

Instead there is the None object. None effectively means there is no value or it is empty. Basically, NoneType is a data type just like int, float, etc.

You can see a type using

```python
    >>> print(type(int))
    <class 'type'>
    >>> print(type(float))
    <class 'type'>
```

You can see this for the None type too:

```python
    >>> print(type(None))
    <class 'NoneType'>
```

## Assign None value

You can see above is an <a href="https://pythonbasics.org/class/">object (class)</a>, in Python this None object never has any functionality. Lets define a variable with the None value

```python
    twelve = None
    print(twelve is None)
```

See the result

```python
    >>> twelve = None
    >>> print(twelve is None)
    True
    >>> 
```

None means no value, not zero.

```python
    >>> print(twelve == 0)
    False
```

## None and null difference

Although there is no null value in Python, you can use None like null. 

```python
    >>> x = None
    >>> if x is None:
    ...     print('x is null')
    ... else:
    ...     print('x is not null')
    ... 
    x is null
```

## Redefine None

Can you redefine None to be something? No, you can't do this.

```python
    >>> None = 1
      File "<stdin>", line 1
    SyntaxError: can't assign to keyword
```

Rest assured, the value of None is always empty.


**Related links:**
* <a href="https://docs.python.org/3.8/library/constants.html?highlight=none#None">Python docs None reference</a>
* <a href="https://pythonbasics.org">Learn Python</a>
Angular 9|8|7 ViewChild Tutorial – Access Child Component
Tags: angular987, angular, angularviewchildtutorial, accesschildcomponent
Published: 2020-01-30 12:10:27

---
title: Angular 9|8|7 ViewChild Tutorial – Access Child Component
published: true
description: Viewchild is one of the decorators in Angular 9/8/7. It is one of the basic ones, and you will learn about it in the early stages itself.
tags: Angular 9|8|7, Angular, Angular ViewChild Tutorial,  Access Child Component  
---

The post [Angular 9|8|7 ViewChild Tutorial – Access Child Component](https://www.positronx.io/angular-7-viewchild-access-child-component/) appeared first on [positronX.io](https://www.positronx.io).

Viewchild is one of the decorators in Angular 9|8|7. It is one of the basic ones, and you will learn about it in the early stages itself.

We have to mention the fact that Viewchild in Angular 9|8|7 is one of the widely used decorators.Viewchild in Angular comes with many features. You will find these features useful. However, only a handful of features are prevalent.

If you wish to gain access to a DOM element, directive or component from a parent component class then you rely on Angular Viewchild.

[Click here to read more](https://www.positronx.io/angular-7-viewchild-access-child-component/)
Getting Started With Angular
Tags: angular, node, angular7
Published: 2020-01-30 12:08:06


1. Install Node
https://nodejs.org/en/ 

2. Check node Version
node -v

3. Check npm Version
npm -v

4. Install Angular CLI
npm install -g @angular/cli

5. Create Angular App
ng new my-app

6. Navigate to my-app
cd my-app

7. Run App
ng serve

8. Open App in Browser
http://localhost:4200/
Magento 2 Refer A Friend Extension - FMEextensions
Tags: magento, refer, friend, extension
Published: 2020-01-30 11:54:01

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

With the help of the extension <b> Magento 2 Refer A Friend</b> both Customer and newly register users can get a reward on each new registration. 

<b><h3>Powerful Key Features</h3></b>
<ul>
<li>View target details, referral link & earnings from “My Account”</li>
<li>Social Sharing buttons to share a link with friends & family</li>
<li>Choose an expiry date for the rewards to avail</li>
<li>Give rewards for registration and/or orders</li>
<li>Set targets users for registration reward and its reward amount</li>
<li>Reward referrer in fix amount or percentage of order amount</li>
<li>Settings for the referee (Referred User)</li>
<li>Reward referred user on registration/order</li>
<li>Set minimum order amount for discount</li>
<li>Provide discount in fix or percentage or order amount</li>
</ul>

<b>More Detail & Live Detail - <a href="https://www.fmeextensions.com/magento-2-refer-a-friend.html">https://www.fmeextensions.com/magento-2-refer-a-friend.html</a></b>
<b><h4>SCREENSHOTS</h4></b>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ijh1ndiky14poojc3cb4.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uizqtjbkxb5bkey5wlsw.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ic75poh00xlf5zm4el7j.png)
Build a terminal ChatApp using python.
Tags: python, tutorial
Published: 2020-01-30 11:51:57

Establishing a successful communication between two or more devices is always a great joy. While I was working on a project I needed to satisfy some requirements. Like, to group certain devices and make communication only between them (chat rooms or group chat). For chatting applications obviously we need a socket protocol. So python has this awesome library called [socket.io](https://github.com/miguelgrinberg/python-socketio). This is a python  implementation of [Nodejs Socket.io](https://github.com/socketio/socket.io).

So the basic idea is to create a server that handles the client messages and delivers to the targeted client. We'll create a [aiohttp](https://pypi.org/project/aiohttp) server which is asynchronous and solves many problems.

Before we start creating a server. Let's set up the python environment.
The python version which I am using is **3.7.9**

### It is recommended to use python-3.6.+

## Install the following libraries
   - [aiohttp](https://pypi.org/project/aiohttp)
   - [socket-io](https://pypi.org/project/python-socketio) 
   - [aioconsole](https://pypi.org/project/aioconsole)

Now we're good to go.

Let's setup the server first.

{% gist https://gist.github.com/imdhanush/4358ce2235c2e520f07b21bdb6550e61 %}
   
What's basically going on here is, we just take an aiohttp server and attach it to a socket-io object. Where there will be a connection upgrade and much more. Let's not get too deep into that. We can also see that every function has a `@sio.event` decorator. It just helps in executing the respective function according to the emitted event.

Now run the server with the command `python server.py`
After running it should look something like this.


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

The URL `http://0.0.0.0:8080` represents the default route. So that every machine or device on this local network can access the server.

That's it. The server part is done. Now let's move on to creating clients.

**Before running clients know your IP Address in Linux it's `ifconfig` in windows it's `ipconfig`**.

Client codes is shown below.

#### Client 1
{% gist https://gist.github.com/imdhanush/7f9cb4c533d3072d13b9b8634aa35690 %}

#### Client 2
{% gist https://gist.github.com/imdhanush/62f1961d00cdd2820aed0e2cdfbb19f6 %}

So we created 2 clients with names `Deadpool` and `Iron man` who belong to the same room called `Marvel`.

Here the communication happens only in `Marvel` room. If `Deadpool` and `Iron man` are in different rooms the communication is not possible.

So let's test it.
When client codes are executed we can see that server logs the name of clients that are connected.

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

That's it. You can start typing in the terminal itself and hit enter to send.

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


{% github https://github.com/imdhanush/Terminal-ChatApp %}
Slackware for the next decade
Tags: linux, slackware, terminal
Published: 2020-01-30 11:34:45

Curious about Slackware Linux and how it holds up in the next decade?

![slackware-logo](https://www.orbjet.org/slackware.jpg)

Then checkout [this](https://www.orbjet.org/post/2020-01-29/slackware-for-the-next-decade/) post on getting up and running with the oldest up to date Linux distribution.
Full Angular 9|8|7 Firebase Authentication Tutorial Examples
Tags: angular987, angular, firebaseauthentication, authenticationtutorial
Published: 2020-01-30 11:16:39

---
title: Full Angular 9|8|7 Firebase Authentication Tutorial Examples
published: true
description: In this Angular tutorial, we are going to build full Angular 7|8|9 Firebase Authentication system from scratch using Firebase Real-time NoSQL cloud database.
tags: Angular 9|8|7, Angular, Firebase Authentication, Authentication Tutorial
---

In this Angular tutorial, we are going to build full Angular 7|8|9 Firebase Authentication system from scratch using Firebase Real-time NoSQL cloud database.

What We’ll Be Creating?
 
 Sign in with Google
 Sign in with username/password
 Sign up with username/password
 Recover forget password
 Send email verification to a newly created user
 Protect app’s inner pages URL using route guard’s canActivate method
 Prevent user to access sign in and sign up URL when a user is already logged in
 Maintain logged in state of Firebase user in localStorage.

[Click here to read more] (https://www.positronx.io/full-angular-7-firebase-authentication-system/)
Replace json values using a mapping json
Tags: go, codenewbie, beginners, tutorial
Published: 2020-01-30 11:15:53

## Problem statement

### Given an input JSON like this
```json
{
	"results": [
	  {
		"id": 1,
		"relationx_id": "11"
	  },
	  {
		"id": 2,
		"relationx_id": "22"
	  }
	],
	"lookup_key": "relationx_id"
}
```

### and a mapping JSON like this
```json
{
	"11": "88",
	"22": "99"
}
```

### Use the lookup_key to replace the value of the key as per the mapping JSON. The result should look like this
```json
{
 "lookup_key": "relationx_id",
 "results": [
  {
   "id": 1,
   "relationx_id": "88"
  },
  {
   "id": 2,
   "relationx_id": "99"
  }
 ]
}
```

## Solution
```go
package main

import (
	"encoding/json"
	"fmt"
)

var inp string = `{
	"results": [
	  {
		"id": 1,
		"relationx_id": "11"
	  },
	  {
		"id": 2,
		"relationx_id": "22"
	  }
	],
	"lookup_key": "relationx_id"
  }`

var mapping string = `{
	"11": "88",
	"22": "99"
}`

func main() {
	var inpJ map[string]interface{}
	json.Unmarshal([]byte(inp), &inpJ)
	// fmt.Printf("%+v\n", inpJ)

	var mappingJ map[string]string
	json.Unmarshal([]byte(mapping), &mappingJ)
	// fmt.Printf("%+v\n", mappingJ)

	lookupKey := inpJ["lookup_key"].(string)
	// fmt.Printf("%+v\n", lookupKey)

	for _, result := range inpJ["results"].([]interface{}) {
		resultMap := result.(map[string]interface{})
		for k, v := range resultMap {
			if k == lookupKey {
				resultMap[k] = mappingJ[v.(string)]
			}
		}
	}
	// fmt.Printf("%+v\n", inpJ)
	b, _ := json.MarshalIndent(inpJ, "", " ")
	fmt.Println(string(b))

}

```
Angular 9/8/7 MEAN Stack Tutorial – CRUD App with Bootstrap 4
Tags: angular987, angular, meanstacktutorial, bootstrap4
Published: 2020-01-30 11:10:20

---
title: Angular 9/8/7 MEAN Stack Tutorial – CRUD App with Bootstrap 4
published: true
description:  In this MEAN Stack tutorial I am going to create an Angular 9/8/7 CRUD App using Bootstrap 4.
tags: Angular 9/8/7, Angular, MEAN Stack Tutorial, Bootstrap 4
---

Today, I am going to share with you a MEAN Stack Tutorial, in this MEAN Stack tutorial I am going to create an Angular 9/8/7 CRUD App using Bootstrap 4. I will be using Node.js, Express.js, MongoDB for backend and Angular 7/8/9 for handling frontend.
For the demo purpose, I will create an employee management system using Angular 7/8/9 MEAN stack. I will try to cover the essential topic used in CRUD web application development.

In this MEAN stack tutorial, I will share step by step process to build an Angular 7 CRUD (Create, Read, Update, Delete) app from scratch.

Let us understand what does MEAN stack means.

[Click here to read more] (https://www.positronx.io/mean-stack-tutorial-angular-7-crud-bootstrap/)
Cheat Sheet for developers
Tags: webdev, productivity, codenewbie, javascript
Published: 2020-01-30 10:56:46

Originally posted in [efficientuser.com] (https://efficientuser.com/2019/11/20/cheat-sheet-for-developers/)

I'm tagging this post with the top tags, not to spam just to reach a wide audience.

As a developer, we can’t remember all the shortcuts or syntax all the time. So here is a curated list of cheat sheet links for Dev.

We don’t own any of the Cheat Sheet. The aim is to help all the Developers in day to day life.

You can visit here:

https://pandiyancool.github.io/CheatSheet/

I got help from many people in Online via HacktoberFest 2019. Thanks to everyone for their contribution.

I wish to make the list bigger. Click **follow** and **reply** to the comment section of your favorite sheet.
CSS <label> pseudo-content trick
Tags: a11y, inclusivedesign, webcomponents
Published: 2020-01-30 10:56:42

Inspired by the [Inclusive Components](https://inclusive-components.design/) by Heydon Pickering and the pseudo-content trick for inclusive card components, I implemented this approach with radio buttons: 

https://codepen.io/tschach/full/PowvmRK

I would be very interested in discussing whether this is a valid option and what could be improved. So if you have any feedback on the semantics, let me know!

I also tweeted about it, so feel free to leave your feedback there:
{% twitter 1222496452598956032 %}
Angular 9|8 Reactive Forms Validation with Angular Material 8
Tags: angular98, reactiveformsvalidation
Published: 2020-01-30 10:43:45

---
title: Angular 9|8 Reactive Forms Validation with Angular Material 8
published: true
description:create an Angular 9|8 Reactive form with Angular Material forms. We’ll be using ReactiveFormsModule API to build and validate Reactive forms. 
tags: Angular 9|8, Reactive Forms Validation 
---

We are going to create an Angular 9|8 Reactive form with Angular Material forms. We’ll be using ReactiveFormsModule API to build and validate Reactive forms. As we know, there are 2 types of Form types offered by Angular 9|8.
Angular 9|8 Form Types:
Template Driven Form
Reactive Forms
In this tutorial, we’ll be using Reactive Forms to create and validate forms. Our focus will be on common Reactive Forms API: FormControl, FormGroup, FormaArray, and FormBuilder.

Reactive Forms is an easy to use service, and Reactive forms are used to handle more complex data.


[click here to read more] (https://www.positronx.io/angular-8-reactive-forms-validation-with-angular-material-8/)
How I hacked Medium (Not about cybersecurity)
Tags: productivity, todayilearned
Published: 2020-01-30 10:24:51

# Hi


I don't use Medium in my daily life. But sometimes curious links get you there.When you click that link something bad happens.
<img src="https://miro.medium.com/max/768/1*QWQGJ5agcruWRBasiRGhRg.png" width="500">


So if you wanna read that article you should pay to medium or clear your browser cookies.

But I found something more useful.And that is [Pocket App](https://app.getpocket.com/)

<img src="https://i0.wp.com/www.diogonunes.com/blog/wp-content/uploads/2018/11/maxresdefault.jpg?fit=1920%2C1080&ssl=1" width="300">


Create a free account on Pocket.And Save the article to pocket.That's it.Simple.And you can read medium article both browsers and pocket app without adds and other distractive components. Also you can **listen** those articles.So simple and efficent.
How to Correctly Use GitHub for Software Development - Part 1: Advantages, Alternatives, and Setup
Tags: github, tutorial, programming, development
Published: 2020-01-30 10:24:23

I have been using GitHub for about 8 years and wanted to share my experiences using it professionally and for open-source projects. I will give you a brief comparison of GitHub to its alternatives, including locally hosted ones. I will also explain to you my personal Git and GitHub setup and how I use it. Finally, I will demonstrate my full software development workflow on my open-source "Android Docker" project, which is hosted on GitHub.

Video: https://www.youtube.com/watch?v=xX8no5eRck0

Article (WIP): https://quanticdev.com/articles/how-to-use-github
Estimating, Part 1
Tags: ruby, estimating, rspec
Published: 2020-01-30 10:06:21

INT. 8TH LIGHT - DAY 2 END

"Optimistic .5, realistic .75...pessimistic 1.25."
"Okay, thats .67."
I'm sitting with my mentor and support mentor, and their faces give nothing away. I've been estimating features with a new system, where 1 point is half a day, or 4 hours. Simple enough project; A 'Tic-Tac-Toe' game in Ruby, fully tested, pulling down features from a Kanban board.

"Next, allow the user to choose a human-human or human-computer game. Questions?"
He keeps adding features until I've estimated about a week's work, normally 8 points.
"I'll see you in a week then!"

I am glad to be getting stuck in with a project so soon. The work itself is not new, but I've never worked with estimates this way, and never done the estimating solo, so I'm curious to see how it'll turn out. My mentor said nothing about my estimates, other than this first task would gauge my estimating.

DAY 3 END

At the end of day 3 I've completed a few features with a tiny amount of time to spare, so far so good! Hopefully it's a good sign, but I'm feeling the pressure that comes with estimating already and that's not a bad thing.


INT. JULES

Time pressure has so far kept me focused as I track every minute, and pushed me to ask colleagues for help sooner. I'm sticking strictly to the idea that it's not done until it's _done done_, so no compromising or pushing problems back.

Will Jules complete the mission in time? Join us next week for part 2!
Service Container in Laravel
Tags: laravel, service
Published: 2020-01-30 09:46:37

Before Understanding Service container we will know what is a container as a name explain it all as Container is places where we store something and we get it from there when we need it.Below is an example of the code.

```php
class container{
    
    public $bindings =[];

    public function bind($name, Callable $resource){

       $this->bindings[$name]=resource;

    }

    public function make($name){

       $this->bindings[$name]();

    }


}

$container = new container();

$container->bind('Game',function(){
    return 'Football';
});

print_r($container->make('Game'));

//Out Put

'Football'

```
As you can see I have created a container class where I have two methods

1)Bind
2)Make


Bind methods register our function in a container and after that, we make use of that function with make function.
This is a basic concept which laravel uses  in Service Container

As we have read the laravel documentation, Service Container helps is managing the Dependency. lets see with an example

```php

app()->bind('Game',function(){

    return new Game();

});

dd(app()->make('Game'));

//Output

Game{}  // class 

```

In Above code with app()->bind()  are binding our service to use it .. then we call to make() to use it then we could see an output as a class .. but what if class Game has a dependency on class Football as shown in below code. it will throw an error

```php

Class Game{

public function __construct(Football $football){

$this->football =$football;

}
}

app()->bind('Game',function(){

    return new Game();

});

dd(app()->make('Game'));

//Output

```

will throw error class football not found so we create a football class as in the below code.

```php

class Football{



}

Class Game{

public function __construct(Football $football){

$this->football =$football;

}
}

app()->bind('Game',function(){

    return new Game(new Football);

});

```
But What if Football Class has one more dependency of the stadium and so on there laravel handles all through service container.

```php

class Football{



}

class Game{

public function __construct(Football $football){

$this->football =$football;

}
}

/*app()->bind('Game',function(){

    return new Game(new Football);
});*/

dd(resolve('Game'));

//Output

Game{
  football {}
}

```

So finally we can say that yes service container is a powerful tool for managing class dependencies and performing dependency injection  ... :)
A Blurb About Async/Await
Tags: csharp, dotnet, async, beginners
Published: 2020-01-30 09:20:54

When using C#'s async/await operators one should not return void unless it's an event. You should always return Task or Task\<T\>. I'll show you what I mean below.

```csharp
public async Task PrintItemsToScreenAsync()
{
       foreach(var item in ItemList)
       {
              //Gets name from a database
              item.Name = await GetItemNameAsync();
       }
}
```

This is an async method, when you don't have any data you want to return you would use the keyword Task. The Task word is saying that you want this method to run async but don't really care about the data, you just want it to do its work and complete.

So how would you call this method from another method?

```csharp
public async Task CallPrintItemsToScreenAsync()
{
       await PrintItemsToScreenAsync();
       //Other work to do
}
```
In the code above we make sure to mark the method as async because whenever you want to await a task it needs to be marked as async or else the compiler will yell at you.

What about how to call an async method from an event like a button click?

```csharp
public async void Button_Click(Object sender, EventArgs e)
{
       await PrintItemsToScreenAsync();
       //Other work to do
}
```
Take note that when calling from an event you would leave it's return type alone and just mark it async, you would then await the async method needing to be called. 

What if I want it to return something like a string?

```csharp
public async Task<string> PrintItemsToScreenAsync()
{
       foreach(var item in ItemList)
       {
              //Gets name from a database
              item.Name = await GetItemNameAsync();
       }
       
       return ItemList.Count.ToString();
}
```
Above we added Task\<string\>, this means that we must return a value in the form of a string. So we return the string literal of ItemList.Count(). This tells us how many items we worked on. Here's how we could call this.

```csharp
public async Task GetItemCountAfterDataDownload()
{
       string _results = await PrintItemsToScreenAsync();
       //use _results anywhere you want to show the count
}
```

Those are just a few tips, I'll be adding more to this but right now it's 1am and I need to sleep :) There is a lot more to cover on async/await, I'll be covering all the basics so stay tuned.

Let me know if you have any questions or if I missed something! 

Happy coding!!!