teleren/devto huggingface dataset:
Cursus NestJS - installation de nest
Tags: beginners, french, nestjs, backend
Published: 2022-03-04 19:33:52

{% youtube AJb6B5iECQU %}

Bienvenue dans la première leçon qui est la seconde vidéo de la chaîne!
Je m'appelle Julien et je serai ton guide dans cette formation NestJS qui fera de toi un véritable expert de NestJS.

Alors abonne-toi pour progresser rapidement!

Je te retrouve dans le terminal pour installer Nest.

## Pré-requis:

NestJS étant un framework typescript pour node, il nécessaire que tu aies installé Node.js, idéalement la dernière version lts (Long Term Support).
```bash
node -v
```

## Installer la CLI nestjs

Ok, pour commencer il faut installer l'outil en ligne de commande via la commande:
```bash
npm i -g @nestjs/cli
```
J'utilise npm mais sens-toi libre d'utiliser un autre gestionnaire de paquet javascript.

À quoi va nous servir cet outil?
```bash
nest --help
```
- créer de nouveaux projets nest `nest new <nom du projet>`
- générer des modules, des contrôleurs, des services, des guards et autres joyeusetés le tout avec un fichier de test `nest g|generate <schema> nom`
- démarrer un projet nest 

## Créer un projet 

C'est parti pour créer un projet:
```bash
nest new nom-du-projet
cd nom-du-projet
```

Dans ce projet un certain nombres de script npm sont disponible:

Lancer les tests unitaires et fonctionnels (ou end 2 end)
```bash
npm run test
npm run test:e2e
```

Démarrer le projet en mode développement, c'est à dire avec un re-démarrage automatique lorsque les sources sont modifiées.
```bash
npm run start:dev
```

Transpiler la version typescript en javascript dans le dossier `dist`
```bash
npm run build
```

Démarrer la version transpiler
```bash
npm run start:prod
```

Appliquer le formatage standardisé du code:
```bash
npm run format
```

### Structure du projet

- src: contient les sources en typescript de l'API
- test: stocke les tests end 2 end
- dist: version transpilée en javascript

dans src:

`main.ts` => configuration et démarrage de l'application nest
`app.module.ts` => module principale
`app.controller.ts` => contrôleur utilisé pour déclarer les routes de l'API
`app.service.ts` => les services sont utilisés pour accéder à la base de données, faire des calculs, stocker de la logique métier


## Bibliographie et liens utiles

- [NestJS documentation: First step](https://docs.nestjs.com/first-steps)
- [Paquet npm](https://www.npmjs.com/package/@nestjs/cli)

![questions?](https://media.giphy.com/media/DUrdT2xEmJWbS/giphy.gif)

Je serai heureux de répondre à toutes tes questions en commentaires

:phone:[Discord Webeleon](https://discord.gg/h7HzYzD82p)

<script type="text/javascript" src="https://cdnjs.buymeacoffee.com/1.0.0/button.prod.min.js" data-name="bmc-button" data-slug="webeleon" data-color="#FFDD00" data-emoji="" data-font="Cookie" data-text="Buy me a coffee" data-outline-color="#000000" data-font-color="#000000" data-coffee-color="#ffffff" ></script>
The Partial utility type in TypeScript
Published: 2022-03-04 16:25:15

Hello everyone!

Today I'll tell about a cool feature of TypeScript, which is the Partial utility type.

This utility type works on types (per definition, and as such won't work with interfaces, a mistake I personally made), and makes all of its properties optional.

Lets take this code for example:



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

Here, we have a `Person` type, with some predefined properties with different types.

Now we want to create a new type with the same properties and their types, but they should all be optional.

We could insert the interrogation mark followed by a colon `?:` at each property, and indeed, that'll do the job, but as obvious, it is not the most efficient solution, not to mention that if we have an huge type, it can take some much valuable time that is better spent doing more productive tasks.

So what is the solution? The `Partial` utility type.

This is how its done using the aforementioned utility type.

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

As you can see, its usage is really simple and straightforward. It accept a single generic (think of it as a TypeScript's parameter, but for types, instead for functions), which is the Type we want its properties to become optional.


Now, we hover over the new `PartialPerson` type, we can see that all of the properties are now optional, and we didn't even have to know all of them beforehand.


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

Its definition per TypeScript is as follows:

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

They basically looped through all of the properties passed through the generic, and making each property optional with its type definition.

The main usage of it is the updating/editing tasks, when you want to edit an object through a function, but you only want to pass the object properties you intend to edit, and not all of them.

This feature is available in TypeScript since version 2.1

Bonus: You can use the `Required` utility type to make all properties of a type required, and if some or all of its properties are optional, they become required. This is the opposite of `Partial`, where all properties become optional.

Thank you for reading, and I hope that was beneficial to you!


________________________________________________________________

Connect with me on: 
* [Twitter](https://twitter.com/marouane_souda)
* [Instagram](https://www.instagram.com/marouane.codes)
* [GitHub](https://github.com/marsou001)
* [LinkedIn](https://www.linkedin.com/in/marouane-souda-837512163)
* [Personal website](https://marouanesouda.com)
Show JSON As Pretty Print With Syntax Highlighting in React
Tags: javascript, react, css, html
Published: 2022-03-04 18:57:46

In this post, we will learn how to show the JSON data as pretty printed, and with colored highlighted syntax in our ReactJS/JS apps.

Coming straight to the utility function below

```
export function syntaxHighlight(json) {
  if (!json) return ""; //no JSON from response

  json = json
    .replace(/&/g, "&amp;")
    .replace(/</g, "&lt;")
    .replace(/>/g, "&gt;");
  return json.replace(
    /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
    function (match) {
      var cls = "number";
      if (/^"/.test(match)) {
        if (/:$/.test(match)) {
          cls = "key";
        } else {
          cls = "string";
        }
      } else if (/true|false/.test(match)) {
        cls = "boolean";
      } else if (/null/.test(match)) {
        cls = "null";
      }
      return '<span class="' + cls + '">' + match + "</span>";
    }
  );
}
```

and the CSS
```
pre {
  outline: 1px solid #ccc;
  padding: 5px;
  margin: 15px;
}
.string {
  color: green;
}
.number {
  color: darkorange;
}
.boolean {
  color: blue;
}
.null {
  color: magenta;
}
.key {
  color: red;
}
```

Now we can use our syntaxHighlight function, just pass it with JSON to prettify and highlight

Example usage in ReactJS app:
```
import { useEffect, useState } from "react";

import { syntaxHighlight } from "./utils";
import "./styles.css";

export default function App() {
  const [ourJSON, setOurJSON] = useState();

  useEffect(() => {
    fetch("https://jsonplaceholder.typicode.com/todos/1")
      .then((response) => response.json())
      .then((json) => setOurJSON(json));
  }, []);

  return (
    <div>
      <h3 className="header">
        Show JSON As Pretty Print With Syntax Highlighting
      </h3>
      <pre
        dangerouslySetInnerHTML={{
          __html: syntaxHighlight(JSON.stringify(ourJSON, undefined, 4))
        }}
      />
    </div>
  );
}
```

[Credit for utility function](https://stackoverflow.com/a/7220510/8036756)

> Happy Coding, Thanks!
What is Unit Testing? Why Unit Testing is Important?
Tags: programming, unittesting
Published: 2022-03-04 18:57:15

## What is Unit Testing?
Unit Testing is a type of software testing where individual units or components of software are tested. The purpose is to verify that each unit of the software code works as expected. Units are tested by developers during the development (coding phase) of an application. The unit isolates a section of test code and verifies its accuracy. A unit can be an individual function, method, method, module or object.

The main aim is to isolate each unit of the system to identify, analyze and fix the defects.

Coding is an important step in software development. So before doing this coding, the requirements are collected and analyzed, the architecture is designed, the platform, tools and programming language are decided. Then if the project gets bigger, coding is started by going through some more steps (like class and interaction design). Now an important thing when writing code is unit testing where different units are tested. Now what does the unit mean? A module can be considered as a single, interface can be considered as a unit, class can be considered as a unit, and function can also be considered as a single. I will now talk about writing test code with a single function. When we write big programs, we write each task into a separate function and one function will do only one task. If it is ever seen that a function is doing more than one thing, then it is necessary to break down the function and write smaller functions. So this function is the smallest unit.



![Unit Testing Advantages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ofhjs54s0ka7x07gvtx.jpg)


## Unit Testing - Advantages:

- Reduces Defects in the Newly developed features or reduces bugs when changing the existing functionality.

- Unit Testing will reduce cost as defects are captured at an early stage.
It improves design and allows better code refactoring.

- Improves design and allows better refactoring of code.

- Unit Tests, when integrated with build gives the quality of the build as well.



## How to do unit test? 
After writing the function, you have to write another function in a separate file for that function which will call that function through different input parameters. Then we have to compare the output to see if the output we are expecting and the output the function is giving are equal. Diameter, our unit became test. Different packages have been developed to facilitate unit testing in all programming languages ​​prevalent in the industry. Although the unit can be tested without using these packages.




## Unit Testing LifeCyle:

![Unit Testing LifeCyle](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hsa5mo1oxadbjhhcq7v.jpg)

## Unit Testing Techniques:

- 
Black Box Testing - Using which the user interface, input and output are tested.

- 
White Box Testing - used to test each one of those functions behaviour is tested.

- 
Gray Box Testing - Used to execute tests, risks and assessment methods.
Python Random Modülü
Tags: python, turkish
Published: 2022-03-04 18:49:34

---
title: Python Random Modülü
published: true
description: Python random modülü kullanımı.
tags: python, turkish 
canonical_url: https://www.sinanerdinc.com/python-random-modulu
cover_image: https://www.sinanerdinc.com/img/2017/python_logo.png
---

Python içinde standart olarak gelen Random modülünden bahsedelim biraz. Rastgele sayı üretmeyi sağlayan bir modül olan Random, python 1.4 ve üzerinde kullanılabiliyor ve **mersenne twister** algoritmasını baz alarak çalışıyor. Uygulamanıza import ederek hemen kullanmaya başlayabilirsiniz. Hemen örneklere geçelim.

```
import random
```
şeklinde uygulamamız içerisine çağırdık.

## random()

Bu bize 0 <= n < 1.0 aralığında bir sayı döner.

```
>>> random.random()
0.38872204424977774
```

## uniform(min,max)

Bu bize min + (max - min) * random() işlemi sonucunda float bir sayı döner.

```
>>> random.uniform(1,100) # Rastgele float:  1.0 <= x < 100.0
52.19820527331601
```

## randint(min,max)

Min ve max aralığında integer olan bir sayı döner. Max dahildir. min <= n <= max

```
>>> random.randint(1,100)
86
```

## randrange(min,max)

Min ve max aralığında max dahil olmayan bir sayı döner. min <= n < max
3. bir parametre daha alır o parametre de bölünebilmeyi ifade eder.

```
>>> random.randrange(1,100)
71
>>> random.randrange(1,11,3) # 1 ve 11 arasında 3'e bölündüğünde 1 kalan bir sayı getir.
4
>>> random.randrange(1,11,3) # 1 ve 11 arasında 3'e bölündüğünde 1 kalan bir sayı getir.
7
>>> random.randrange(1,11,3) # 1 ve 11 arasında 3'e bölündüğünde 1 kalan bir sayı getir.
1
```

## sample(liste,q)

Liste içinde q adet rastgele değeri döner.

```
>>> sayilar = range(50)
>>> random.sample(sayilar,3)
[1, 19, 16]
>>> random.sample(sayilar,3)
[7, 10, 49]
>>> random.sample(sayilar,3)
[11, 37, 36]
```

## shuffle(list)

Verdiğiniz bir liste içindeki değerlerin sırasını karıştırır.

```
>>> l = list(range(10)) # örnek bir liste oluşturalım.
>>> l # bu listenin içeriğine bakalım.
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> random.shuffle(l) # l listesini karıştıralım.
>>> l
[4, 8, 7, 3, 2, 1, 6, 5, 9, 0]
```

## choice(list)

Verdiğiniz bir liste içinden rastgele bir değer seçer.

```
>>> liste = list(range(20)) # 0'dan 20'ye kadar sayılar gelsin.
>>> liste # doğru gelmiş mi kontrol edelim.
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> random.choice(liste)
0
>>> random.choice(liste)
5
>>> random.choice(liste)
10
>>> random.choice(liste)
11
>>> random.choice(liste)
5
```
ES6?  Array methods.
Published: 2022-03-04 18:25:53

Array. The (of) method generates an example of a new array from a variable number argument, regardless of the number or type of argument.

Converts and returns an array-like object or list (such as argument, novelist, DOMTokenList (used by classlist), 

NamedNodeMap (used by attribute property)) to a new array ();
The use-case is when you can't write a literal because you are passing a function-that-constructs as a funerary, and the eventual caller may pass only one number arg, or several args. In that case, Array will not do the right thing in the one-number-arg case.

The find () method executes a function for each array element. If no component is found, the find () method returns indefinitely. The find () method does not perform functions for empty elements.

The findIndex () method provides an index of the first elements of an array that satisfies a given test function. Otherwise, it returns -1

Array.keys( ) Returns only the key of the array element which is currently being indicated by the internal pointer
For Example:
var A = [ 5, 6, 10 ];
var iterator = A.keys()
  for (let key of iterator) {
   document.write(key + ' ');
   }
Array.values() The function is a built-in JavaScript function used to return a new array iterator object that contains the value of each index in the array. For Example:
var array = [ 'a', 'c',  'n' ];
var iterator = array.values();
for (let elements of iterator) {
  console.log(elements);
}
Output:
> a,c,n

The fill () method converts all elements of an array to a static value example:
const array1 = [1, 2, 3, 4];

console.log(array1.fill(0, 2, 4));
console.log(array1.fill(5, 1));
console.log(array1.fill(6));
out put 
 Array [1, 2, 0, 0]
 Array [1, 5, 5, 5]
Array [6, 6, 6, 6
Add Google Calendar in Notion
Tags: indify, notion, googlecalendar
Published: 2022-03-05 12:42:25

---
title: Add Google Calendar in Notion
published: true
date: 2022-03-04 18:25:20 UTC
tags: indify,notion,googlecalendar
canonical_url: https://medium.com/@staceypyee/add-google-calendar-in-notion-d8d2a135db6c
---

Most of us would like to save our time by reusing the same calendar. So that we just need to add or edit event at a place and get everything synced.

Based on the official tutorial from Notion, it can be achieved with the following steps as mentioned as followed:

[Embed Google Calendar](https://www.notion.so/Embed-Google-Calendar-f1dd42e7071d495ca6764d03c1d2972e)

![](https://cdn-images-1.medium.com/max/1024/0*QY7uDWj6vZhtjYdi)
_Photo by Hello I'm Nik on Unsplash_

Hmm, unfortunately this is the **limitation**. The pre-requisite for the above to work — you have to compromise and make the calendar as  **public**.

That being said, anyone with the calendar link will be able to see all your event details.

### Question:

What if the data is so **important** to me that I only want to keep it  **private**?

After researching, this is the best option I have gotten thus far.

[Indify - Notion Widgets](https://indify.co/)

### How to add Google Calendar with Indify?

1. Sign up or with your intended email.
2. After sign up or login successfully, you should be able to view the widgets available to you. **Choose Google Calendar.** Give a title to your widget.

![](https://cdn-images-1.medium.com/max/1024/1*FbSwkq-NQ057sebH0ikadQ.png)
_Screenshot of Calendar widget_

3. Select your intended calendar in **Select Calendar ** field.

![Screenshot of Indify Calendar widget](https://cdn-images-1.medium.com/max/1024/1*u7rkoAFe6Rm4wEwgozCnKw.png)

**P/S:** For free user, you can only select one calendar for a widget, with other usage limitations. Upgrade to Pro if you wish to unlocked those features.The most useful feature might be adding multiple calendar from your account.

4. **Copy the link** of your Google Calendar widget.

5. Proceed back to Notion, and **create embed** in your desired Notion page.

That’s all folks~

Happy Exploring
One color palette a day with example. -003
Tags: webdev, design, uiweekly
Published: 2022-03-04 18:15:10

www.colorsandfonts.com

## Color and typography for Web Developers and Digital Designers.

From today, I will sharing 1 Color palette a day as I did before, when I started Colors & fonts.



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7cjpdddr49m93shpqqu.jpeg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5pz0dlk1uib55x9ubz1.jpeg)


You will find them here, [Dribbble](https://dribbble.com/MichaelAndreuzza), [Instagram](https://www.instagram.com/apes_of_london/), [Pinterest](https://pin.it/w18zxbr) and [Twitter](https://twitter.com/Mike_Andreuzza).

Since 2017 - 2022
Webpack Hashing name of files is different
Published: 2022-03-04 18:15:03

Hashing name of files when I run npm run build it generated in different number of the number in index.html file


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

in index.html file code is :

  ` <script src="../src/plugins/common/common.min.js"></script>
   <script src="../src/js/custom.min.js"></script> `
Vectores (Array o Arreglos)
Tags: spanish, tutorial, computerscience, español
Published: 2022-03-04 17:58:12


Si acabas de encontrar esta publicación, antes de continuar te recomiendo que le des un vistazo a los artículos previos de esta serie, que brindan conceptos claves para comprender las Estructuras de Datos.

---

Los **Vectores (Arrays o Arreglos)** son estructuras estáticas lineales finitas ordenadas secuencialmente, y de datos homogéneos, es decir, del mismo tipo de dato y se puede acceder directamente a cada elemento del mismo mediante el uso de índices, donde el índice de un elemento (1, 2, ..., n) designa su posición dentro del vector. Es una secuencia de posiciones de la memoria a las que se puede acceder directamente.

![Vector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3b6wb31s37yk8xsg771o.png)


>
> En general, los índices de un vector comienzan en 0, pero este puede diferir acorde al lenguaje de programación utilizado.
>

## Operaciones elementales sobre Vectores
- Asignar
- Leer
- Recorrer (Acceso secuencial)
- Insertar
- Eliminar
- Ordenar
- Buscar

Cabe resaltar que otras operaciones pueden ser definidas sobre esta estructura como mezclar, filtrar, copiar, etc., acorde a las necesidades del problema por resolver.


## Vector Multidimensional
Un vector multidimensional puede tener *n* cantidad de dimensiones, en consecuencia se dice que es *n*-dimensional. También se lo puede ver como un vector de vectores de vectores, cuyos elementos pueden ser referenciados por dos o más índices.

### Vector Bidimensional
Un vector multidimensional de 2 dimensiones, es decir, un vector bidimensional recibe el nombre de matriz o tabla, es un caso especial del vector multidimensional,

El mismo puede ser considerado como un vector de vectores. Por consiguiente, es un conjunto de elementos homogéneos, en el cual existe un orden y en el que se necesita especificar dos índices para poder identificar cada elemento, es decir, es necesario definir la fila y la columna en la matriz para poder acceder a cada elemento, **Matriz[fila][columna]**.

![Matriz](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/au86re81q6cxhtwjuk0c.png)
### Vector *n*-dimensional
Los conceptos de rango de índices y número de elementos se pueden ampliar directamente desde vectores de una y dos dimensiones a vectores de orden más alto. Un vector puede ser definido de tres, cuatro hasta de *n*-dimensiones. 
En general, un vector *n*-dimensional requiere que los valores de los *n* índices sean especificados a fin de identificar unívocamente un elemento. Si cada componente tiene *n* índices, se dice que el vector es de *n* dimensiones. En la figura se observa un vector de 3 dimensiones, un Cubo. 

**Cubo[0][0][0]** representa el elemento del cubo resaltado en azul; mientras que el elemento **Cubo[2][2][0]** esta resaltado en verde.

![Cubo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fe9vd6w5b90f0gzkwk55.png)

---

¡Gracias por leer! 

Ponte en contacto en Twitter [@sZalimben](https://twitter.com/sZalimben), y si te gusta mi contenido puedes realizar una donación *[invitándome un café](https://www.buymeacoffee.com/szalimben)*.
Mental health
Tags: mentalhealth
Published: 2022-03-04 17:47:28

I don't know what drove me into writing this article but I believe through this article I will communicate to many and give  hope to many.
How is your mental health right now? How are you feeling are you afraid, hopeless, anxious, suicidal.
Recently have been feeling anxious. Anxiety is that condition that's accompanied with fear and worry. from my research have found out that can be as a result of childhood trauma and also your upbringing. Anxiety makes you a slave of your thoughts you fear to try something because you're worried what will people say or what if I can't do it.

**Suicide**

What comes in your mind when you hear about suicide,I remember I lost a friend to suicide.Do you check on your family? family is anyone close to you.Some of us assume that this is a man he will maneuver around and come into his senses no please, let's stop giving men these superhero titles and thoughts.It does not make you less of a man if you share your problems in fact to me that's a hero.Do you know the largest population of depressed people is men and children.Men who is the most important person in your life? Wife, children, family?? Noo you're the most important person in your life work on your self growth and love.You can't love your family if don't love you.
Many are asking how are children depressed? How many of us parents fight infront of kids,Use abusive words Infront of our kids and also direct to the kids,Compare your kids and many more.are you among the group how are planning to change this inorder bring up functional generation?.
Any time you feel your mental health is at stake kindly seek help from professionals not from your religious leaders...A professional is trained to handle the cases and religious leader is trained to handle religious matters. Yes some religious leaders are trained too. what if am financially down? we have institutions that offer free service inquire around you.
Let's embark on this journey of healing and living a happy and stress free life.
Please if someone confides with you don't make them regret sharing .Be the light to the person.
A healthy mind is a happy family.