teleren/devto huggingface dataset:
Authenticate using Auth0
Tags: security
Published: 2023-01-14 22:08:28

In authentication, a user or application proves they are who they say they are by providing valid credentials. The most common verification is password, often combined with other methods, such as a fingerprint.

**Auth0** simplifies the use of open industry standards like OAuth 2.0, OIDC, and SAML to authenticate. Users can log into your applications with social media credentials, corporate accounts, and a broad range of other credentials.


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

So , we have 2 ways.

1) Add Login


2)Provision Users


**Add Login**
Here we have 3 options.

- Login

- Single Sign on

- Passwordless

**Provision Users**
Here we have:

- Identity Providers

- Database connections

- Enterprise connections

- Protocols

- Connection setting best practices


For detailed information, kindly follow this [official documentation](https://auth0.com/docs/authenticate)
phpMyAdmin Docker Lightweight
Tags: php, mysql, phpmyadmin, docker
Published: 2023-01-14 20:59:28

This project is built on top of the official phpMyAdmin fpm-alpine image, it includes Caddy web server and extra dark themes.

The docker image is automatically updated, so the latest phpMyAdmin version is always supported.

Themes included:

`blueberry`
![blueberry phpMyAdmin dark theme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzbtk86b5k2xclg6o8hp.png)

`BooDark`
![BooDark phpMyAdmin dark theme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kkd3q1ka9lyef4crq9cw.png)

Project address:
[https://github.com/beeyev/phpmyadmin-docker-lightweight/](https://github.com/beeyev/phpmyadmin-docker-lightweight/)
How to fetch and play a mp3 from play.ht AI voices with the web Fetch API
Published: 2023-01-14 20:48:16

Yes, it's possible to get and play the mp3 of the AI voices of play.ht! Just in your browser, just client-side. You can open up developer console and copy paste the code. 

You have to replace **SECRETKEY** and **USERID** below with your own ones. You log in and find them here: https://play.ht/app/api-access
or via menu: Accessibility -> Integrations -> API Access

```

async function speak(text) {
  return new Promise(async (resolve, reject) => {
    try {
      const response = await (await fetch('https://play.ht/api/v1/convert', {
        method: 'POST',
        headers: {
          'Authorization': 'SECRETKEY',
          'X-User-ID': 'USERID',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          "voice": "en-US-MichelleNeural",
          "content": text.split(/\.|\?|!/),
          "title": "Testing Italian api convertion"
        })
      })).json();
      const mp3Url = `
      https://media.play.ht/full_${response.transcriptionId}.mp3`;
      console.log(mp3Url);
      while(true) {
        console.log(`trying again...`);
        if((await fetch(mp3Url)).status === 200) {
          snd = new Audio(mp3Url);
          snd.play();
          snd.onended = resolve;
          break;
        }
      }
    } catch (err) {
      reject(err);
    }
  });
}
```

### Finding the right mp3 url
I discovered the mp3 URL "https://media.play.ht/full_${response.transcriptionId}.mp3" by logging into the play.ht website, navigating to the 'files' section in the menu on the left, and playing the audio fragments. This URL was not included in the play.ht documentation. I also noted that the URL provided in the documentation for fetching the mp3 file, "./articleStatus?transcriptionId={transcriptionId}", did not work and returned a "Forbidden" error. 

### A loop until the mp3 is available
The mp3 is not immediately available, so I made a while-loop to try again and again!

### Promise
The function is a promise, so that you can also await it. This can be useful in applications, so that you know when the text has been spoken

### Voice
You can change the voice from a list [here](https://playht.github.io/api-docs-generator/#standard-api-voices). In the script above just replace **en-US-MichelleNeural** with the voice name.
React Router v6 in React Js with Complete Project Of 2022
Tags: react, webdev, javascript, beginners
Published: 2023-01-14 20:32:40

**React Router** is a library for routing in React js . It allow the navigation between views of various components in React Application , That allow changing the browser URL . Lets create the simple React application to understand the flow of **react router** .

# You Tube
{% embed https://www.youtube.com/watch?v=oyutEaJyBV8&ab_channel=ziontutorial %}



In this application the components would be Home component , About component and last one is contact component so that we can jump or navigate to different component easily . You can refer the below example how it look like at the end of this tutorial.

![React Router](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6a399640uyoftqhnnhm.gif)


Full Detail Article : https://bit.ly/3FLY1uE

People are also reading:
Simple interest calculator using React Hooks

React Router v6 in React Js With Complete Project Of 2022

Creating Simple Sum Calculator

BMI Calculator in React JS – useState Hook
Why Good Software Architecture and Sustainable Design Patterns are More Important Than Ever in Today's Job Market
Tags: architecture, onboarding, designpatterns, discuss
Published: 2023-01-14 19:39:10

Hey fellow developers, have you heard of the term "rage applying"? It's when people get fed up with their current job and apply for multiple new ones out of anger. And it looks like it's becoming more common - recent statistics show that 74% of people would leave their current role within the next 6-12 months, compared to only 47% in 2021.

As developers, this highlights the importance of having good software architecture and sustainable design patterns in place. Good architecture means more readable, maintainable and scalable code - which makes it easier for new developers to understand and work with. And following design patterns helps to make the architecture more predictable and consistent, which leads to more efficient onboarding and faster ramp-up times for new developers.

We all know that documentation alone is not enough. With high employee turnover, it's important to make sure that our codebase is easy to understand, maintain and scale. This way, new developers can hit the ground running and contribute to the team more quickly.

So let's keep in mind, as we work on our projects, how important is to have good software architecture and sustainable design patterns, not just for ourselves but for the team and future team members.

### Discussion:
What steps do you take to ensure that your codebase is easy to understand, maintain and scale for new team members? How do you approach onboarding in your team?
What's your current tech stack for web development?
Tags: discuss, webdev, javascript, productivity
Published: 2023-01-14 19:34:12

A tech stack in web development refers to the combination of technologies and programming languages used to create and maintain an excellent web application. A full-stack web app can be made using many different tech stacks. The specific technologies and languages used in a tech-stack depends entirely on the project and the goals of the developer or development team. So, what's your current tech stack? It can have frameworks like React or Svelte, databases, ORMs, CSS frameworks, tools, plugins, extensions, and anything you use in the development process.

My current tech stack is [T3 stack](https://create.t3.gg/), which might sound a bit new to some people:

- **Next.js** - Fullstack framework
- **Typescirpt** - Doesn't need any explanation🤣
- **tRPC** - A way to write fully typesafe APIs. GraphQL Killer😈
- **Prisma** - ORM
- **Tailwind CSS** - For styling
- **NextAuth.js** - For authentication

This tack focuses primarly on implementing full-stack TypeScript applications. Typescript isn't optional here😓. This stack can be used both for front-end and back-end.

Write about your tech-stack in the comments below, looking forward to reading them!
GraphQL basics and how it differs from REST
Tags: graphql, rest, node, webdev
Published: 2023-01-14 19:26:54

GraphQL is a query language for your API that was developed by Facebook in 2012. It allows the client to define the structure of the data it needs, and the server will return only the requested data. In this way, it differs from REST (Representational State Transfer) which is an architectural style for building web services.


![Rest and GraphQL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wt1hoo6ghi7g1szx3x1w.jpeg)

## Advantages

One of the main advantages of GraphQL is its flexibility. With REST, the client must make multiple requests to different endpoints to retrieve all the necessary data, which can lead to over-fetching or under-fetching of data. With GraphQL, the client can specify exactly what data it needs in a single request, and the server will return only that data. This allows for more efficient data retrieval and reduces the amount of data transfer over the network.

Another advantage of GraphQL is its ability to handle complex and nested data. With REST, retrieving nested data requires multiple requests to different endpoints, which can be time-consuming and difficult to manage. With GraphQL, the client can specify exactly what nested data it needs in a single request, and the server will return that data in a single response.

## Real Time Subscription

GraphQL subscriptions allow for real-time updates by enabling the client to subscribe to specific events or changes and receive updates over a WebSocket connection as the data changes. This feature is supported by most of the GraphQL implementations, and can be implemented using a GraphQL client library such as Apollo Client.

## Disadvantages

However, GraphQL does have some disadvantages as well. One of the main disadvantages is that it can be more difficult to cache the data in a GraphQL API compared to a REST API. This is because the structure of the data returned by a GraphQL API can vary depending on the client's request, whereas the structure of the data returned by a REST API is fixed. Additionally, GraphQL does not have as wide of support as REST, and may not be as well suited for certain types of applications.

## Conclusion

In conclusion, GraphQL is a powerful tool for building APIs that is particularly well suited for applications that require flexible, efficient data retrieval and real-time updates. However, it does have some disadvantages and may not be the best choice for every application. It is important to weigh the pros and cons of both GraphQL and REST before deciding which is the best option for your specific use case.
Creating a desktop shortcut for a shell script (Ex:How to add Android Studio to the launcher)
Tags: ubuntu, android, java, tricks
Published: 2023-01-14 18:47:01

You can set desktop icon in your machine of any kind of `.sh` executable file. Here we can use android studio `studio.sh` file to set it as desktop app icon.
When you download android studio from [Android studio official site](https://developer.android.com/studio) and after extract you will get `studio.sh` executable file. And you can run android studio from terminal by 
```bash
./studio.sh
```

![Install android studio](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ss9ykrxwa25oafaepjnx.png)

But who used terminal to run a application, let's set a desktop icon

Create a `studio.desktop` file in desktop location or you can set name as your wish like - `name.desktop`

```bash 
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec= sh /path/to/studio.sh #path to your studio.sh file mine is /usr/local/android-studio/bin/studio.sh
Icon=/usr/local/android-studio/bin/studio.png #path to your application icon 
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-android-studio
Name[en_GB]=android-studio.desktop
```
Paste that piece of code into `studio.desktop` file 

Save it...

Then go to your desktop, and you will see the icon of your application. But you will see an error something like launch your application. So you have to give permission to launch that application. Right-click your mouse on that icon, and you will get an option

Voila... now we can run our script as a desktop icon 😎
Non-nullable properties in C# 11
Tags: programming, dotnet, csharp, tutorial
Published: 2023-01-14 18:39:38

---
title: Non-nullable properties in C# 11
published: true
date: 2023-01-14 18:26:18 UTC
tags: programming, dotnet, csharp, tutorial
canonical_url: https://zagosk.in/non-nullable-properties-in-c-11
---

After taking a break from blogging, I am excited to be back and try something new. As an experiment, I have decided to focus on writing shorter articles, which hopefully, will allow me to share some of my thoughts, ideas and tips in a more concise and digestible manner. Let's see how it goes. Shall we?

## Problem

First, take a look at this simple code:

```csharp
public record User
{
    public string Name { get; init; }
    public string? Email { get; init; }
}
```

Nothing fancy here, an immutable record with two properties: `Name` and `Email`. At first glance, it may look fine, but the compiler won't like this code:

```
Program.cs(14, 19): [CS8618] Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
```

This means that we created an immutable record with a non-nullable property `Name`, but nothing will stop us from creating a new user and not providing any name at all:

```csharp
var user = new User { Email = "Sam" };
```

## Solution 1: Assign `default!`

(Don't do that) Often, to shut the compiler up, programmers assign default values with an exclamation mark to such properties:

```csharp
public record User
{
    public string Name { get; init; } = default!; // or null! or "" 
    public string? Email { get; init; }
}
```

Here we simply ask the compiler to ignore the issue, while the problem remains: we are still able to create an instance of that record and forget to assign a value to `Name`.

## 💩 Solution 1: Constructor

```csharp
public record User
{
    public string Name { get; }
    public string? Email { get; init; }

    public User(string name, string? email = default)
    {
        Name = name;
        Email = email;
    }
}
```

Very boring and verbose code, which at the end of the day does the job. There is no way a developer can forget to pass a value for `Name`because now it's a mandatory constructor parameter.

## Solution 2: Positional properties

```csharp
public record User(string Name, string? Email = default);
```

In this case whenever we create a new instance of the `User` type, we have to provide a value for the `Name` property. Nice and clean.

## Solution 3: `required` modifier

The new keyword `required` was introduced in C# 11, which can be applied to properties of classes, records and structs. You can find all details as well as information about existing limitations [here](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/required).

```csharp
public record User
{
    public required string Name { get; init; }
    public string? Email { get; init; }
}
```

Problem solved.

I hope it helps and thank you for reading!

Cheers!
455. Assign Cookies
Tags: java, leetcode, 100daysofcode, algorithms
Published: 2023-01-14 18:21:07

**Problem Statement:**

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.

Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.

 

**Example 1:**

**Input:** g = [1,2,3], s = [1,1]
**Output:** 1
**Explanation:** You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3. 
And even though you have 2 cookies, since their size is both 1, you could only make the child whose greed factor is 1 content.
You need to output 1.

**Example 2:**

**Input:** g = [1,2], s = [1,2,3]
**Output:** 2
**Explanation:** You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2. 
You have 3 cookies and their sizes are big enough to gratify all of the children, 
You need to output 2.
 

Constraints:

- 1 <= g.length <= 3 * 104
- 0 <= s.length <= 3 * 104
- 1 <= g[i], s[j] <= 231 - 1

**Solution:**

**Algorithm:**
1. Sort the array of children's greed factor and cookies' size.
2. Assign the cookie to the child with the least greed factor.
3. If the cookie's size is less than the child's greed factor, then move to the next child.
4. If the cookie's size is greater than or equal to the child's greed factor, then move to the next child and increment the number of satisfied children.
5. If the cookie's size is less than the child's greed factor, then move to the next cookie.
6. If the cookie's size is greater than or equal to the child's greed factor, then move to the next child and increment the number of satisfied children.
7. Repeat steps 4-6 until all the children are satisfied or all the cookies are used.
8. Return the number of satisfied children.

**Code:**
```
class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int numberOfChildren = g.length;
        int numberOfCookies = s.length;
        int cookie = 0, answer = 0;
        for (int i = 0; i < numberOfChildren && cookie < numberOfCookies;) {
            if (s[cookie] >= g[i]) {
                i++;
                answer++;
            }
            cookie++;
        }
        return answer;

    }
}
```

**Time Complexity:**
O(NlogN) where N is the number of children or the number of cookies.

**Space Complexity:**
O(1)
Deploy Docker Containers on Amazon ECS
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-01-14 18:19:58

[14/100] #100DaysOfCloud Today, I created a Docker-enabled sample application on an Amazon ECS cluster behind a load balancer and tested the sample application.

<u>Amazon Elastic Container Service (Amazon ECS) :</u>
Amazon Elastic Container Service (Amazon ECS) is a highly scalable and fast container management service. You can use it to run, stop, and manage containers on a cluster. With Amazon ECS, your containers are defined in a task definition that you use to run an individual task or task within a service. In this context, a service is a configuration that you can use to run and maintain a specified number of tasks simultaneously in a cluster. You can run your tasks and services on a serverless infrastructure that's managed by AWS Fargate. Alternatively, for more control over your infrastructure, you can run your tasks and services on a cluster of Amazon EC2 instances that you manage.

<u>Use cases :</u>
- Deploy in a hybrid environment
 - Build container-based applications on-premises or in the cloud with Amazon ECS Anywhere and enjoy consistent tooling, management, workload scheduling, and monitoring across environments.

- Support batch processing
 - Plan, schedule, and execute batch computing workloads across the full range of AWS services, including Amazon Elastic Compute Cloud (EC2), Fargate, and Amazon EC2 Spot Instances.

- Scale web applications
 - Automatically scale and run web applications in multiple Availability Zones with the performance, scale, reliability, and availability of AWS.

You can try to create a Docker-enabled sample application on an Amazon ECS cluster behind a load balancer and test the sample application by yourself by following the steps from the link below :
[GitHub](https://github.com/aaditunni/100DaysOfCloud/tree/main/Journey/014)
Is ChatGPT testing the users?
Tags: chatgpt, ia, watercooler, discuss
Published: 2023-01-14 18:11:27

---
title: Is ChatGPT testing the users?
published: true
description: chatgpt answers incorrectly on purpose, why?
tags: chatgpt,ia,watercooler, discussion
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nyx5wfd3qv4bgftrqe2z.jpeg
canonical_url: https://alvaromontoro.com/blog/68022/is-chatgpt-testing-its-users
---

<p>Why does ChatGPT sometimes give clearly wrong answers? I get it can provide incorrect code or <em>get confused</em> with the natural language in a problem, but today it told me that the square root of 8 is 2 (just 2, no decimals). It's impossible that an AI (or any machine) <em>thinks</em> that's the correct answer.</p>

<p>It was a simple question, too: "<em>what is the square root of the cube of 2?</em>" And it explained the logic correctly. It just gave a wrong result: 2<sup>3</sup>=8, &Sqrt;(8)=2.</p>

<figure>
<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtt9hdlyhg22me17vfad.png" alt="Question to ChatGPT: 'What is the square root of the cube of 2'. And an elaborate answer by the AI explaining that it is 2 (8 is the cube of 2, and 2 is the square root of 8)" />
<figcaption>That is definitely wrong.<br/>&nbsp;</figcaption>
</figure>

<p>After I asked to recalculate the result as it might be incorrect, ChatGPT provided the correct answer &mdash;with what looked like some "snarky" comment about how the previous one was wrong, and the right calculations this time: 2<sup>3</sup>=8, &#8730;(8)=2.828...</p>

<figure>
<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4m8v3bq1pbdtlqc8ueze.jpg" alt="Conversation with ChatGPT. Following the previous question, the user states that the answer may be wrong and to run the calculation again. ChatGPT apologizes for any confusion, and states that the previous answer is wrong. It does the calculations again, this time with the correct values and result." />
<figcaption>Super-verbose answer, addressing the previous error more than running the calculation<br/>&nbsp;</figcaption>
</figure>


<p>So I guess <b>ChatGPT is coded to provide wrong answers on purpose</b>. But why? Is the system programmed to "test" the user? Is it some A/B testing? What and why?</p>

<p>It could be to get publicity online (people like me sharing about incorrect results and how <em>unintelligent</em> this Artificial Intelligence thing is). It's plausible, but I doubt it's just that &mdash;it would be bad publicity, too, but as they say, "<em>Bad publicity is better than no publicity.</em>"</p>

<p>There has to be more to it. What am I missing?</p>
JavaScript
Published: 2023-01-14 17:34:08

Started a JavaScript course on Coursera.

Hopefully, this course will be what will set me on the right course to fully understand arrays, objects, and DOM in JavaScript and use it to build some apps.
I will also test my knowledge with a code challenge 

I wish that within 6 months' time, I will get a job so that I can be to get that real company working environment.
#discuss
Published: 2023-01-14 16:54:04

 Hello, aside from tweaking a CSS file here and there, I have next to no experience with coding. I'm majoring (for an MS) in environmental science and am now taking my first Python class. The trouble is, I need some inspiration as we seem to be learning just how to create and modify simple lists (the kinds of lists I might make in a spreadsheet program). How do I see the bigger picture and relate Python to the bigger picture of applying it to things like energy research? I'm trying to get excited here, but I'm struggling. THANKS CODERS!
Do you know this toolchain ?
Published: 2023-01-14 17:24:16

The React team largely suggests the following fixes:

1. Use Create React App if you're studying React or developing a new single-page app. ()

2. If you're using Node.js to create a server-rendered website, give Next.js a try.

3. Try Gatsby if you're creating a website focused on static content.

4. Try More Flexible Toolchains if you're creating a component library or interacting with an existing codebase. (https://reactjs.org/docs/create-a-new-react-app.html#more-flexible-toolchains)