teleren/devto huggingface dataset:
Connexion Bureau à distance - Utiliser 2 écrans sur 3
Tags: discuss, tutorial, french
Published: 2023-01-23 15:31:00

Avec l'explosion du télétravail, il arrive de plus en plus que l'on travaille en connexion à distance. Mais, l'utilisation de cet outil peut être gênant si on a plusieurs écrans et qu'on ne veut pas tous les utiliser.

Aujourd'hui on va voir comment faire pour utiliser *(par exemple)* seulement 2 écrans sur 3.

---

## 1 - Définir la configuration de base
Afin de pouvoir choisir les écrans sur lesquels le partage de connexion va se faire, vous devez d'abord **vous créer une configuration où vous voulez utiliser "tous les écrans"**.

## 2 - Mise à jour de la configuration
Ouvrez le fichier de configurations créé à l'étape précédente avec un bloc note *(ou n'importe quel autre éditeur de texte)*.

Regardez si vous voyez le paramètre suivant : `selectedmonitors`

Si vous ne le voyez pas, ajoutez le en vous basant sur l'exemple ci-dessous.

```
selectedmonitors:s:0,1,2
```

Les identifiants que vous voyez en tant que valeur du paramètre correspondent aux identifiants des écrans que vous voulez utilisez pour la connexion à distance.

## 3 - Récupération des identifiants
Afin de récupérer les identifiants, il vous suffit d'exécuter la commande suivante :
```bash
mstsc /l
```

Vous allez obtenir la pop-up suivante où vous pouvez voir les identifiants des écrans, ainsi que leurs coordonnées.
![](https://websetnet.net/wp-content/uploads/2021/01/image-3.png)

Dans cet exemple, **2** est l'écran principal qui est au centre. **0** se trouve à sa gauche *(vu qu'il a sa coordonnée x de négative)* et **1** se trouve à sa droite.

A présent, vous pouvez aller remodifier le fichier de configuration pour y mettre uniquement les écrans dont vous avez besoin.

---

## Liens
- Documentation Microsoft sur la commande mstsc : https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc753907(v=ws.11)

---

J'espère que ça vous sera utile! 🍺

---

<center><h3>Vous voulez me supporter?</h3></center>
<a href="https://www.buymeacoffee.com/mxguilbert7" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
useMemo vs usecallback in simple terms
Published: 2023-01-16 15:51:37

When building a React application, two hooks that are commonly used for performance optimization are useMemo and useCallback.

useMemo is a hook that allows you to cache the result of a expensive computation and only re-evaluate it when one of the dependencies has changed. This can greatly improve the performance of your application by avoiding unnecessary re-renders.

useCallback is similar to useMemo, but it is used to cache the reference to a function, instead of caching the result of a computation. This is useful when passing a function down as a prop to a child component and you want to avoid re-creating the function on every render.

In short, useMemo is used to cache the result of a computation and useCallback is used to cache the reference to a function. Both can help improve the performance of your React application by avoiding unnecessary re-renders.


```
import { useMemo, useCallback } from 'react';

function MyComponent({ data }) {
  const memoizedData = useMemo(() => {
    // perform expensive computation on data
    return data.map(item => item * 2);
  }, [data]);

  const handleClick = useCallback(() => {
    console.log(memoizedData);
  }, [memoizedData]);

  return (
    <div>
      <button onClick={handleClick}>Log Data</button>
    </div>
  );
}

```

In this example, useMemo is used to memoize the result of an expensive computation performed on the data prop. This means that the computation will only be performed again if the data prop changes.

useCallback is then used to create a callback function that will only change if the memoizedData value changes. This is useful when passing the callback as a prop to a child component, as it will help prevent unnecessary re-renders of the child component.
Using JSX in React
Published: 2023-01-23 15:28:20

React is a JavaScript library that was made to help developers create web applications easily and painlessly. In React, we use JSX, JavaScript XML, to create elements in the DOM instead of HTML although the syntax for JSX looks quite similar. JSX helps describe what the UI (user interface) should look like.

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

To start, we declared our heading as a variable with const and on our second line we see our element variable being declared, which is where we will be using JSX. As you can see we use opening and closing tags to put our h1 element and set the id to header. In. between the the tags we put our our heading variable that we defined earlier in curly braces so we can "append" to the page.

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

And there we have it! This was a simpler and easier way to write our HTML.
11- Manage directories and files in Python
Tags: python, programming, tutorial, beginners
Published: 2023-01-23 15:24:02

--- series: Python for scientific research ---

os module functions:

* **os.getcwd()** obtains current working directory
    
* **os.chdir(dir)** changes current working directory to dir
    
* **os.listdir(dir=".")** list files in directory dir
    
* **os.path.exists(path)** checks whether path exists
    

Print current directory:

```python
import os # import modules
print (os.getcwd()) # e.g., "C:\Users\Azad"
```

Change the current directory to the home directory:

```python
import os, os. path # import modules
home_dir = os.path.expanduser ("~") # get home directory
print(home_dir)
os.chdir (home_dir )
```

List all files in the home directory:

```python
print(os.listdir()) 
# ['$netrc', '.anaconda', '.bash_history', '.bundle', ...]
```

If you like the content, please [SUBSCRIBE](https://www.youtube.com/channel/UCpbWlHEqBSnJb6i4UemXQpA?sub_confirmation=1) to my channel for future content.

To get full video tutorial and certificate, please, enroll in the course through this link: [https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7](https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7)
Serializers with Ruby on Rails
Tags: rails, ruby
Published: 2023-01-23 15:21:15

With our final learning phase at the Flatiron School we began by learning about Rails, which is a library used for the Ruby language. Rails has done an amazing job of simplifying and automating a lot from plain old ruby. One of my favorite things about rails is the inclusion of serializers for the data that exists in your backend. Serializers are files within your app that allow us as developers to customize how users will see the data that exists. When creating our tables in rails we can enter 'Rails g resource [tablename]' and the serializer file will automatically be created.

After the file has been created it will default to show every column in your table (except the timestamps), from here we can edit which attributes we want to show when viewing data in our app. One thing that I have noticed most people take off is showing the id column from each table, since users themselves don't typically need to see the id for each data point brought in.

Serializers can do a lot more than just edit one tables data view. If associations exist between tables whether they are many-to-many, one-to-many, etc. we are able to show that relationship through serializers.

Think of a blogging application, a user can have multiple blog posts but each blog post belongs to one user. In our serializers we can establish the relationship like normal, users: `has_many :posts` & posts: `belongs_to :user`. From here we can see that when we use a tool like postman to view users we can see the associated posts that exist for each respective user. Even with associations like this, we can still filter through which attributes we want out user to see.

Rails has been an amazing resource for me when trying to create full stack applications. The initial setup and modifications make it so simple and helps ruby developers speed up the process in which they design and apply the backend files they need for each project.
What are your goals for the week January 23?
Tags: discuss, watercooler, motivation
Published: 2023-01-23 15:19:24

What are your goals for this week?
 
- What are you building? 
- What will be a good result by week's end?
- Are you attending any events this week?
- Did you meet your goals last week?

**Last Week's Goals**

- [:white_check_mark:] Update resume/linkedIN/portfolio.
- [:white_check_mark:] Job Search. Spending my mornings hitting LinkedIn and sending DMs. Applying to open roles.
- [:x:] Learn something. Planning a project out. Did not get started on project. 
- [:x:] Encourage Virtual Coffee members in our Month of Learning Challenge.
- [:x:] Blog Just this weekly post and a short thing on community. I need to build something and blog on it.

**Last Week's Wins**
- Need to start a wins log, cause this am all I can think of is the normal stuff I did last week. Nothing spectacular. Biggest thing is a updated header. I added my avatar to my contact info header.

### Still working on: 
- Update resume/linkedIN/portfolio.
- I'm taking a course starting later this month, course hasn't dropped yet.


**This Week's Goals**

- Update resume/portfolio.
- Continue Job Search.
- Start new project.
- Blog.
- Attend [Jam.DEV](https://cfe.dev/events/the-jam-2023/) Jan 25 & 26.

**This Month's Goals**
- Gain more followers here. I would like to have more followers on DEV than I had on the bird site. Need about 100 more here. My twitter followers increased but most were bots.
- Gain more followers on Mastodon. [@jarvisscript@hachyderm.io](https://hachyderm.io/@jarvisscript) 

You've read my goals so I'll throw that question back to you.

What are your goals for the week?

```
-$JarvisScript git push
```
13- Using SciPy (Scientific Python) library in Python
Tags: python, programming, tutorial, beginners
Published: 2023-01-23 15:17:53

--- series: Python for scientific research ---

SciPy denotes Scientific Python and it is valuable for scientific analysis.

#### SciPy installation:

```xml
pip install SciPy
```

Examples of the functions in SciPy:

* Integration: (scipy.integrate)
    
* Optimization/Fitting: (scipy.optimize)
    
* Interpolation: (scipy.interpolate)
    
* Signal Processing: (scipy.signal)
    
* Spatial data structures and algorithms: (scipy.spatial)
    
* Statistics: (scipy.stats)
    
* Multi-dimensional image processing: (scipy.ndimage)
    

#### Importing from SciPy

```xml
from scipy import optimize
from scipy import spatial
# first form
from scipy import stats
# second form
from scipy.stats import distributions
```

#### T-Test

```xml
from scipy.stats import ttest_ind
x = ([1, 3, 5, 7, 11])
y = ([2, 4, 6, 8, 4])
res = ttest_ind(x, y)
print(res)
```

#### Statistical Description of Data

```xml
import numpy as np
from scipy.stats import describe

x = np.random.normal(size=50)
res = describe(x)

print(res)
# DescribeResult(nobs=50, minmax=(-2.5511668761037507, 1.7772593602939395), mean=0.02937722230632724, variance=0.9754504451804601, skewness=-0.12226936632001595, kurtosis=-0.39363575297869824)
```

#### Interpolation

```xml
import numpy as np
x = np.array([0., 1.,5., 8., 10.])
y = np.array([0., 4., 1., 6., 8.])
f = interp1d(x, y)
f(3)
# array(2.5)
```

#### Integration

```xml
import scipy.integrate
f= lambda x:np.exp(x**1)
# print results
i = scipy.integrate.quad(f, 1, 2) # quad -- General purpose integration.
print(i)
# (4.670774270471606, 5.1856011379043454e-14)
```

#### Input and Output

Scipy.io package provides multiple methods to handle inputs and outputs of multiple formats such as:

* Matlab
    
* Netcdf
    
* IDL
    
* Arff
    
* Matrix Market
    
* Wave
    

```xml
import scipy.io as syio
  
# Save the mat file
n = 14031977
syio.savemat('test.mat', {'test': n})
  
# Load the mat File
matf_contents = syio.loadmat('test.mat')
print(matf_contents)
  
# printing the contents of mat file.
matf_contents = syio.whosmat('test.mat')
print(matf_contents)

#{'__header__': b'MATLAB 5.0 MAT-file Platform: nt, Created on: Mon Jun 28 16:15:59 2021', '__version__': '1.0', '__globals__': [], 'test': array([[14031977]])}
[('test', (1, 1), 'int32')]
```

> If you like the content, please [SUBSCRIBE](https://www.youtube.com/channel/UCpbWlHEqBSnJb6i4UemXQpA?sub_confirmation=1) to my channel for the future content.
> 
> To get full video tutorial and certificate, please, enroll in the course through this link: [https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7](https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7)
SQL Window Functions Explained
Published: 2023-01-23 15:12:24

Window functions are probably the most confusing section of SQL. You might think, "So what? They just came up with some additional functions". Not really. "Window functions" is a separate language built into regular SQL. And it's more complicated than everything you know about SELECTs.

In short, window functions assist in making great analytical reports without Excel. Maybe you want to calculate monthly sales percentages over the year? Window functions. Split marketing channels into effective and ineffective ones? Window functions. Choose the top 10 clients for each segment? Same.

I've read several dozen articles explaining SQL window functions. They all suffered from one of two problems:

- Easy read without much practical value, describing 10% of features.</li>
- Difficult to comprehend. If I did not know the subject — I would not understand a thing.</li>

![How I see complex queries](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mr6k4ktqojdi3ejhygwq.png)

_SQL window queries can look like this for an unfamiliar reader._

I want people to understand SQL windows better. So I decided to write a book — _SQL Window Functions Explained_.

## About the book

It is a clear and visual introduction to window functions. Clear — because I can describe complex topics in a readable way. Visual — because I have prepared a hundred pictures and GIFs to help you understand SQL windows.

Window functions are a complex topic. So the book only teaches a little at a time. It gives just enough theory and a lot of practice — because it's the only way to turn abstract knowledge into skills.

Here is what you will learn:

1. Why use window functions
2. Windows and functions
    - Ranking
    - Offset
    - Aggregation
    - Rolling aggregates
3. Frames
    - ROWS and GROUPS
    - RANGE
    - EXCLUDE
    - FILTER
4. Practice
    - Product analytics
    - Handling duplicates
    - Finding the gaps


![Book poster](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8onqj8whx5jloxfkbv2.png)

_Every chapter covers a single topic in depth_

10 of the 13 chapters are ready, and I’ll publish the rest by May 2023.

And here is an [excerpt from the book](https://antonz.org/why-use-sql-window-functions/).
CSS tutorial series: The float & clear properties
Tags: beginners, webdev, tutorial, css
Published: 2023-01-23 15:04:21

This post is going to discuss the CSS `float` property. _The elements inherit the property values from their parent_.

## Float property

| Property| Value|
|---------|:----:|
| `float` | `left`, `right`, `none`, `inherit`|

Using this property takes the element out of the page flow and allows its positioning to the left or right side of its container. 

Let's consider that we have, an image followed by a paragraph, using the `float` property will place the image to the `left` or `right` of these elements' container.

- Using the value `none` is the default value of the `float` property meaning it will display the element in its default position.

## Clear property
The clear property defines how to handle the sibling of a floating element.


| Property| Value|
|---------|:----:|
| `clear` | `left`, `right`, `both`, `none`, `inherit`|

- `none` is the default value of the `clear` property which states that, no elements that are left or right floated are pushed under a the element.

- when applied the `left` property value, pushes the element under the `left` floated elements.


- when applied the `right` property value, pushes the element under the `right` floated elements.

- when applied the `both` property value, pushes the element under both `left` & `right` floated elements.


{% codepen https://codepen.io/fullstackjo/pen/KKBQxzL %}
Create a complete responsive landing page website using HTML & CSS
Tags: webdev, codenewbie, html, css
Published: 2023-01-23 15:03:38

{% embed https://youtu.be/jGSN1pvzUDI %}

Learn how to create a responsive website using HTML and CSS Easily by watching this step-by-step web design video tutorial.

You will get the **source files** from the video description on YouTube.
🤔 What Fetch Examples Always Miss
Tags: javascript
Published: 2023-01-23 14:48:38

Most examples of using `fetch()` are missing something very important. Here it is:

```js
if (!response.ok) {
  throw new Error(`Unexpected response status: ${response.status}`);
}
```

The quintessential `fetch()` example from [MDN itself](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) looks like this:

```js
fetch('http://example.com/movies.json')
  .then((response) => response.json())
  .then((data) => console.log(data));
```

Rewrite this as:

```js
fetch('http://example.com/movies.json')
  .then((response) => {
    if (!response.ok) {
      throw new Error(`Unexpected response status: ${response.status}`);
    }

    return response.json();
  })
  .then((data) => console.log(data));
```

To spare yourself the following problems:

1. `Uncaught (in promise) SyntaxError: Unexpected token '<'` - This error baffles beginners all the time. This generally means the server returned an HTML response (often 404 "Not Found") so parsing it as JSON fails.
2. Crap data flowing through your application. Maybe the server responds with status 500 and `{ "error": "Internal Server Error" }` in the body, but your code treats it as a good response and it causes issues downstream, at best a mysterious error message.

The code I demonstrated which checks `response.ok` isn't necessarily the exact code you should write. Sometimes a 404 or other "non-ok" response is actually perfectly "okay" and should not result in an error. The key is really just to check `response.status` and handle it appropriately, rather than ignoring it and assuming everything is fine.

Learn more about [response status codes and what they mean on MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status). Generally speaking, anything in the 200-299 range is an okay response. Anything 300-399 is redirection - you rarely have to worry about this because HTTP clients (including fetch) will automatically do the redirect for you. 400-499 indicates a "client error", these include validation errors, not found, that kind of thing. This range of errors indicates that the problem is with your request. Finally, 500-599 means there was some kind of error server-side. A response in this range should almost always be thrown as an error in your JS code (or retried).

`response.ok` is the same as `response.status >= 200 && response.status <= 299`

Stay safe out there!
Pass It Around
Published: 2023-01-23 14:45:03

When developing in react we've all had the issue of the errant or misplaced prop. It can be hard to figure out exactly where you want to make a fetch, post to the server, or even just initialize a specific state. My general advice to solving the issue of not having access to a prop in the component you want it in is to start by drawing a component hierarchy to visualize your tree of components. While this is very important it can be quite the challenge for more extensive apps, especially if your like me and only made a visual representation of your components after getting lost.


![Complex Component Hierarchy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w49nvw392fvxe923eadt.png)

As you can see above getting from A to B could be an absolute nightmare if you weren’t prepared. This is why you always want to draw out a component hierarchy at the onset of your project not in the middle after writing some code.

My second nugget of wisdom is this: It's possible to pass it up, it's best to pass it down, side to side will leave you with a frown. You might not be on the best terms with your siblings but in react siblings have a no contact order, you simply can't get information from on sibling component to another without going through mom or dad first. In general you want to put your prop in the lowest component that still has access to pass it down to all components that will need the prop.
Amplify API Auth with Cognito Custom Scopes - overview and temporary solution
Tags: cognito, aws, amplify
Published: 2023-01-23 14:44:18

Recently I have faced a truly annoying problem, whose understanding took me 1 week. Here is a simple overview of the problem and potential solution which I found:

## Overview
Amplify is a tool which helps frontend developers create and manage backend resources. It comes with predefined libraries which take care of implementing communication with AWS Backend.  With Amplify, we can easily create authorization which work with Cognito and Rest API requests for API Gateway. The problem begin when we want to use Cognito User pool authorization for Rest API.

## Problem
Due to [AWS Docs ](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate-with-cognito.html) to restrict Rest API with Cognito User pool you should create _Resource server_ and protect your endpoints with _Custom scope_. However, Amplify, and even more precisely _AndroidSDK_, doesn't return Custom Scopes if Hosted UI is not used --> [link to Issue](https://github.com/aws-amplify/aws-sdk-android/issues/684)
**If you don't want to use Hosted UI, currently you cannot use Custom Scopes.**

## First solution - stick with what you got 
Use _aws.cognito.signin.user.admin_ scope to protect endpoints. It's not perfect solution, it can work only if all your endpoints requires same permissions. It's still better than not protecting your endpoints at all. If you don't use any scope at API Endpoints, by default API Gateway would assume that _openid_ scope is used, which will result in authenticating to API with _ID token_ instead of _Access Token_. 

## Second solution - do it yourself
If your project requires Custom Scopes and you really don't want to use Hosted UI for your mobile app, you have to implement token management yourself. You can do it by sending a request for _Grant Code_ and then sending another request for all tokens with Cognito credentials in the body. You also have to take care of proper protection of all requests. It's harder because you have to take care of token management by yourself (as well, you could not use Amplify/AWS SDK at all). 

## Third solution - move to Hosted UI
It is what it is. The simplest solution would be using Hosted UI since there are no other options right now.  Let's hope that AWS will  provide further improvements in the nearest future.


None of this solution is perfect, and the most recommended would be moving to Hosted UI, which will result in lower user experience.