teleren/devto huggingface dataset:
MongoDB Cheatsheet
Tags: mongodb
Published: 2022-11-18 17:10:36

### Connect & Check version :

```bash
mongo
mongosh
mongod
```

### **Database Commands**

View all databases

```
show dbs
```

Create a new or switch databases

```
use dbName
```

View current Database

```
db
```

Delete Database

```
db.dropDatabase()
```

### **Collection Commands**

Show Collections

```
show collections
```

Create a collection named 'comments’

```
db.createCollection('data')
```

Drop a collection named 'comments’

```
db.comments.drop()
```

### **Row(Document) Commands**

Show all Rows in a Collection

```
db.comments.find()
```

Show all Rows in a Collection (Prettified)

```
db.comments.find().pretty()
```

Find the first row matching the object

```
db.comments.findOne({name: 'Manthan'})
```

Insert One Row

```
db.comments.insert({
    'firstName': 'Manthan',
    'lastName': 'Ank'
 })
```

Insert many Rows

```
db.comments.insertMany(
[
	{
		'firstName': 'Manthan',
	  'lastName': 'Ank'
  },
  {
   'firstName': 'Gagan',
   'lastName': 'BA'
  }
])
```

Search in a MongoDB Database

```
db.comments.find({lang:'JavaScript'})
```

Limit the number of rows in output

```
db.comments.find().limit(3)
```

Count the number of rows in the output

```
db.comments.find().count()
```

Update a row

```
db.comments.updateOne(
	{name: 'Manthan'},
	{$set: {
			'name': 'Manthan',
	    'lang': 'JavaScript',
	    'mem_since': 1
		}
	}, 
	{upsert: true}
)
```

MongoDB Increment Operator

```
db.comments.update(
	{name: 'Manthan'},
	{
		$inc:{
	    mem_since: 2
		}
	}
)
```

MongoDB Rename Operator

```
db.comments.update(
	{name: 'Manthan'},
	{
		$rename:{
	    mem_since: 'member'
		}
	}
)
```

Delete Row

```
db.comments.remove({name: 'Manthan'})
```

Less than/Greater than/ Less than or Eq/Greater than or Eq

```
db.comments.find({member_since: {$lt: 90}})

```

```
db.comments.find({member_since: {$lte: 90}})
```

```
db.comments.find({member_since: {$gt: 90}})
```

```bash
db.comments.find({member_since: {$gte: 90}})
```

[Reference Link](https://www.youtube.com/watch?v=oSIv-E60NiU)
Como agregar y usar alias en typescript sin morir en el intento
Tags: webdev, javascript, programming, productivity
Published: 2022-11-18 17:09:32

Usualmente cuando trabajamos en proyectos importaciones que resultan tediosas 😬

```typescript
import { x } from '../../../../path/to/x';

// code ...
```

Para reducir ésto, typescript nos provee `paths` en el archivo de configuración `tsconfig.json`, con el fin de agregar alias que nos ayuden a tener un código más limpio 😎


```typescript
{
  "compilerOptions": {
    // skip
    "paths": {
      "@src/*": ["./src/*"]
    }
  }
}
```

En ésta parte podemos añadir los diferentes directorios con sus respectivos alias, quedando nuestro primer bloque de código mucho más limpio 🙌

```typescript
import { x } from '@src/path/to/x';

// code ...
```

Este es el primer paso para que nuestros alias nos funcione; typescript compilará con éxito debido a que el compilador inteligentemente resuelve las importaciones. Pero al momento de ejecutar nuestro proyecto con node, ts-node, ts-node-dev, etc, el proyecto no se ejecutará y arrojará un error donde indicará que "no encuentra x importación", y ésto ocurre por el método de resolución de módulos de nodejs que solo busca en la carpeta de `node_modules`, por supuesto no encontrará las importaciones propias que hemos especificado en el archivo de configuración `tsconfig`.

Pero ¡no te preocupes! Hay una solución 😎 [tsconfig-paths](https://www.npmjs.com/package/tsconfig-paths), arreglará este problema por nosotros, resolviendo las importaciones que hemos definido en `paths`.

Primero necesitamos instalar el paquete:

```sh
yarn add -D tsconfig-paths
```

Luego, actualizamos el script `package.json`:

```json
{
  "scripts": {
    "dev": "ts-node-dev --respawn --transpile-only -r tsconfig-paths/register index.ts"
  }
}
```

¡Genial! ¡Ya funciona! ✨. Puedes añadir la cantidad de alias que quieras, y todo funcionará debidamente 💪.

Espero que este post haya sido de ayuda.

Puedes ver y seguirme en mi [perfil de github](https://www.github.com/Dave136) 😃

Gracias por leer éste articulo, Happy coding! 💻
How to be successful Instagram🤑🤑
Published: 2022-11-18 16:59:04

Chapter 1: What is Instagram all

about?

What Is Instagram?

We hope you enjoy and get the

most out of this training section.

Instagram is a photo sharing social

network. In practical terms, it is a

visual discovery platform focused

on user generated content and

with predominantly social media

oriented features. Contrary to other social networks, though, Instagram has

been designed from the ground up for mobile devices.

Its humble beginnings can be traced back to 2010, when it was launched as a

free photo sharing app for iOS devices, followed by Android versions as well as a

feature-limited desktop interface two years later.

Much like any other social network, Instagram allows its users to create a profile

from where they can upload and share visual media such as photos and short-

form videos to other users’ feeds. As you can see, the idea behind Instagram is

simple, yet elegant; So much so that Facebook acquired it in 2012 for $1 Billion!

What Can You Find On Instagram?

Instagram is mostly famous

because it allows its users to share

awesome visual content, and

because of that you will be able to

find basically any 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okoiadd4en6iwol88bb5.jpeg)
[[Red more.](url)](url)https://moneymaking4555.blogspot.com/2022/09/how-to-be-successful-instagram.html
DPS909 Blog - Lab 9: Continuous Integration
Tags: opensource
Published: 2022-11-18 16:53:16

This week in my open-source course (DPS909), we were asked to add Continuous Integration (CI) to our [static site generator (SSG)](https://github.com/alexsam29/ssg-cli-tool).

This continues the work we did in [lab 8](https://dev.to/alexsam29/dps909-blog-lab-8-testing-j2a) when we added testing. CI is a method where you can build and run tests automatically whenever anything is pushed to the repo, or a new pull request is made.

## GitHub Actions CI Workflow
To setup CI in my project, I created a GitHub actions workflow. I followed this [guide](https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs) which shows how to build and test a Node.js project using GitHub actions workflows. 

The YAML file I created for testing looked very similar to the example template given in the guide. The only thing I had to change was the operating system the workflow jobs run on. I changed it to run on Windows instead of the default Linux/Ubuntu environment. This was because I originally did my tests on my local Windows machine, so the snapshots taken by my tests use CRLF instead of LF for line endings. So just to avoid any testing errors coming from a windows environment, I changed the workflow job environment to match.

## Adding Tests to Another Repo
PR to another repo: https://github.com/cychu42/staticSiteCon/pull/21
My partner's repo and testing setup was very similar to my own. The main difference was that they used multiple testing files which kept things more organized. In hindsight, I probably should've done the same thing to keep things cleaner.

They pretty much covered all areas of their program with their existing tests. I just added tests to their MD parser that was similar to tests they added for their text parser. I did this just to make sure testing for both parsers are consistent.

## Conclusion
Now that I know how to add CI to my project, I feel like it's a must to add it to any new project I create since it makes testing easier.  You don't have to worry about accidently merging anything that will break the code in `main`.
Deploy Create-React-App on GitHub Page
Tags: react, github, webdev
Published: 2022-11-18 16:42:10

Whenever you finish your react project, the next step is naturally to deploy it: Make the world see your amazing work! There are many services to host your react project, I personally use Vercel and GitHub Page most often. This post will teach you how to deploy in GitHub Page. 

Suppose your app name is "simple-react-app". 

Open a terminal:

**1st, Create react app.** (Skip this step if you already have created the app)
```bash
npx create-react-app simple-react-app
cd simple-react-app
npm start
```
Then, make necessary changes as you want. OK, everything looks good. The app is running locally.

**2nd, Install GiHub page as dev-dependency.**
```
npm install gh-pages --save-dev
```

**3rd, Make modifications to `package.json` file.**
Add homepage `https://{username}.github.io/{app-name}` at top level, add predeploy and deploy in scripts. Here is an example of my json file (since my github username is jzfrank and the app name is assumed to be simple-react-app)

```json
{
  "name": "simple-react-app",
  // ...
  "homepage": "https://jzfrank.github.io/simple-react-app",
  // change jzfrank to your github username
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    // ... 
  },
  // ...
}
```

**4th, Create an empty github repo of name `simple-react-app`.** Now, initialize local repo and set the remote repo as remote
```bash
git init
git remote add origin git@github.com:jzfrank/simple-react-app.git
```

**5th, deploy it to GitHub page**
```bash
npm run deploy
```
You can then visit the repo, go to setting -> GitHub Page to see where it is hosted. (Should be somewhere like "https://{username}.github.io/simple-react-app/"

[Visit my deployment](https://jzfrank.github.io/simple-react-app/)

**6th, optionally, you may want to push this repo to master branch.**
```
git add .
git commit -m "init my simple react app"
git push origin master
```

Final remark (just in case you are deploying a personal website written in react): Naturally you may want to use `https://{username}.github.io` as domain name. In such case, you have to name the app/repo by `{username}.github.io`. Additionally, in 3rd step where you modify the `package.json` file, you don't set `homepage` for it. Why? [See this.](https://stackoverflow.com/questions/71959605/trying-to-deploy-a-react-app-to-a-github-io-page-getting-unexpected-token)

That's it, Cheers!
Wheatcha - MVP release! A catalogue of the best tech videos on YouTube.
Tags: beginners, webdev, tutorial, programming
Published: 2022-11-18 16:42:02

## What's Wheatcha?

Don't know about you guys, but I love watching programming and IT videos on YouTube. So much, that at one point I found myself in some kind of a tutorial hell people keep talking about. I managed to escape it, but I still appreciate how much free content people are producing every day.

But there is one big problem. It's not that easy to find a video about a topic you're interested in. And even if you find a couple, there is no quick way to know how good they are. Especially now that YouTube removed dislikes.

That's why we decided to create [Wheatcha](https://wheatcha.com/). A catalogue of tech related videos, with tags, ratings, reviews, and more. So that you can easily find the best React video of 2020, that is a complete step-by-step tutorial and also TypeScript is used.

And today we released the first MVP version of the platform. Obviously not all the features are there yet, but we were just too curious to see if someone likes the idea.

## Our plans

The roadmap is pretty big. Here are some of the features we're planning to implement next
- Way bigger library.
- Complex search with multiple filters.
- User reviews.
- Design updates.
- And more!

We could also use some help from the community. If you think your favorite youtuber is missing, just let us know in the comments and we will gladly add their videos. Any suggestions regarding functionality, design, tags would also be greatly appreciated. Or feel free to just say hi if you think a platform like this would be useful to you.

See you on [Wheatcha](https://wheatcha.com/)!
How to start programming?
Tags: opensource, video, programming, luos
Published: 2022-11-18 16:22:15

We asked the Luos Team about what advice they would give people that are just starting out with programming. 

⏩ Watch the video to see what they said: https://www.linkedin.com/posts/luos_advice-for-programers-activity-6999404787288961024-6_jz?utm_source=share&utm_medium=member_desktop

If you have any advice or ressources for beginners, feel free to share them with the community in the comments!
Serverless - what should I have thought about?
Tags: aws, serverless, lambda, dynamodb
Published: 2022-11-18 16:01:46

I have been working with serverless for about 2 years now and I really like it and can recommend it!

I can share two steps that I can recommend to you who want to start with serverless. I have mainly been using AWS Services which I will mention in this article.

##So to start with quickly, what is serverless?
Serverless is a cloud-native development model that allows developers to build and run applications without having to manage servers meaning it essentially uses a cloud provider to completely manage your infrastructure.

Some benefits with serverless:

- You only pay for when you use the service
- You're moving away from servers and allowing developers to focus on code
- You can build high scalability and reliability applications without managing servers
- Offloading more responsibility to your cloud provider

Remember, you don't have to use serverless just because. There are cases where serverless might just not be the best solution.

Two stpes I can recommend you to think of when you're using serverless:

##Start by using the AWS Console to play around
Firstly, I recommend you to create an AWS account.

When you have created your AWS account - play around, check the different settings, what happens when you change some setting, what options is available etc.

Let's take [AWS Lambda functions](https://aws.amazon.com/lambda/) for example, play around with it. Check how you invoke a Lambda, create a Lambda with the newly supported arm64 architecture. Figure out how you trace errors.

Next, create an [Amazon DynamoDB](https://aws.amazon.com/dynamodb/?trk=21dcee34-c3e2-40cc-a321-89731e38bb6a&sc_channel=ps&s_kwcid=AL!4422!3!536324000148!e!!g!!dynamodb&ef_id=Cj0KCQiA99ybBhD9ARIsALvZavXv2z7ogw5gvvxXP3wP5Ps64ywYqWBHOTk4h8Gmk8qlkD0qw8ta9EIaAjx_EALw_wcB:G:s&s_kwcid=AL!4422!3!536324000148!e!!g!!dynamodb). Create tables, checkout the Partition key and Sort key. Read about Read capacity unit (RCU) to get a better understanding about the costs. Use the Lambda you have created to add a row to the database.

When you have played around with Console and different services, then you proceed to the next step.

##Start using Infrastructure as Code
After you have played around in the Console, have got a better understanding of the services I can really recommend you to use IaC for all your environments and not handle any changes from the Console.
 
This to understand what’s happening and to see the result of configuration changes. I can basically say, once you know what you are doing IaaC tools are really good and powerful! 

### Frameworks for serverless

- [AWS Serverless Application Model (SAM)
](https://aws.amazon.com/serverless/sam/)
- [Serverless framework](https://www.serverless.com/)
- [Terraform](https://www.terraform.io/)

## Summary
A short summary of how I recommend you to get started with serverless. Don't rush into things, it's better to have a good understanding of the tools and services you are using. Good luck!

Any comments, questions or discussions are always welcome!
What are Java Records?
Tags: java, record, programming
Published: 2022-11-18 16:01:22

Records have been in Java since version 16, but what are they and what can you use them for?

Records can be thought of as a replacement for simple data-holding <abbr title="Plain Old Java Objects">POJOs</abbr>.
These holders usually have one or more of the following properties:

* They are defined solely by the data they hold
* They have an `equals()` and `hashCode()` method based solely on their data
* Their fields are private and final, and they define a getter method for them
* They are written to and read from another format, like JSON or the database

Here is an example of such a POJO:
```java
final class Customer {
    private final UUID id;
    private final String name;

    public Customer(UUID id, String name) {
        this.id = id;
        this.name = name;
    }
    
    public UUID getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "Customer[id=" + id + ", name=" + name + "]";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Customer customer = (Customer) o;
        return id.equals(customer.id) && name.equals(customer.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }
}
```

Now let's see the equivalent record implementation:
```java
record Customer(String id, String name) {}
```

Need we say more? You can now stop reading and start using records everywhere,
or you can continue on to [Part 2: how you use Java Records](https://dev.to/dhoepelman/how-to-use-java-records-5h79-temp-slug-4734467?preview=060ee0ac1287055324ea340c801417d75dafeba1f96f9ff48c9495b6cc77f5ad2cf478c1e91b831828c7222d7c5473507d09c38684af83c1ce860dd0).
Angular: Creating Angular Client Library
Tags: angular, typescript, javascript, webdev
Published: 2022-11-18 15:56:59

Download and install [Node.js] (https://nodejs.org/en/download/) 

⬇

Open `Terminal` or `Command Prompt` and check node version using command `node -v`

⬇

Now, type in `npm install -g @angular/cli` to install CLI

⬇

Check CLI version using `ng --version`

⬇

Create Angular workspace using `ng new <app_name>`

⬇

app_name consider as `libraryApp`

⬇

To create library init, use `ng g library <library_name>`

⬇

`library_name` consider as `myLib`

⬇

Inside the `projects` folder, go to mylib component inside  `myLib` library. 

⬇

Design reusable component in it.

⬇

Now, build that library using `ng build <library_name>`

⬇

Library gets generated in `dist` folder


## Using this library in same application.

Import `myLib` module in `app.module.ts` of application

⬇

Access components or services of `myLib` library inside application and use wherever required in application

⬇

Now, do `ng serve` to check the application


## Using in external application

`ng new externalApp` - Create new external application

⬇

In the `ng build myLib` log, `dist` folder locations are shown

⬇

take `lib` path and do `npm i <path>` inside new external application

⬇

Import `myLib` module in `app.module.ts` of application

⬇

Access components or services of `myLib` library inside application and use wherever required in application

⬇

Now, do `ng serve` to check the application
What is actually .well-known folder?
Tags: webdev, html, javascript, beginners
Published: 2022-11-18 15:52:39

If you built a website, you have already seen .well-known path but I claim that you do not know what it is and why it is there. 🙂

When you setup a website on cpanel or pleks and then access to file system of the website, there is a folder or path that is called .well-known.

We are familiar with the name but most of us don’t care what it is actually.

## What is .well-known folder?
[.well-known folder](https://en.ahmetonursolmaz.com.tr/what-is-meaning-of-well-known-path/) or path name is about giving reference to your website or app from other services. To illustrate, when you visit password manager inside chrome browser for a specific website and click to change password, it redirects you to website’s .well-known/change-password page. If the website that you want to change your password is already handled, you will be automatically redirected to website’s password change page. If not, as a user you will be disappointed.

## How should we handle .well-know/change-password route?
There are actually 2 ways to handle this.

### Redirecting the path to desired page
Assume that we have auth/forget-password page that enables user to change their password on our app. We just need to set our server to redirect requests from .well-known/change-password path to auth/forget-password page.

Redirecting via giving a response with 302, 303 or 307 status code can be accepted.

302 Status Code – Found

303 Status Code – See Other

307 Status Code – Temporary Redirect

### Serving via HTML
You can simply add this meta tag in html file that is located .well-known/change-password path, the route will redirect users to desired page.

`<meta http-equiv="refresh" content="0;url=https://example.com/auth/forget-password">`


The .well-known/change-password practice is accepted by nearly entire web world. You can improve user experience on your web apps so that real users can access password change page properly from redirecting password managers or browsers to your app.

## How do we test .well-known/change password function?
Simply copy and paste this **chrome://settings/passwords/** URL in your chrome browser. And then click to change password button in right-hand side of any saved password. The button will redirect user to website’s password change page. (of course if it is already setup 🙂 )


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

Furthermore, there are lots of [.well-known folder](https://en.ahmetonursolmaz.com.tr/what-is-meaning-of-well-known-path/) practices and you can check them out here as we add step by step.

We list important but not known technical updates here in our [**software world updates page**](https://en.ahmetonursolmaz.com.tr/software-world-updates/). You can follow new improvements and updates in software world.