teleren/devto huggingface dataset:
All MongoDb Database commands (MongoDb Cheatsheet)
Tags: mongodb, beginners, programming, tutorial
Published: 2022-03-26 07:22:52

In this post, we will see a comprehensive list of all the MongoDB commands you will ever need as a MongoDB beginner. This list covers almost all the most used commands in MongoDB.


# Database Commands

- View all databases
```
show dbs
```
- Create a new or switch databases 
```
show dbs
```
- View current Database
```
db
```
- Delete Database 
```
db.dropDatabase()
```
These are the basic Database Commands of MongoDb.

I will assume that you are working inside a collection(tables in sql) named 'comments' on a MongoDB database of your choice

# Collection Commands
- Show Collections
```
show collections
```
- Create a collection named 'comments'
```
db.createCollection('comments')
```
- 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: 'yash'})
```
- Insert One Row
```
db.comments.insert({
    'name': 'yash',
    'lang': 'JavaScript',
    'meme': 1
 })
```
- Insert many Rows
```
db.comments.insertMany([{
    'name': 'yash',
    'lang': 'JavaScript',
    'meme': 1
    }, 
    {'name': 'Rohan',
    'lang': 'Python',
    'meme': 3
    },
    {'name': 'jagu',
    'lang': 'Java',
    'meme': 4
}])
```
- Search in a MongoDb Database
```
db.comments.find({lang:'Python'})
```
- Limit the number of rows in output
```
db.comments.find().limit(2)
```
- Count the number of rows in the output
```
db.comments.find().count()
```
- Update a row
```
db.comments.update({name: 'Teja'},
{'name': 'yash',
    'lang': 'JavaScript',
    'meme': 1
}, {upsert: true})
```
- Mongodb Increment Operator
```
db.comments.update({name: 'Rohan'},
{$inc:{
    meme: 2
}})
```
- Mongodb Rename Operator
```
db.comments.update({name: 'Rohan'},
{$rename:{
    meme: 'member'
}})
```
- Delete Row
```
db.comments.remove({name: 'yash'})
```
- Less than
```
db.comments.find({member_since: {$lt: 90}})
```
- Less than equals to
```
db.comments.find({member_since: {$lte: 90}})
```
- Greater than
```
db.comments.find({member_since: {$gt: 90}})
```
- Greater than equals to
```
db.comments.find({member_since: {$gte: 90}})
```

These are all basic MongoDb commands
Search in Rotated Sorted Array - Python
Tags: leetcode, dsa, python, saipavan
Published: 2022-03-26 07:18:42

There is an integer array nums sorted in ascending order (with distinct values).

Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].

Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

You must write an algorithm with O(log n) runtime complexity.

 https://leetcode.com/problems/search-in-rotated-sorted-array/

Example 1:

Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4
Example 2:

Input: nums = [4,5,6,7,0,1,2], target = 3
Output: -1
Example 3:

Input: nums = [1], target = 0
Output: -1
 

Constraints:

1 <= nums.length <= 5000
-104 <= nums[i] <= 104
All values of nums are unique.
nums is an ascending array that is possibly rotated.
-104 <= target <= 104


```
class Solution:
    def search(self, nums: List[int], target: int) -> int:
        #TC=O(log n)
        s=0
        e=len(nums)-1
        while s<=e:
            mid=(s+e)//2
            if nums[mid]==target:
                return mid
           #left-line
            if nums[s]<=nums[mid]:
                if target>=nums[s] and target<=nums[mid]:
                    e=mid-1
                else:
                    s=mid+1
            else:
                if target>=nums[mid] and target<=nums[e]:
                    s=mid+1
                else:
                    e=mid-1
        return -1     
```
MongoDb Row commands
Tags: mongodb, beginners, programming, tutorial
Published: 2022-03-26 07:14:47

In this post, we will see a comprehensive list of all the MongoDB Row commands you will ever need as a MongoDB beginner.
#  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: 'yash'})
```
- Insert One Row
```
db.comments.insert({
    'name': 'yash',
    'lang': 'JavaScript',
    'meme': 1
 })
```
- Insert many Rows
```
db.comments.insertMany([{
    'name': 'yash',
    'lang': 'JavaScript',
    'meme': 1
    }, 
    {'name': 'Rohan',
    'lang': 'Python',
    'meme': 3
    },
    {'name': 'jagu',
    'lang': 'Java',
    'meme': 4
}])
```
- Search in a MongoDb Database
```
db.comments.find({lang:'Python'})
```
- Limit the number of rows in output
```
db.comments.find().limit(2)
```
- Count the number of rows in the output
```
db.comments.find().count()
```
- Update a row
```
db.comments.update({name: 'Teja'},
{'name': 'yash',
    'lang': 'JavaScript',
    'meme': 1
}, {upsert: true})
```
- Mongodb Increment Operator
```
db.comments.update({name: 'Rohan'},
{$inc:{
    meme: 2
}})
```
- Mongodb Rename Operator
```
db.comments.update({name: 'Rohan'},
{$rename:{
    meme: 'member'
}})
```
- Delete Row
```
db.comments.remove({name: 'yash'})
```
- Less than
```
db.comments.find({member_since: {$lt: 90}})
```
- Less than equals to
```
db.comments.find({member_since: {$lte: 90}})
```
- Greater than
```
db.comments.find({member_since: {$gt: 90}})
```
- Greater than equals to
```
db.comments.find({member_since: {$gte: 90}})
```
# [clickhere to see MongoDb commands](https://dev.to/yaswanthteja/all-mongodb-database-commands-mongodb-cheatsheet-146k)
Facebook clone using HTML and CSS
Tags: html, css, fullstack, mern
Published: 2022-03-26 07:08:46

As part of switching back my career to Tech, as a beginner I have created a facebook home page clone using HTML and CSS only
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yg6x50g0oekx423e1n1.jpg).
🇫🇷 Techniques de prise de notes pour devs 📝
Tags: french, dev, productivity, notetaking
Published: 2022-03-26 07:07:41

Comment prendre de bonnes notes  en tant que développeurs 💪

{% youtube uUiyLscVLdg %}


Pour aller plus loin, je t’ai concocter une vidéo plus longue 👉 https://m.youtube.com/watch?v=EAQRbaqgdV8 🤗



——-

🙂 GitHub https://github.com/pH-7

🏁 Mon cours Udemy sur la création d'une application PHP 8.1 depuis zéro 👉 https://www.udemy.com/course/create-real-world-php-webapp-from-scratch/
Vue 3 lifecycle hooks with real-time example
Tags: vue, vue3, lifecycle
Published: 2022-03-26 07:05:28

Vue.js is providing lifecycle hooks to manage/manipulate a component's state at specific time. It's a basic building block of vue.js, as developers need it at each and every stage of implementing vue.js app.

Have you ever been through the lifecycle hooks in detail? 

If no then learn vue lifecycle hook in-depth with a comparison to "Bobs morning routine" at Vue.js lifecycle hooks with real-time example.

You can read full article here [ https://blog.canopas.com/vue-3-lifecycle-hooks-with-real-time-example-1b772b89e085]( https://blog.canopas.com/vue-3-lifecycle-hooks-with-real-time-example-1b772b89e085)
SPO600 Project - Candidate Selection
Tags: spo600, stage1
Published: 2022-03-26 07:02:42

Hi this is Tecca, this post is meant to be an update on progress of me finding a candidate package for the SPO600 project stage 1.

# Stages of the project 
## Stage 1: Selection
- Searching and selecting candidate packages to optimize, pick an approach to optimize the current code in the package.
## Stage 2: Implementation
- Implementing the approach of optimizations mentioned in Stage 1, and testing the program to ensure that it uses the SVE2 instructions without crashing the program.
## Stage 3: Upstreaming
- submitting changes into the upstream codebase

# What I need
I need to be able to find a package that is open-source and use SIMD(Single Input, Multiple Data) implementation at the library-level, and making sure they don't already have SVE or SVE2 optimizations already implemented.
Lesson 03 | Conditionals
Published: 2022-03-26 06:58:33

## Types of Conditionals
A conditional in C can be written using `if`, `else-if`, `else`, `ternary operators`, and `switch` statements.

## if Statements
An `if` statement tests an expression and executes code based on its truth.

```c
if (x == 3) {
  printf("x is 3!");
}
```
## else-if Statements
An `else-if` statement tests an expression and must come after an existing `if` or `else-if`.
```c
if (x > 3) {
  printf("x is greater than 3");
} else if (x < 3) {
  printf("x is less than 3");
}
```
## else Statements
An `else` statement is accessed when all preceding `if` and/or `else-if` statements return false.
```c
if (x > 3) {
  printf("x is greater than 3");
} else if (x < 3) {
  printf("x is less than 3");
} else {
  printf("x equals 3");
}
```
## Dangling else Statement
A dangling `else` statement results when it’s ambiguous which conditional the `else` statement is attached to.

## Ternary Operators
A ternary operator is a condensed `if-else` statement.

```c
min = a < b ? a : b; // This is the same as the if-else below

if (a < b) {
  min = a;
} else {
  min = b;
}
```

## switch Statements
A `switch` statement is a condensed series of cascading `else` statements. It tests a value and compares it against multiple cases.

```c
switch (grade) {
  case 9:
    printf("Freshman\n");
    break;
  case 10:
    printf("Sophomore\n");
    break;
  case 11:
    printf("Junior\n");
    break;
  case 12:
    printf("Senior\n");
    break;
  default:
    printf("Invalid\n");
    break;
}
```
## Operators and Conditionals
A conditional in C can use relational operators such as `&&`, `||`, and `!` to compare values and test multiple expressions.
All MongoDb Collection Commands
Tags: mongodb, database, programming, beginners
Published: 2022-03-26 06:51:22

In this post, we will see a comprehensive list of all the MongoDB  Collection (tables in sql) commands you will ever need as a MongoDB beginner.
I will assume that you are working inside a collection named 'comments' on a MongoDB database of your choice

# Collection Commands
- Show Collections
```
show collections
```
- Create a collection named 'comments'
```
db.createCollection('comments')
```
- Drop a collection named 'comments'
```
db.comments.drop()
```

# [clickhere to see MongoDb commands](https://dev.to/yaswanthteja/all-mongodb-database-commands-mongodb-cheatsheet-146k)
All MongoDb Database commands (MongoDb Cheatsheet)
Tags: mongodb, database, beginners, mysql
Published: 2022-03-26 06:42:02

In this post, we will see a comprehensive list of all the MongoDB commands you will ever need as a MongoDB beginner. This list covers almost all the most used commands in MongoDB.
# Database Commands

- View all databases
```
show dbs
```
- Create a new or switch databases 
```
show dbs
```
- View current Database
```
db
```
- Delete Database 
```
db.dropDatabase()
```
These are the basic Database Commands of MongoDb.

# [clickhere to see MongoDb commands](https://dev.to/yaswanthteja/all-mongodb-database-commands-mongodb-cheatsheet-146k)
Find First and Last Position of Element in Sorted Array - Python
Tags: leetcode, python, dsa, saipavan
Published: 2022-03-26 06:30:13

Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

If target is not found in the array, return [-1, -1].

You must write an algorithm with O(log n) runtime complexity.

https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/

Example 1:

Input: nums = [5,7,7,8,8,10], target = 8
Output: [3,4]
Example 2:

Input: nums = [5,7,7,8,8,10], target = 6
Output: [-1,-1]
Example 3:

Input: nums = [], target = 0
Output: [-1,-1]
 

Constraints:

0 <= nums.length <= 105
-109 <= nums[i] <= 109
nums is a non-decreasing array.
-109 <= target <= 109


```
    def searchRange(self, numbers: List[int], target: int) -> List[int]:
        result=[-1,-1]
        l=0
        h=len(numbers)-1
        while l<=h:
            mid=(l+h)//2
            if target>numbers[mid]:
                l=mid+1
            elif target<numbers[mid]:
                h=mid-1
            else:
                result[0]=mid
                h=mid-1
        l=0
        h=len(numbers)-1
        while l<=h:
            mid=(l+h)//2
            if target>numbers[mid]:
                l=mid+1
            elif target<numbers[mid]:
                h=mid-1
            else:
                result[1]=mid
                l=mid+1
        return result   
        
    
```
How to set the HTML lang attribute in Next.js?
Tags: nextjs, react, javascript, webdev
Published: 2022-03-26 06:06:23

## What is HTML lang Attribute?

The HTML lang attribute is used to identify the language of the content on the web and, when you've got an international audience say for example Spanish and English, it helps search engines return language-specific results for Spanish or English screen readers to provide correct pronunciation.

## the lang attribute in Next.js

Here's what `lang` attribute looks like in HTML,

```html
<html lang="en">
  <!-- Head and Body -->
</html>

```

You can't just simply set the `lang` attribute by changing the `HTML` tag in Next.js.

To set the `lang` attribute to the `HTML` tag in Next.js. We have to add the `i18n` object in the `next.config.js`.

Here's how it must be done,

```javascript
module.exports = {
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
  reactStrictMode: true,
}
```

Let's understand the properties of the `i18n`i n above snippet,

- **locale**: It is the array of the `locales` values that you want to add support to the website. For example, you can set the value to `es` for the Spanish language.

```javascript
locales: ["es"]
```

- **defaultLocale**: It defines the default locale to be used on different pages.

After updating `next.config.js`, restart the server. Your final source code will have the `lang="en"` attribute in `html` tag.

```html
<html lang="en"></html>
```

Check out the full list of [Language codes](https://www.w3schools.com/tags/ref_language_codes.asp)

## Conclusion

We hope you enjoyed our article on how to set the lang attribute. Thank you for reading!

We all have used dummy text at some point or another as developers - for example, "Lorem Ipsum". Recently, I've launched **[Let's Lorem Ipsum](https://letsloremipsum.vercel.app/)**, an easy-to-use service that enables you to copy and paste useful dummy content into projects where required - like annoying form fields!

Let’s Lorem Ipsum - [https://letsloremipsum.vercel.app/](https://letsloremipsum.vercel.app/)

### Let’s connect

- [Twitter](https://twitter.com/codewithsnowbit)
- [GitHub](https://github.com/codewithsnowbit)

If you found my content helpful and would like to thank me for my time, feel free to Buy me a coffee - [https://www.buymeacoffee.com/codewithsnowbit](https://www.buymeacoffee.com/codewithsnowbit).
Send Notification on Expo ReactNative App from Laravel | PHP
Tags: laravel, php, reactnative, expo
Published: 2022-03-26 05:56:02

```
     public function notifyApp($app_id){
        $payload = array(
            'to' => $app_id,
            'sound' => 'default',
            'body' => "New Task Assigned"
        );

        $curl = curl_init();

        curl_setopt_array($curl, array(
        CURLOPT_URL => "https://exp.host/--/api/v2/push/send",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => json_encode($payload),
        CURLOPT_HTTPHEADER => array(
            "Accept: application/json",
            "Accept-Encoding: gzip, deflate",
            "Content-Type: application/json",
            "cache-control: no-cache",
            "host: exp.host"
        ),
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err) {
        echo "cURL Error #:" . $err;
        } else {
        echo $response;
        }
    }
```
Absolute import in create-react-app
Tags: react, javascript, jsconfig, absolute
Published: 2022-03-26 05:31:21

**Want to get rid of the annoying, long, boring import statements in react?**

```
import {Card} from './../../components/Card';
```

**Just create a `jsconfig.json` file in your projects root directory and the following code**

```
{
    "compilerOptions": { "baseUrl": "src" },
    "include": ["src"]
}  
```
**Yaa it is that much simple to do now you can go into your file and replace the previous code with**

```
import {Card} from 'components/Card';
```

> Make sure you restart the server after creating the `jsconfig.json` file

---


- Now do you want create `jsconfig.json` file all of your projects in more efficient way? 

- Then Open up your project root directory in the terminal and run

```
npx react-jsconfig
```

> It will automatically generate the `jsconfig.json` file for you

[Learn More About react-jsconfig](https://github.com/AshirbadGudu/react-jsconfig)
React To-Do App With LocalStorage API!
Published: 2022-03-26 05:07:11

**I Have Started Learning `React.js` From Past Few Months (I Also Have Other Things To Do, So It Took Months!), Now  I Have Created A React To-do App With LocalStorage, I Will Give Tutorial In Coming Blogs, Also Comment Do You Like App?**

**Deployed :-** [https://ttooddoo.netlify.app](https://ttooddoo.netlify.app)

## Image Preview 🖼️
![image](https://cdn.discordapp.com/attachments/937581686592503891/947006102359396392/unknown.png)

## Features 💡

- Works Offline If App Is Loaded Once And Not Refreshed (Not Like PWA)
- Export Feature To Export All Your Todo's (Just Click On Settings Button On Top-Right)
- Syncs Your Browser Theme (This Is A Feature Of Daisy UI)

## Comment Your Suggestions Below! 💬
Implement a Payment Solution Provider
Tags: stripe, payments, commercejs, ecommerce
Published: 2022-03-26 03:55:28

###When do you need to implement a payment system? Which payment solution provider is the best to use? In this blog, I attempt to figure out which payment solution provider to implement onto your app or website, and why. 
![How the heck do I pay?](https://media.giphy.com/media/l0MYDoN32puQXNmx2/giphy.gif)


####When Do We Use a Payment System

I was inspired to write about this topic after meeting with a founder of a start-up I'm really interested in freelancing for. He wanted to convert his websites written in PHP on WordPress natively and he wanted to implement [Stripe](https://stripe.com/) as a payment system. As a practice, I decided I'd try my hand at building an app that gave me an opportunity to practice how to implement the usage of Stripe. I chose to refer to JavaScript Mastery's "ECommerce Web Shop - Build & Deploy an Amazing App | React.js, Commerce.js, Stripe" [video](https://youtu.be/377AQ0y6LPA), which was extremely helpful. It also gave me the chance to try out [Commerce.js](https://commercejs.com/). In addition, it was developed responsively.  

As mentioned above, when do we need to use a payment system in our apps or websites? Usually, we would need to incorporate this essential function of being able to make a payment for an item or service when it's an e-commerce app or website. This functionality allows users to conveniently make a payment for any items or services that they choose to purchase. In some cases, a transaction needs to be made when it involves investing funds or online banking; not necessarily to purchase anything. 

![There are so many ways to pay](https://media.giphy.com/media/10Qc9DdLbcSKuk/giphy.gif)
####Types of Payment Solution Providers 
The most common payment solution provider that has been a catalyst in the scene is PayPal. PayPal used to be so advanced back in the day, but from exprience, they've now fell short with their cyber security and customer service; they seem to side with the seller in most cases, making it difficult to claim for items that were not received or when receiving damaged goods. 

Today, more and more payment solution providers have sprouted making it hard to select which one to use. You could also opt to use multiple payment solutions, so the user can have the liberty to select which one is the most convenient. According to Kilpatrick, S. of [BigCommerce](https://www.bigcommerce.com/blog/ecommerce-payment-processing/#7-examples-of-ecommerce-payment-solutions), the 7 examples of e-commerce payment solutions (besides PayPal) are: 

- Stripe
- Square 
- BlueSnap 
- Amazon Pay 
- Klarna 
- Sezzle  
 
![Thumbs up wallet](https://media.giphy.com/media/NxT7L0g2xY2waymXxB/giphy.gif)
####Conclusion
To summarize, whichever payment solution you end up using on your app or website really depends on what you and your users' needs are. Therefore, there really isn't a wrong choice.
Telescope v2.9.0
Tags: opensource
Published: 2022-03-26 03:31:08

This week is the time for releasing Telescope v2.9.0 with many new features coming up. I personally have not added any new codes for this release, but I learn the new codes from teammates by reviewing the PRs.

### What I have done?

While reviewing the PRs, I honestly always run to a wall because I might not know what the PR is about, and there are also some new codes that I have never seen before. I usually head to the related issues or PRs that are mentioned, then trying to know the background of the code. Even though it takes some times, but it works for myself during the review time. I was suggested to ask the assignee about the codes, or testing it and reporting what I have done.

Francesco has moved the front-end from `src/web` to `src/web/app` and I was struggling when pulling the new codes from Master branch. I don't know why I have 47 uncommitted changes in `src/web` when I get the new codes from Master. I thought it was because I did not `pnpm install` when I get the new codes, however, it still didn't work and 47 changes were still there. I was told to remove the `src/web` then restoring it again, everything was fine after all. 

I also reviewed some PRs about configuring ESLint for the project. And I could see that `supertest` was the most confused part for the PRs that I reviewed. Because some of the projects used the `supertest` for their tests, but some of them were not. So when reviewing ESLint PRs, I have to go back to the `*.test.js` file to see if `supertest` is used.

When reviewing [PR #3309](https://github.com/Seneca-CDOT/telescope/pull/3309), at first I think `localhost` and `localhost:80` are different, however, when I test it locally, I try to access to both of them, and it return the same answer -> both are the same. When running Docusaurus by `pnpm start`, it will run the development side of the Docusaurus. But in this PR, I just know that we are generating the static site for this, and then putting it under **nginx** to serve our static content.

### Final thoughts

Each has its own perks. I am learning the codes by reviewing it if am not writing the new one. Review is still important as writing code because we can see our own mistakes when writing the code, and see how others will do when approaching to the same problem that we might have mistakes. I realize that my coding skills are still not good enough in my opinion, because I don't have any optimal ways when coding. And review others' PRs is one of the solutions that I will be looking for my answer.