teleren/devto huggingface dataset:
How to Mock a Server in Postman (CRUD) Example | 30 Days of API Testing | Day 14
Tags: testing, tutorial, beginners, webdev
Published: 2020-05-14 18:13:43

🚀Mastering API Testing(Full Course) -  https://www.learnapitesting.com

In this video of 30 Days of API Testing Challenge, We are going to discuss Postman Mock Server and a CRUD example mocked in postman.
Also, we are going to learn about the Compare and contrast mocking, stubbing, and faking.

[![30 Days of API Testing](https://i.imgur.com/ne6U9ds.png)](https://youtu.be/MdyaU1rl_QU "30 Days of API Testing")


🚀 Day 14 Task: Compare and contrast mocking, stubbing, and faking.

🚀 Task 14. :  https://scrolltest.com/api/day14

🚀 All Task List : https://scrolltest.com/api/task




🚀 Tools and services I recommend:
Some of the courses that I recommend to become better Automation Tester 🙌🙌

✅Selenium Training and Certification -
https://scrolltest.com/go/edureka

✅Learn Jenkins for QA -
https://bit.ly/learnjenkins-p1

✅Programming Java -
https://bit.ly/learnjava2020-p1

✅Test Automation - 
https://bit.ly/learnautomation2020

✅API Testing - 
https://www.learnapitesting.com

✅Cypress Tutorial with LIVE Projects -
https://cypresstutorial.com

--
Be sure to subscribe for more videos like this!

[![ TheTestingAcademy](https://dev-to-uploads.s3.amazonaws.com/i/r7vcy6wbvyjbk1y1uu0o.png
)](https://www.youtube.com/TheTestingAcademy?sub_confirmation=1 "TheTestingAcademy")
Make A Custom User Model - Building SaaS #40
Tags: python, django, saas
Published: 2020-05-14 18:03:58

{% youtube I2pG21ol_KU %}

In this episode, we started a users app and hooked up the custom user model feature of Django to unlock the full extensibility of that model in the future.  The stream was cut short this week because of some crashing issues in the OBS streaming software.

The goal of the episode was to add [django-allauth](https://django-allauth.readthedocs.io/en/latest/) so that users can sign into the service with an email and password instead of the default username and password combination.  We're using [Will Vincent's guide](https://wsvincent.com/django-login-with-email-not-username/) on this topic as an aide for this implementation (thanks Will!).

django-allauth makes it possible to add a variety of authentication options like Google or Facebook sign in.  My app is not using those modes, but it is taking advantage of the "email as username" feature that the package can provide.

Before getting to the django-allauth integration, we first needed to create a custom `User` model.  This isn't strictly necessary, but it unlocks a lot of future potential and is a hard change to make later in a project.

I started with the creation of a new Django app for the `User` model to reside in.

```bash
(venv) $ python manage.py startapp users
```

From there, I discussed some code organization ideas and explained why I'm making the choice to put all of my app code into a single, top-level package called `homeschool`.  It's mostly a personal preference issue, but I did talk through some justification for my decision.

```bash
(venv) $ mkdir homeschool
(venv) $ touch homeschool/__init__.py
(venv) $ mv users homeschool
```

With the app in the location I wanted, we put it in the list of installed applications in the settings.

```python
# project/settings.py

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "homeschool.users",
]
```

Next, we needed to create the model and set it in the settings.

```python
# homeschool/users/models.py
from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
    """A custom user for extension"""

# project/settings.py
AUTH_USER_MODEL = "users.User"
```

Finally, we generate the migration to make use of the setup.

```bash
(venv) $ python manage.py makemigrations
(venv) $ python manage.py migrate
```

Unfortunately, that's where the stream ended for the night.  My recent upgrade to macOS Catalina was not playing nicely with the OBS streaming software and OBS crashed **hard**.  Interestingly, I was able to get OBS to crash every time I tried to log in to the Django admin in Firefox.  It was super weird.

Next time, we will continue to work through the django-allauth addition with a (hopefully) more stable streaming setup.

This article first appeared on [mattlayman.com](https://www.mattlayman.com/building-saas/make-custom-user-model/).
Stick-it Notes PWA - do you like it? [ webapp + code ]
Tags: showdev, webdev, codenewbie, discuss
Published: 2020-05-14 17:47:48

Hey All!
  Tharun Here. I had developed this Stick-it Notes application and hosted it online. Would like to hear feedback on it. 

**Purpose of the web app**: To learn

**Features**: 
1. Can Add, delete notes
2. Works on Desktop and Mobile Phone responsively
3. Works offline
4. Can be installed on the desktop and mobile phones
5. Personalized to you, the notes you add stays in your phone


**About this application**: 

It is a PWA, meaning, a Progressive Web App. One of the current modern powerful ways to build websites. You can read more about PWA here

{% link https://dev.to/tharunshiv/pwa-why-should-you-use-it-and-not-use-it-447 %}


**Link to the website**: http://bit.ly/stick-it-notes


**Github Repo of the website**: 

{% github tharunshiv/stick-it-notes no-readme%}


Thank you
Also feel free to share the websites and PWAs which you have published.

An article by

{% user tharunshiv %}
Don't use "git add ."
Tags: git, development, cli
Published: 2020-05-14 17:37:00

---
title: Don't use "git add ."
published: true
description: The main reasons why you should use git add -A instead of git add .
tags: git, development, cli
cover_image: https://www.howtogeek.com/wp-content/uploads/2020/03/1-3.png
---

### TL:DR
`git add -A` will stages all changes
`git add .` will stages new files and modifications, without deletions
`git add -u` stages modifications and deletions, without new files

---

Wait, this post is in English. So keep going!

I never put enough thought into the mentor I had. He was not the teacher, he was a guide in this world of web development, just pointing my focus and attention to learning the right thing. And I remember when he told me to avoid using `git add .` and instead use `git add -A`.

At that time, I never thought about it, I just assumed I was doing it wrong, until yesterday I was wondering why there are two ways to add files to the stage area.

When you add files with `git add .`, you are adding every single file in the current folder, or structure, or anything like that, It's ok, you can do that, you can even add `git add file.js` for example.

But if you want to add any deletion, update and all changes in the other directories, in this case, you should use add `git add -A`, this `-A` means **ALL**.

Another way is to update only the updated files, without any test file, or some experimental code, in this case, you can use `git add -u`, this `-u` means **UPDATE**.

Easy to remember, right?

(()=>{})()
Short introduction to Deno
Tags: deno, typescript
Published: 2020-05-14 17:36:16

I would like to give a short introduction to Deno in the video below. It is only about 5 minutes long. This will cover installing Deno and event creating a few code examples. Also I will give my input to the big question at hand: "Will Deno replace Node.js?"

{% youtube ObmAjv5qHr8 %}
How to reduce debt during implementation
Tags: webdev, javascript, testing, programming
Published: 2020-05-14 17:17:43

---
title: How to reduce debt during implementation
published: true
description: See how teams are managing their projects using feature management to progressively deliver features to users with confidence.
cover_image: https://i.imgur.com/SeiWvDt.jpg
tags: webdev, javascript, testing, programming
---

&nbsp;

### How Feature Flags helps reduce debt during implementation

Feature Flags are essentially variables that are used inside conditional statements. Therefore, the blocks inside these conditional statements can be toggled 'on or off' depending on the value of the feature toggles. A block of code that has been toggled 'off' is similar to it being commented out. This allows developers to control the flow of their software and bypass features that are not ready for deployment.

The main usage of feature flags is to avoid conflict that can arise when merging changes in software at the last moment before release. Although this can lead to Flag debt. Flag debt arises due to the dead code present in software after a feature has been toggled on permanently and produces overhead. This portion of the code has to be removed carefully as to not disturb other parts of the code.

### [What is UpStamps?](https://www.upstamps.com)

[UpStamps](https://www.upstamps.com) is a Feature Flag Management Platform to separate code from different environments and projects. 

UpStamps helps teams manage their projects using feature management with a **Central control** to progressively deliver features to users with confidence.

[Sign Up for Free](https://app.upstamps.com)

🛳 Ship when you're ready 
🚀 Accelerate feature release 
🙈 Hide unfinished features

![UpStamps Control Center](https://i.imgur.com/FQEqNbP.png)

Useful links about UpStamps:

- [About](https://www.upstamps.com)
- [Documentation](https://docs.upstamps.com)
- [Start Testing in Production](https://app.upstamps.com)
What is ''__ main __'' in Python? 
Tags: python
Published: 2020-05-14 17:07:46

Main is the self. Without a main function, the Python code on import would you execute all code.

The main function is where your program starts, the beginning of your program.

So what you can add in your script is:

```python
def main():
    print('main')

if __name__ == “__main__”:
    main()
```

On running it will call the function main(). If another script imports this file the functions will be available, but it won't run the code.

So to summarize: '__main__' is the name of the scope in which top-level code executes. 

There are two ways of using a Python module: 

* Run it directly as a script
* import it

When a module is run as a script, its __name__ is set to __main__.

## Main in other languages

The main() function exists in many programming languages, it shows the computer where to start the program. While in Python it's not necessary to put everything in a function, in other languages it is mandatory.

For instance, in C you would write this:
```c
int main() 
```
In Java, a program starts this way:
```java
public static void main(String args[]) 
```

So the concept in Python is similar, it's the starting point of your program.

It is generally a good practice to divide your code into small <a href="https://pythonprogramminglanguage.com/functions/">functions</a>, that makes it easier to find bugs and easier to understand. One big long sequence of code is called spaghetti code.

**Related links:**
* <a href="https://gumroad.com/l/dcsp">Python course and book</a>
* <a href="https://python.org">Download Python</a>
Guess the number with Python !
Tags: python, codenewbie, tutorial
Published: 2020-05-14 16:55:48

Today I will be sharing tips for making a "Guess the number" game with the Python programming language.

Let's begin !

👉 Import the random module to generate the numbers randomly in the game.
```python
import random
```
💡 Introduce a infinite while loop.

👉 Generate a random number, initialize the chances to zero.
```python
while True:

    print("\nN U M B E R   G U E S S I N G   G A M E") 
    print("\nYou have 10 chances to guess the number.")
    
    # randint function to generate the random number between 1 to 100 
    number = random.randint(1, 100) 
    
    """ number of chances to be given to the user to guess the number or it is the inputs
    given by user into input box here number of chances are 10 """
    chances = 0
    
    print("Guess a number (1 - 100):")
```
👉 Add a while loop to count the number of chances used and take the input from the user.
```python
# While loop to count the number of chances 
    while chances < 10: 
        
        # Enter a number between 1 to 100  
        guess = int(input()) 
```
👉 Tally the user's input with the guess number accordingly.
```python
# Compare the user entered number  with the number to be guessed  
        if guess == number: 
            
            """ if number entered by user is same as the generated number by randint
            function then  break from loop using loop control statement "break" """
            print("Congratulation YOU WON!!!") 
            break
            
        # Check if the user entered number is smaller than the generated number  
        elif guess < number: 
            print("Your guess was too low: Guess a number higher than", guess) 
    
        # The user entered number is greater than the generated number              
        else: 
            print("Your guess was too high: Guess a number lower than", guess) 
```
👉 Increase the value of the chances variable one at a time as the user will be using one chance at a time.
```python
# Increase the value of chance by 1 as 1 chance is used
        chances += 1
```
👉 Verify if the user has identified the number or not.
```python
    # Check whether the user guessed the correct number  
    if not chances < 10: 
        print("YOU LOSE!!! The number is", number) 
```
👉 Ask a replay question and break the infinite while loop.
```python
    ans=input("Do you want to play again (y/n) : ")
    
    if ans != 'y' : 
        break
```
That's it! Wasn't that simple ?
You can also refer my GitHub repo :
{% github divyakelaskar/Guess-the-number %}
Dark Theme for your Angular app
Tags: angular, darkui, owwly, design
Published: 2020-05-14 16:51:56

Hello everyone. I would like to share with you my experiences of how I implemented basic light/**dark mode** for our **Owwly Angular web application**.

Background: The last trend for the dark theme option convinced us to introduce a similar approach to our website to fulfill all user's needs - especially mine 😎.

You can also **look at the real website**: https://owwly.com to check the described implementation yourself in a real-world use case.

Okay, let's begin.

For start define default theme class, which is going to be your fallback CSS class and default setup for the theme:

![](https://res.cloudinary.com/owwlytest/image/upload/v1589470671/articles/dark-ui/Pasted_Graphic_5_m75lmz.jpeg)

Create the definitions for colors and put them to the one list which is going to be used later.

*_colors.scss*
![TODO](https://res.cloudinary.com/owwlytest/image/upload/v1589471042/articles/dark-ui/Pasted_Graphic_4_hmmguw.jpg)

Create an SCSS script to iterate through the colors you defined and generate the right CSS variables:

*_theme.scss*
![TODO](https://res.cloudinary.com/owwlytest/image/upload/v1589470675/articles/dark-ui/Pasted_Graphic_6_euz2xv.jpeg)

To provide a smooth transition between both themes, add the CSS class for color and background transitions as below:

*_animations.scss*
![TODO](https://res.cloudinary.com/owwlytest/image/upload/v1589470678/articles/dark-ui/Pasted_Graphic_7_teznwc.jpeg)

Next, create the service responsible for themes toggling. *setTimeout* is not a pretty solution here, but it does the job. Thanks to it we don’t see the transitions when the page is loaded and style is set to dark. On the other hand, we don’t see page to load light and immediately change to the dark mode. A win-win solution to the rescue. 

*ui-style-toggle.service.ts*
![TODO](https://res.cloudinary.com/owwlytest/image/upload/v1589471079/articles/dark-ui/Pasted_Graphic_8_wnuf5s.jpg)

Initialize the theme toggle service when the app boots up to set previously selected by a user theme.

*ui.module.ts*
![TODO](https://res.cloudinary.com/owwlytest/image/upload/v1589470693/articles/dark-ui/Pasted_Graphic_9_yu5nrb.jpeg)

That's it, now you can use the defined values in your standard component styles as below:
![TODO](https://res.cloudinary.com/owwlytest/image/upload/v1589470699/articles/dark-ui/Pasted_Graphic_10_wieezj.jpeg)

It is a very basic implementation that works for us. I hope you will share your solutions on how you implemented light/dark mode in your angular websites. See ya!
TypeScript - Interfaces
Tags: typescript, javascript, webdev
Published: 2020-05-14 16:48:45

# TypeScript: Interfaces

As we read before, the typing system from TypeScript is the main feature inside this superset by adding a strong typed system into JavaScript. Now, one of the most used features is called: **Interfaces**

## What is an Interface?

An **Interface** we can calling as a properties contract with need to be fulfilled in order to satisfy the requirement in the code about that Interface. The sintax is pretty simple, to declare an interface need to be like.

```ts
interface <PutYourInterfaceNameHere> {
  yourProperty?: <your type here>;
}
// The ? is optional and you indicate into the contract that property is optional and is not required to fulfill the interface.
```

Example:

```ts
interface Foo { // <- Needs to be PascalCase
  Bar: string;
  MyBar: boolean;
  MyFoo?: number;
}
```

And how to use it? Just like a type, you need to declare it as a type:

```ts
let MyFooExample: Foo
```

Benefits? If you are using VS Code, Intellisense will be listening and helping you by showing all the properties that the interface has, also you can make a group of types you need in case you are using OOP, this helps you to make your code cleaner:

![TypeScript Interface Example](https://i.imgur.com/1LveZVx.png)

Pretty simple, isn't? Tell me what you think about the interfaces? Tell me in the comment section your thoughts and see you next time.
How to speed up your daily Docker builds
Tags: docker, ruby, node
Published: 2020-05-14 16:38:38

Nowadays, there is no way around Docker. It's a great technology that ensures that your software works on production the same as on your laptop. 

If you have a medium size Node.JS or Ruby on Rails project, with a hand full of dependencies, this command can take a couple of minutes: 

```sh
docker build -t orga/project:1.0.0 . 
```

Especially if you have dependencies with native extensions like libxml or sassc, the build will take a long time.
 
The build time can be reduced dramatically if you are using a Docker base image which includes already the majority of the needed dependencies. That's why I have, in most of my projects, a directory called `docker_base`, which contains a Dockerfile and package manager files for my base image. For a typical Ruby on Rails project the Dockerfile would look like this: 

```Dockerfile
FROM ruby:2.5-alpine

ENV RAILS_ENV=production

WORKDIR /usr/src/app_base

COPY docker_base/Gemfile .
COPY package.json .

RUN apk update; \
    apk add build-base; \
    apk add libxml2-dev; \
    apk add libxslt-dev; \
    apk add ruby-nokogiri; \
    apk add yarn; \
    apk add tzdata; \
    yarn install --production=true; \
    bundle config build.nokogiri --use-system-libraries; \
    bundle install --without development test; 

```

The first `COPY` command adds a Gemfile with the most important dependencies. These Gemfile does not include private (closed source) dependencies. That way the Docker base image can be later hosted on a public Docker Hub repository. The second `COPY` command adds the package.json file for the frontend dependencies. 

The `RUN` command is doing all the hard work which we want to avoid on our daily builds. It's installing all the native system libraries which are required for the Ruby and Node dependencies. In the last 3 lines we finally install all the Node and Ruby dependencies. 

Let's build the base image like this: 

```sh
docker build -t versioneye/base-web:1.0.0 . 
```

Now the regular Dockerfile in the root directory of the project can inherit from this base image. The first line of that Dockerfile would look like this: 

```Dockerfile
FROM versioneye/base-web:1.0.0
```

The dependencies in your Gemfile and package.json might change every day. That's why it's important that you run the install steps again in your main Dockerfile! That way new dependencies will be installed. However, the build time shrinks dramatically because the base image contains already the majority of the dependencies. In my case I could reduce the build time from 5 minutes to under 1 minute! 

What do you think about this method? Do you have another trick to reduce the build time of your daily Docker build?
How to have Debug and Release Firebase environments in an iOS project
Tags: ios, firebase, xcode, tutorial
Published: 2020-05-14 16:18:36

We should be using a debug environment when developing unreleased features to the public so we don't affect the environment where your real users are (avoids risks), plus we don't clutter it with testing data.

This is kind of obvious nowadays. But let's see how to do it with a Firebase project in Xcode.

1. Create your Development and Production projects in Firebase and download both _GoogleService-info.plist_.
2. Add a Firebase directory in your project, with _Development_ and _Release_ subfolders. Add the _plist_ of each environment to its respective folder, but **unchecking the add to the target option** because we are going to add the correct file to it during the build phase.
![Xcode](https://dev-to-uploads.s3.amazonaws.com/i/r64rb3x02szs0whl53z9.png)
3. Add a new build script phase. If you have a _Crashlytics_ script, add it before it. I've called it _Firebase script selection_:
![Build Phases](https://dev-to-uploads.s3.amazonaws.com/i/uwi00qf0xf45nd41apdz.jpg)
4. Add this code to the script you have added:

```bash
INFO_PLIST=GoogleService-Info.plist

DEVELOPMENT_INFO_PLIST=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Development/${INFO_PLIST}
RELEASE_INFO_PLIST=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Release/${INFO_PLIST}

echo "Checking ${INFO_PLIST} in ${DEVELOPMENT_INFO_PLIST}"
if [ ! -f $DEVELOPMENT_INFO_PLIST ] ; then
    echo "Development GoogleService-Info.plist not found."
    exit 1
fi

echo "Checking ${INFO_PLIST} in ${RELEASE_INFO_PLIST}"
if [ ! -f $RELEASE_INFO_PLIST ] ; then
    echo "Release GoogleService-Info.plist not found."
    exit 1
fi

PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Copying ${INFO_PLIST} to final destination: ${PLIST_DESTINATION}"

if [ "${CONFIGURATION}" == "Release" ] ; then
    echo "Copied ${RELEASE_INFO_PLIST}."
    cp "${RELEASE_INFO_PLIST}" "${PLIST_DESTINATION}"
else
    echo "Copied ${DEVELOPMENT_INFO_PLIST}."
    cp "${DEVELOPMENT_INFO_PLIST}" "${PLIST_DESTINATION}"
fi
```

And that's it! Now you will be using the development environment when developing/testing your app and the release one when archiving the project. 

If you want to test your release environment when developing too, you can just create a new compilation scheme for that:

![Scheme](https://dev-to-uploads.s3.amazonaws.com/i/cxc5ol3w3j4grgg20h4c.jpg)

![Schema configuration](https://dev-to-uploads.s3.amazonaws.com/i/q6qd6w9gu07mj7x03885.jpg)