teleren/devto huggingface dataset:
How to add security to your MongoDB Docker Container
Tags: docker, mongodb, tutorial
Published: 2022-07-20 07:50:54

All databases must be secure to prevent unauthorized access to your data. For [Atlas](https://www.mongodb.com/atlas/database) users, it is very easy to set up security for your database since most of it is automated by Atlas and all you have to do is follow a setup wizard, it gets tricky when you are hosting your own instance of mongo using the power of docker so I'm going to walk you through the steps needed to host a secure MongoDB docker container.

**NB: This guide assumes you have some [docker](https://www.docker.com) knowledge and you have docker setup in your work environment.** 

So first things first we need to have the [MongoDB docker container](https://hub.docker.com/_/mongo) up and running, this can be done with the command 

```bash
docker run -d --name some-mongo \
	-e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
	-e MONGO_INITDB_ROOT_PASSWORD=secret \
	mongo
```

If you look closely here we are creating an instance of the mongo image (container) with the environment variables **MONGO_INITDB_ROOT_USERNAME**, **MONGO_INITDB_ROOT_PASSWORD** Setting these two variables will create a database user, The user will be created in the ***auth*** authentication database and is given the role of ***root*** which is a super user in MongoDB.  Now that the MongoDB image is running with the name **some-mongo** we need to login into the mongo shell and create users for our databases. Run the command below to run bash on the mongo container.

```bash
docker container exec -it some-mongo bash
```

Now the running terminal is bash now we need to run mongo and connect to our secure local database using the command below.

```bash
mongo mongodb://mongoadmin:secret@localhost:27017
```

If everything runs correctly you should be able to see a terminal almost similar to one below depending on your system.

![Mongo Terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/go0ir42v58xw7i2qc72u.png)

Now we are running DB commands as root user we can create database users for ours databases. 

To create a user for the database **customers** you run the following commands

```bash
use customers
db.createUser({
	user: "web-app",
	pwd: "eureka",
	roles: [{role: "readWrite", db: "customers"}]
})
```

After running the above commands the database customers will now be a secure DB with user **web-app.** The database will now be accessible with the connection string **`mongodb://web-app:eureka@<host>:<port>` .** You can now use this connection string in your server configs or even in MongoDB Compass to browse the data.

Yay now you have a secure database on your docker container 🙌👏🙌👏
Why do you need a XML Sitemap for a website?
Tags: xml, sitemap, staticsave
Published: 2022-07-20 07:47:00

If you're responsible for a website, you know there's a lot that goes into keeping it running smoothly. From design to content to navigation, there are many factors to consider. One important element that is often overlooked is the XML sitemap. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kgj69ywn1328yw0t33qq.png)

Here are some reasons why your website needs an XML sitemap:

1.An XML sitemap makes it easier for search engines to index your website.

2.An XML sitemap can help you identify broken links and other errors on your website.

3. An XML sitemap can give you insights into how often your website is being crawled by search engines.

4. An XML sitemap can help you track changes to your website over time.

5. An XML sitemap can help you identify any problems with your website's structure or content.

6. An XML sitemap can give you insights into how people are navigating your website.

7. An XML sitemap can be a valuable tool for marketing your website. 

8. An XML sitemap can help you optimize your website for search engines.

If you have XML code that you want to host online, one option is to use a service like [StaticSave](https://staticsave.com/). This service allows you to paste your XML code and then provides a URL that you can share with others.

One advantage of using StaticSave.com is that it makes your XML code accessible from anywhere in the world. Additionally, hosting your XML code on StaticSave is free and  easy to use.

Also Read: [7 Reasons Why Your Website Needs an XML Sitemap](https://staticsave.com/blog/7-reasons-why-website-needs-xml-sitemap)
🎮 Bringing live data to life with Digital Art & Unity
Tags: showdev, api, datascience, gamedev
Published: 2022-07-20 07:37:27

## ❔ About

As you already know now, we have & share live data through :

- [APIs](https://rapidapi.com/opt-nc-opt-nc-default/api/temps-attente-en-agence)
- [Docker image](https://hub.docker.com/r/optnc/opt-temps-attente-agences-api)

We wanted to create an immersive and Jaw Dropping experience with this live content : 

> _"We wanted to bring our data into life and jump inside it so we could finally be surrounded by our own data"_

👉 We chose to use [Unity Game platform](https://unity.com/) for that.👈

## 🎤 The pitch 

> _"We are using Unity as a platform to visualize our data in a new dimension."_

## 🖼️ The artworks

### 🎱 Create and bring a scene to life

The underlying concept is quite straight forward : 

1. Each **agency is a billiard ball**
2. We get all our agencies **and drop them on a circular pool table** (it creates more interactions)
3. Each ball **continuously updates its own size** (then increasing its mass) according to the **real data by polling the API**

Enjoy the show :

{% youtube R1rNXhQ-UHI %}

### 🎮 Deliver as a video game

Finally we did package the whole experience as a Video game **so we can take a walk withing the artwork** :

{% youtube 2xBAxvcDgGI %}

### 🧪 Experimentations

We also started to develop some other kinds of experiences : 

{% youtube PsTF55byh34 %}

### 💭 To be done

Export as an [Augmented Reality experience](https://unity.com/unity/features/arfoundation) so we can enjoy the show in our world, for example

> _"Display the show on a real table at the office, or put collaborators in their own immersive experience."_


## 🤓 Source code

The code is open sourced so anyone can push experimentations further :

{% github opt-nc/opt-temps-attente-agences-unity %}

## 🔖 Ressources

- [Made with Unity](https://unity.com/madewith)
- [Unity developer and creator advocacy team](https://unity.com/community/advocates)
- [Youtube dedicated playlist](https://youtube.com/playlist?list=PL7GdrgVAWcDgN1QV5tbPRCa1f5Q83yRMi)
The Importance of AWS API Security
Tags: aws, beginners, tutorial, api
Published: 2022-07-20 07:35:15

###Why API security is important 
API security is thus crucial for preventing data breaches and protecting sensitive information. In order to achieve effective API security, organizations need to put in place robust authentication and authorization mechanisms, as well as provide data encryption.
###The potential consequences of poor API security 
If any of these steps are neglected, the consequences can be severe. For example, if data is not properly encrypted, it could be intercepted by an attacker and used for nefarious purposes. Or, if the API is not tested for vulnerabilities, it could be exploited to gain access to sensitive information or systems.
API security is critical to protect data, systems, and even lives. It is important to take all steps necessary to ensure the security of an API, including authentication and authorization, data encryption, and vulnerability testing.
###How to improve AWS API security
####1. Use IAM roles and policies
IAM roles and policies can help you control access to your AWS resources. You can use IAM roles to grant permissions to users or services, and you can use policies to specify what actions a user or service can take on your resources.
####2. Use security groups
Security groups can help you control access to your AWS resources by defining which traffic is allowed to reach them. You can create security groups that allow only certain types of traffic, and you can assign them to your resources.
####3. Use VPCs
Virtual private clouds (VPCs) can help you isolate your AWS resources from the rest of the Internet. By creating a VPC, you can control which traffic is allowed to reach your resources, and you can encrypt your data in transit.
####4. Use multifactor authentication
Multifactor authentication (MFA) adds an extra layer of security to your AWS account. With MFA enabled, you’ll need to provide both your username and password, as well as a code from an MFA device, in order to log in.
####5. Encrypt your data
Encrypting your data can help protect it from being accessed by unauthorized individuals. You can use AWS Key Management Service (KMS) to encrypt your data at rest, and you can use SSL/TLS to encrypt your data in transit.


The moral of the story is: don't skimp on security, especially when it comes to AWS APIs. If you're not careful, you could end up with a nasty bill from Amazon.

Star our [Github repo](https://bit.ly/3QFgAUf) and join the discussion in our [Discord channel](https://bit.ly/3HQtlYo) to help us make BLST even better!
Test your API for free now at [BLST](https://www.blstsecurity.com/?promo=blst&domain=https://dev.to/The_Importance_of_AWS_API_Security)!
This Keyword in Javascript
Tags: javascript, this
Published: 2022-07-20 07:24:57

> In javascript, **this** means immediate parent context.
 

- But when you use this keyword in arrow function, then it does not mean in immediate parent context. It means self context.

**Just see the two code output and think the difference between them **
```javascript
var title = " awesome.";
var statement = {
    name: ' MERN ',
    lang: 'Javascript',
    getDetails: function () {
        name = "normal function";
        return "lets see " + this.name+  " " + name + title;
    },
    getDetails2: () => {
        name = " arrow function";
        return "let us see " + this.name + " " + name + title;
    }

};
```

Run getDetails function:  `console.log(statement.getDetails())`
output: 

```javascript
lets see  MERN  normal function awesome.
```

---


again run getDetails2 function :  `console.log(statement.getDetails2())`
output: 

```javascript
let us see  arrow function  arrow function awesome.
```
_here, output is: **arrow function arrow function** twice. so we understand that our this.name keyword does not mean parent name: ' MERN '._

---

**Advance**
```javascript
var title = " awesome.";
var statement = {
    name: ' MERN ',
    lang: 'Javascript',
    getDetails: function () {
        name = "normal function";
        return "lets see " + this.name+  " " + name + title;
    },
    getDetails2: () => {
        name = " React";
        return {
            name: "Node",
            getDetails3: function() {
                 return "lets see " + this.name+  " " + name + title;
            } 
        };
    }

};
```
again run getDetails3() function :  `statement.getDetails2().getDetails3()`
output: 

```javascript
lets see Node  React awesome.
```

---

**Advance2**
```javascript

```
again run getDetails3() function :  `statement.getDetails2().getDetails3()`
output: 

```javascript

```

---
What are Hooks in React JS
Tags: javascript, webdev, programming, react
Published: 2022-07-20 07:14:34

## What are hooks in React JS 🪝?
Hooks are the new addition in React 16.8. They let you use state and other react features without writing a class.
Using hooks in react class components are no longer needed.

## How to use Hook in react ?
To use any react hook you must import it from `react` library.

There are Three Main Hooks in React JS:
1. useState 🌟
2. useEffect 🌟
3. useContext

## <u>useState Hook</u>
The React useState Hook allows us to track the state in a functional component
State generally refers to data or properties that need to be tracked in an application.

```javascript
import { useState } from 'react';
```

we initialize useState by passing the default value into the function. useState accepts an initial state and returns two values
1. The current state
2. Function to change the state.

```javascript
import { useState } from 'react'

function Fun() {
    const [name, setName] = useState("state hook");
}
```

## useState Example :
{% embed https://codesandbox.io/embed/brave-stallman-iqt1c2?fontsize=14&hidenavigation=1&theme=dark %}

## <u>useEffect Hook</u>
useEffect hook allows you to perform side effects in your functional components.

What does side effects mean? like fetching data from an API, updating DOM, timers etc....

useEffect two parameters in which second one is optional.
`useEffect(<function>,<dependency>);`

If you do not pass second parameter useEffect will run on every render.
If you pass an empty array [] useEffect will run only on first render.
If you pass any prop or state as dependency then useEffect will run on first render and every time when dependency changes.

## useEffect Example
{% embed https://codesandbox.io/embed/nice-heisenberg-wxbuoq?fontsize=14&hidenavigation=1&theme=dark %}
Remote Work Tip!
Tags: beginners, programming, productivity, career
Published: 2022-07-20 06:49:55

Stop asking, **"Can I ask you a question?"**, **"Can we jump on a call?"**
.
And then waiting for a reply. 
.
.
Just share what you need or ask the question you have.
.
Async work isn't hard, just stopping expecting everyone to be on call.
Why do you write?
Tags: watercooler, discuss
Published: 2022-07-20 06:30:02

I see three main reasons why developers should write:

1. **Sharing knowledge**: communicate their ideas and thoughts to a larger audience and help others learn more
2. **Building a personal brand**
3. **Learning**: writing can be a way to structure their thoughts and consolidate their knowledge

However, there are many other ways devs could reach the same objectives.
1. Use videos or teach live lessons
2. Be a speaker, panelist, building in public, contributing to projects etc.
3. Using diagrams, building prototypes, or just reading 

So, why do you write or don't write?
Localbitcoins Clone Script Development
Tags: localbitcoinclonescript, localbitcoinsclonesoftware, bitcoinexchangescript, bitcoinexchangesoftware
Published: 2022-07-20 06:29:34

LocalBitcoins is the leading and most trusted peer-to-peer cryptocurrency exchange platform where cryptocurrency users can buy and sell their digital assets and pay the other party with fiat or any other cryptocurrency. In this guide we will see how to build a crypto exchange like localbitcoins and how a localbitcoins clone works.

Now you can build your own localbitcoins like cryptocurrency exchange website instantly using a white-label localbitcoins clone script. Troniex Technologies offers a cryptocurrency exchange clone script with advanced API and security, as well as payment infrastructure.

**[Continue Reading..](https://troniextechnologies.com/localbitcoins-clone-script)**
What is Rarible Clone Script?
Tags: raribleclonescript, rarileclonesoftware, nft, nftmarketplace
Published: 2022-07-20 06:25:36

Be one of the pioneer NFT marketplace business leader by team up with us to develop your top-notch NFT marketplace platform that is compatible with multiple devices. Troniex technologies develop and deploy [whitelabel Rarible clone script](https://troniextechnologies.com/rarible-clone-script) so you can integrate add-on features and customise the user interface. Our proficient NFT marketplace software developer will together to build customized NFT Marketplace.
Let's Explore React
Published: 2022-06-23 10:01:57

First of all React is one of the best javascript framework. It gives the best-rendering performance, clean code, rich user interface, etc. React build single-page applications. Now lets learn some react topics.

PropTypes: propTypes means in the component we can write what type of props is this. As a data type is a string, number, boolean, or anything we can pass these props types.

What is the difference between State-props:
Props only send the value. It is read-only. can not change the value by props. And we can send anything like hardcoded value, dynamic value, object, function.

State
Props
State can get initial value from parent component
Props also can get initial values from the parent component.
State can not change by parent component
Props can be changed by parent component
State can set default value in the component.
Props also can set default values in components.
State cab change inside the component
Props can not be changed inside component.
State can not be changed in child component
Props can be changed in the child component.

Explain the Component Lifecycle.

=> Lifecycle method happened three ways
Mounting: In mounting, we maintain some order. These are
contractor()
Static getDerivedStateFromPorps()
render()
componentDivMount()

Updating: In updating also maintain some orders. there are
Static getDerivedStateFromPorps()
shouldComponentUpdate()
render()
getSnapshotBeforeUpdate()
componentDivUpdate()

Unmounting: when the component deletes from the DOM. Then it is called
componentWllUnmount()

What is hooks in react? Hooks is create a connection with our application to react. We use some hooks: useState: this hook is used to update any value. if anything changes or needs to update In the application useState hooks can update this. useEffect: by this hook, we can load data or fetch data in UI. it’s also like an impure function.if Loaded data is not loaded from the server it can not be rendered.
There are more hooks like this that are building a connection with code and rendering in UI.

Virtual DOM and diffing- algorithm? Virtual DOM: virtual DOM is most like real DOM.in real DOM we trigger any element by methods like getElementById or getElementByClassName and then change the code. Sometimes if needed to change somewhere then all structures should be changed this was very time-consuming and most difficult. But now VIrtual DOM is made our life easier. In virtual DOM initially set a DOM. when we change code then automatically create a new DOM and compare the previous DOM and then update the DOM.this this is created a Tree which is rendered from the root and his parent is app.js. All component is stored in app.js and finally rendered in UI by root. This tree most looks like real DOM. All processes are happened by diff algorithms. It means when anything changes in code then it is compared with virtual DOM and then they create a Diff algorithm. and then reference change or update in UI.
Segment-Page Feature of openGauss for Solving File Storage Problems
Tags: database, opengauss, opensource
Published: 2022-07-20 06:12:05

In modern society, data is growing explosively, and service requirements in the industry are complex. The amount of data to be stored and the number of tables to be created keep increasing. Each common data table of openGauss corresponds to a logical large file (maximum size: 32 TB). The logical file is divided into multiple actual files based on the fixed size and stored in the corresponding database directory. Therefore, as the data volume of each data table increases, the number of files required for underlying data storage increases gradually. In addition, openGauss provides features such as hash bucket tables and large partitioned tables. Each data table is split into several sub-tables, and the number of files required at the bottom layer increases exponentially.

learn more,Please click the word"[openGauss](https://blog.opengauss.org/en/post/2022/segment-page-feature-of-opengauss-for-solving-file-storage-problems/)"
A study of bugs
Published: 2022-07-20 06:11:34

I changed the name of my blog to “A study of bugs”.

It had been called “my notes”. But that feels quite formal. It suggests there are concrete thoughts presented in them. (Maybe I feel this way because in a zettelkasten system, each note is supposed to be a self-contained bit of thought.)

In programming and debugging, I see bugs and solve them. Each bug is bewildering in its own way. Solving them problems they pose is usually  a haphazard fumbling. 

All I’m saying is I like this new name a lot.
Using Git Hooks To Run your Tests and/or Linter
Tags: git, lint, testing
Published: 2022-07-20 06:07:00

**Original article:** https://www.ethancarlsson.dev/blog/githooks

If you're looking to set up a simple way to run 
code before each commit in a `pre-commit` hook for
a Javascript project, this is how I did it.

## Setup
Hooks don't actually depend on anything other than git, but 
I'm using `vite` and `yarn` in this project.
It would work the same with any build tool, 
and if you use `npm` just replace `yarn [command]` with `npm run [command]`.

For the hook to work you need to write this code in 
`{YOUR_PROJECT_ROOT}/.git/hooks/pre-commit`.
So to get started write one of the following into your 
terminal from your project root:

For vim: `vim .git/hooks/pre-commit`

For nano: `nano .git/hooks/pre-commit`

For VS Code: `code .git/hooks/pre-commit`

Or create and edit the file in whatever other way you like.

## Code

``` bash
#!/bin/bash

yarn lint
linting_result=$?

if [[ $linting_result -ne 0 ]]
then
  echo "LINT FAILED!"
  echo 'Please fix linting problems before committing.'
  exit 1
fi

yarn test
test_result=$?

if [[ $test_result -ne 0 ]]
then
  echo "TESTS FAILED!"
  echo 'Please make sure tests pass before committing.'
  exit 1
fi
```

The `yarn test` and `yarn lint` commands work exactly the same as 
they do when called from the command line at the root of my project.

I get the exit code and check to see if it equals zero here:
```bash
linting_result=$?

if [[ $linting_result -ne 0 ]]
```
if it doesn't equal 0 (`-ne 0`), I echo a message 
and exit the bash code with another non-zero exit code,

```bash
then
  echo "LINT FAILED!"
  echo 'Please fix linting problems before committing.'
  exit 1
fi
```
If either the tests or the linter fail they exit 
with a code of 1. But if it exits with a different code
I'd like to know why, so I exit with anything non-zero and don't
let the commit go forward.

## Next steps
All you need to do now is run `chmod +x .git/hooks/pre-commit`, to make the code executable, 
and the code will run on every commit. 

Check out the [documentation](https://git-scm.com/docs/githooks) and add 
whatever other hooks you like. I run the same code on push as well using 
the `pre-push` hook for example
Top Websites to find free transparent Arrow PNG images
Tags: free, png, image, arrow
Published: 2022-07-20 06:00:30



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e5lr5gr6krrnkqz08lff.png)
Free [arrow PNG](https://toppng.com/collection/arrow) image resources are becoming more popular among designers nowadays. The reason for their immense popularity is, they are easy to access, designed by creative individuals with keeping quality in mind, and most importantly they are a big time saver. But finding the right website with the right graphics for your project is sometimes gets really frustrating. So, we made this list for graphics creators to easily find free transparent PNG images on the web.
1791. Leetcode Solution in Java
Tags: java
Published: 2022-07-20 05:21:21

```
class Solution {
    public int findCenter(int[][] edges) {
        int n = edges.length + 1;
        int[] connections = new int[n + 1];
        for (int[] edge : edges) {
            int node1 = edge[0], node2 = edge[1];
            connections[node1]++;
            connections[node2]++;
            if (connections[node1] > 1)
                return node1;
            else if (connections[node2] > 1)
                return node2;
        }
        return 0;
    }
}
```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/find-center-of-star-graph/
2042. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-20 05:20:04

```
class Solution {
 public:
  bool areNumbersAscending(string s) {
    int prev = 0;
    istringstream iss(s);

    for (string token; iss >> token;)
      if (isdigit(token[0])) {
        const int num = stoi(token);
        if (num <= prev)
          return false;
        prev = num;
      }

    return true;
  }
};

```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence/