teleren/devto huggingface dataset:
How to update a record and delete that same record before update (nest js & mongoDB)
Tags: nestjs, node, mongodb, javascript
Published: 2022-10-19 06:22:14

I want to update a record by its id but before update, i want to delete the previously stored data on that same record.What would be the process?

controller.ts

       public updateVendorServiceSpecialPrice = async (req: Request, res: Response, next: NextFunction): Promise<Response | void> => {
        try {
            if (req.body.vendorServiceId!='') {
                let results = await this.ServicesService.updateVendorServicesSpecialPrice(req.params.vendorServiceId, req.body);
                if (results != false) {
                    this.success(res, 'Updated Successfully', 200, results._id);
                }
            } 
            return await this.error(res, 'Something Went Wrong!.', 500);
        } catch (e) {
            next(e)
        }
    }


service.ts


        public async updateVendorServicesSpecialPrice(
        vendorServiceId: any,
        data: any
    ): Promise<any | Error> {
        try {
            return new Promise((resolve, reject) => {
                vendorServiceSpecialPriceSchema.findByIdAndUpdate(
                    vendorServiceId,
                    { ...data },
                    (err: any, success: any) => {
                        if (err) {
                            reject(err);
                        }
                        if (!success) {
                            resolve(false);
                        } else {
                            resolve(success);
                        }
                    }
                );
            });
        } catch (e) {
            console.log('service error\n', e);
            throw e;
        }
    }

I am trying in this way to solve this,may be I am wrong,what would br the right process:
     
        public async updateVendorServicesSpecialPrice(
        vendorServiceId: any,
        data: any
    ): Promise<any | Error> {
        try {
            return new Promise((resolve, reject) => {
                vendorServiceSpecialPriceSchema.deleteOne({vendorServiceId})
                vendorServiceSpecialPriceSchema.findOneAndUpdate(
                    vendorServiceId,
                    { ...data },
                    { returnNewDocument: true },
                    (err: any, success: any) => {
                        if (err) {
                            reject(err);
                        }
                        if (!success) {
                            resolve(false);
                        } else {
                            resolve(success);
                        }
                    }
                );
            });
        } catch (e) {
            console.log('service error\n', e);
            throw e;
        }
    }


Thanks for your time....
Why I Only Have 2 Items On My To do List Every Day
Published: 2022-10-19 06:15:55

It is a lie. Now I have about four items on my to-do list every day. But when I started my bootstrapped startup Proxies API, I only had two things on my to-do list for months.

a) Make the product better every day

b) Write every day

The reason for this is:

a) I believe a startup, in the beginning, is nothing but the sum of the founder’s habits.

b) Habits are the dependable assets of the startup.

c) Even if the startup fails, I take home these habits, so they can’t hurt in the next startup or job.

So for months, this is all I did. I refused to even explain in the to-do list what I was going to write. It didn’t matter what I wrote. I just wrote today, that’s a more significant takeaway in the whole scheme of things than what I wrote. It also didn’t matter how good it was. Time will fix that anyway. I focus on not breaking the habit no matter what. That’s the deal with myself.

I am not allowed to read about the latest marketing growth hack on medium or Twitter. Put my head down and show me after 100 days that I have not broken the streak of writing every single day. That's what I need.

It is no surprise that Proxies API went on to be my first successful startup. It is a huge relief. But this secret was never in building a startup, and the secret is making a couple of simple habits.

The author is the founder of Proxies API, a proxy rotation api service.
Will a break from job affect my career?
Tags: help, discuss, computerscience
Published: 2022-10-19 06:06:32

Hello All,

I am currently working as a developer in a small organisation.
I had a burnout few months ago due to over-working, and it is still going on.

I thought a job change will work but now I don't even want to work for sometime.

I was thinking of taking a break from coding, **no job no coding**, but I don't know how long I can survive without a job. Also don't know how will it (gap in resume) affect my further job search.

Please share some suggestions regarding this.

Thanks in advance.
Debian Sistemlerde NFS Sunucusu Oluşturma
Tags: beginners, network, debian, linux
Published: 2022-10-19 05:54:17

   NFS açılımıyla Network File System, dosyalarımızı ağ üzerinden paylaşmamıza olanak sağlayan bir sistemdir. **_NFS_** kullanarak sunucu olan bilgisayarda paylaşılan dizinleri client olan bilgisayarlara **_mount_** edebiliriz. 

   Mount işlemini gerçekleştirmek için en iki makinaya ihtiyacımız var, bunlardan biri NFS server ve diğerleri de sunucuya bağlamak istediğimiz client makinalar olabilir.

# NFS Sunucu Kurulumu

## 1. Sistemin ve paketlerin Güncelliğinin Kontrol Edilmesi (Opsiyonel)
```bash
sudo apt update
```
```bash
sudo apt upgrade
```
   Sırasıyla yukarıdaki komutları çalıştırarak sisteminizin ve içlerindeki paketleri güncelleyebilirsiniz.

## 2. NFS Paketlerinin Yüklenmesi

Aşağıdaki komutu çalıştırıyoruz.
```bahs

sudo apt install nfs-kernel-server

``` 
## 3. Paylaşım Yapmak İstediğimiz Dizini Oluşturuyorz

Eğer paylaşmak istediğiniz dizin zaten sunucunuzda varsa, bu adımı atlayabilirsiniz. Yoksa _**mkdir**_ komutunu kullanarak oluşturabilirsiniz.
```bash
mkdir /Data
```
Dizini oluşturduktan sonra içerisine istediğiniz verileri ekleyebilirsiniz. Şimdilik aşağıdaki komutu kullanarak _deneme.txt_ adındaki dosyayı oluşturabilirsiniz.

```bash
touch /Data/deneme.txt
```

**Nano** editörünü kullanrak _deneme.txt_ dosyasının içeriğini düzenleyebilirsiniz.

```bash
nano deneme.txt
```

## 4. Exports Dosyasını Düzenliyoruz

Exports dosyasında, **NFS** sunucusuna hangi makinanın hangi yetkilerle erişlebileceği konfigrasyonunu yapıyoruz.

```bash
nano /etc/exports
```

dosyanın içeriğini aşağıdaki gibi kendinize göre düzenleyebilirsiniz.
```
/<Paylaşılacak Klasör Adı>   <Paylaşılacak IP veya aralığı> (<Yetkiler ve özellikler>)
```

Örnek gösterecek olursak

```
/Data   192.168.2.100(rw,sync)
```

Ayrıca aşağıdaki gibi IP aralığına da paylaşabilirsiniz

```
/Data 192.168.2.0/24(rw,sync)
```

Yukarıda Parantez içerisinde belirttiğimiz **rw**, belirtilen ip veya ip aralığındaki client makinaların dosya üzerinde **read** ve **write** işlemlerini yapabileceklerini belirtiyor.

## 5. NFS Server Servisini Yeniden Başlatıyoruz

```bash

systemctl restart nfs-server

```

## 6. NFS Servisini Bilgisyar Açıldığında Açılacak Şekilde Ayarlıyoruz

```bash

systemctl enable nfs-server
```
Lowest Common Ancestor of a Binary Search Tree
Tags: javascript, leetcode
Published: 2022-10-19 05:38:41

Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.

According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

 

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


Example 1:
Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
Output: 6
Explanation: The LCA of nodes 2 and 8 is 6.

Example 2:
Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4
Output: 2
Explanation: The LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.


```js
/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */

/**
 * @param {TreeNode} root
 * @param {TreeNode} p
 * @param {TreeNode} q
 * @return {TreeNode}
 */
var lowestCommonAncestor = function (root, p, q) {
  if (root === null) {
    return null;
  }

  if (root.val > q.val && root.val > p.val) {
    return lowestCommonAncestor(root.left, p, q);
  }
  if (root.val < q.val && root.val < p.val) {
    return lowestCommonAncestor(root.right, p, q);
  }

  return root;
};


```
The Best Tips For Hiring Top Interior Designers in Jaipur
Published: 2022-10-19 05:35:50

Rupankan Archo Interiors professional home interior designer will assist you to choose the colors that are suitable for the winter season. Darker and warmer shades are perfect for chilling winter nights and cold days. Choose warm and inviting colors such as beige, golden, and burgundy shades, as well as shades of brown, red, and dark green as well as orange for curtains, mattress sheets cushioning, and pillows. The wallpapers and wallcover shades of these colors will add to the warmth of the room.
 
Finding an interior designer to hire in Jaipur isn't an easy task. It's similar to getting married, but unless finding the right person, you can't marry. Therefore, you must locate the right person and it is difficult to know who is the best just by taking a look at his face. There isn't an app yet to locate the perfect interior by simply moving either left or right across your phone's screen. It is therefore a manual task that should be done by you alone. Here are some guidelines or more specific questions that you must ask when choosing an interior designer.
 
**Check Your Budget**
Budgeting before you hire an interior design professional is the best method to begin your project. We choose the most appropriate contractor for your budget. Also, the quality of the furniture is dependent on your budget. If you have a small budget, fixing it earlier is a good idea since some designers in Jaipur don't take on jobs with a low budget.

**Designers' fee**
It's probably the most crucial thing you consider before making a decision to hire an [Interior Designer for Home in Jaipur](https://www.rupankanarchointeriors.com/interior-and-exterior-designer-in-jaipur.php). If you hire an interior designer whose price is way beyond your expectations and you are not sure what to do, it could be an issue for you. Be aware of one thing even if you have an exquisite home, however, the beauty of your home will increase in proportion to the money you spend. Employing an interior designer whose cost is cheap may not be suitable for you too. That doesn't mean you can't hire the person, but before making a decision, you should look into whether they offer after-install assistance or if they are reliable or not. It doesn't mean you must hire an artist with a large price, but you should select someone whose cost is within your budget and whose work is of high quality.
 
**Which Kind of Style do You Prefer**
The idea that we are experts in the field of home design is absurd. Every interior designer has a specialization in a certain area. It is enough to determine what kind of style you are looking for and then choose the one that can offer exactly the interior design you want in Jaipur. Gather the portfolios of designers, and then carefully before you make a choice. It's a matter of your home. To avoid any regrets, be sure to check the details and the offers.
Weekly web development resources #120
Tags: webdev, weekly
Published: 2022-10-19 05:32:36



______

##[Randoma11y](https://randoma11y.com/)
[![Randoma11y](https://wweb.dev/weekly/content/120/randoma11y.jpg)](https://randoma11y.com/)
A cool website that generates and shows random, accessible color combinations.

______

##[Day.js](https://day.js.org/)
[![Day.js](https://wweb.dev/weekly/content/120/dayjs.jpg)](https://day.js.org/)
A fast 2kB alternative to Moment.js with the same modern API

______

##[Agreper](https://github.com/Demindiro/agreper)
[![Agreper](https://wweb.dev/weekly/content/120/agreper.jpg)](https://github.com/Demindiro/agreper)
A minimal forum software that works without JavaScript. 

______

##[Can I DevTools?](https://www.canidev.tools/)
[![Can I DevTools?](https://wweb.dev/weekly/content/120/devtools.jpg)](https://www.canidev.tools/)
A website that curates commands browser devtools for different browsers.

______

##[tailwindcss-highlights](https://tailwindcss-highlights.hubatsch.dev/)
[![tailwindcss-highlights](https://wweb.dev/weekly/content/120/tailwind-highlights.jpg)](https://tailwindcss-highlights.hubatsch.dev/)
A plugin for Tailwind CSS to add highlights to your text.

______

##[Metlo](https://github.com/metlo-labs/metlo)
[![Metlo](https://wweb.dev/weekly/content/120/metlo.jpg)](https://github.com/metlo-labs/metlo)
A modern open-source API security platform. 

______

##[Magic Eraser](https://www.magiceraser.io/)
[![Magic Eraser](https://wweb.dev/weekly/content/120/magiceraser.jpg)](https://www.magiceraser.io/)
A tool to easily remove unwanted things from images.

______

##[Prefixed API Key](https://github.com/seamapi/prefixed-api-key)
[![Prefixed API Key](https://wweb.dev/weekly/content/120/prefixed.jpg)](https://github.com/seamapi/prefixed-api-key)
A module for generating a prefixed API key for better key handling.

______

##[Planby](https://planby.netlify.app/)
[![Planby](https://wweb.dev/weekly/content/120/planby.jpg)](https://planby.netlify.app/)
A React based component that lets you implement your own timeline.

______

##[miniparallax](https://github.com/minimax711/miniparallax)
[![miniparallax](https://wweb.dev/weekly/content/120/parallax.jpg)](https://github.com/minimax711/miniparallax)
A lightweight & powerful parallax script for your next project.

______

##[Loading Disco](https://joebell.co.uk/sketches/loading-disco)
[![Loading Disco](https://wweb.dev/weekly/content/120/loadingdisco.jpg)](https://joebell.co.uk/sketches/loading-disco)
An alternative animation to the loading spinner.

______

##[Animate CSS Grid](https://github.com/aholachek/animate-css-grid)
[![Animate CSS Grid](https://wweb.dev/weekly/content/120/animate-grid.jpg)](https://github.com/aholachek/animate-css-grid)
A library to seamlessly animate all CSS grid properties.

______

##[Ultra](https://ultrapkg.dev/)
[![Ultra](https://wweb.dev/weekly/content/120/ultra.jpg)](https://ultrapkg.dev/)
A fast and efficient package manager for JavaScript.

______

To see all the weeklies check: [wweb.dev/weekly](https://wweb.dev/weekly)
Websites Optimization 2021
Tags: performance, storybytes, digital, webandappstudio
Published: 2022-10-19 05:26:06


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


Web performance is all about how fast your website feels to the user. A slow website causes frustration to the user. These feelings can also be called Perceived Performance. According to a recent survey from similar tech, the data shows that this Years number one Priority has been optimising the website performance. Everything that improves the site speed is getting addressed. The Survey in which 200 digital agencies worldwide participated shows that they spent most of the time optimising Images/Video, which significantly impacts page speed. How are you addressing your website performance?
LCA of Binary Tree
Tags: javascript, leetcode
Published: 2022-10-19 05:21:54

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.

According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

 

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

Example 1:
Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
Output: 3
Explanation: The LCA of nodes 5 and 1 is 3.

Example 2:
Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
Output: 5
Explanation: The LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.

Example 3:
Input: root = [1,2], p = 1, q = 2
Output: 1

```js
/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @param {TreeNode} p
 * @param {TreeNode} q
 * @return {TreeNode}
 */
var lowestCommonAncestor = function (root, p, q) {
  if (!root) return null;

  if (root == p || root == q) {
    return root;
  }

  const lac1 = lowestCommonAncestor(root.left, p, q);
  const lca2 = lowestCommonAncestor(root.right, p, q);

  if (lac1 !== null && lca2 !== null) {
    return root;
  }

  if (lac1 !== null) {
    return lac1;
  }

  return lca2;
};

```
Hello, World! In different world...
Published: 2022-10-19 05:21:26

**Python**
print("Hello, World")

**C**
\#include<stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}

**C++**
\#include <iostream>
using namespace std;
int main() {
   cout << "Hello, World!" << endl;
   return 0;
}

**Java**
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

**javascript**
console.log("Hello, World!");

**Ruby**
puts "Hello, World!";

**Go**
package main
import "fmt"

func main() {
    fmt.Println("Hello, World!")
}


**C#**
using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine ("Hello, World!");
    }
}


**R**
"Hello World!"

**Swift**
print("Hello World")


will add more in the collection.
Laravel 8 Get Latest Record From Database
Tags: laravel, laravel8, database, mysql
Published: 2022-10-19 05:19:30

In this article, we will see laravel 8 get the latest records from the database. In PHP, you can use order by clause with descending order to get the last record from the database but in laravel, you can simply get the last record using the laravel 8 eloquent model. Laravel provides the latest() method to get the last record from the database. In the MySQL database get the last record using the ORDER BY clause with desc.

So, let's see how to get the last record in laravel 8 or laravel 8 to get the last record SQL query.

> Get Last Record Using MySQL:

You can get the last records using the below code example.

```
SELECT column_name FROM table_name  
ORDER BY column_name DESC  
LIMIT 1;
```

Example:

```
select * from users ORDER BY id DESC LIMIT 1;
``` 

---

**_[Read Also: How To Generate QR Code In Laravel 8](https://techsolutionstuff.com/post/how-to-generate-qr-code-in-laravel-8)_**

---

> Get Latest Records Using Laravel:

Example 1:

```
$user = DB::table('users')
                ->latest()
                ->first();
```

Example 2 :

```
$user = User::orderBy('id', 'DESC')->first();
```

Example 3:

```
$user = User::get()->latest();
```
Ethics In AI
Tags: machinelearning, ai, storybytes, privacy
Published: 2022-10-19 05:19:22


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3oh6kpxk4fm16fv2fb9.png)
	
AI applications are rapidly improving and the technology has emerged into virtually all aspects of any industry. This is fueled in part by raising awareness of ethical issues in AI, as well as the positive perception of recent data privacy regulations, such as the General Data Protection Regulation (GDPR) in the European Union (EU). As AI is set to radically change the world we live in, it is critical for organizations to address ethics in AI. For us in Web and App Studio, It is important that we create ethical systems and practice them for the use of AI. This is not just a compliance issue, but one that can create a significant benefit in terms of loyalty, endorsement and engagement.
About ReactJS.
Published: 2022-10-19 05:12:21



**Q1. What is React?**
**A1**: React is a JavaScript library for building user interfaces.

**Q2. Why React?**
**A2**: One of the main benefits of using React JS is its potential to reuse components. It saves time for developers as they don't have to write various codes for the same features. Furthermore, if any changes are made in any particular part, it will not affect other parts of the application.

**Q3. What is Virtual Dom?
A3:** A virtual DOM is a lightweight JavaScript object which is a copy of the real DOM. 

**Q4. How does Virtual DOM work?**

- **A4:** This Virtual DOM works in three simple steps-
    - Whenever any underlying data changes, the entire Ul is
    re-rendered in Virtual DOM representation.
    - Then the difference between the previous DOM representation
    and the new one is calculated
    - Once the calculations are done, the real DOM will be updated with only
    the things that have actually changed

**Q5. What is Library?
A5:** A JavaScript library is a library of pre-written JavaScript code that allows for easier development of JavaScript-based applications, especially for **AJAX** and other web-centric technologies.

**Q6. What is AJAX?
A6:** AJAX is a developer's dream because you can: Read data from a web server - after a web page has loaded, Update a web page without reloading the page, and Send data to a web server - in the background. 

AJAX is not a programming language.

AJAX is a technique for accessing web servers from a web page.

AJAX stands for Asynchronous JavaScript And XML.

**Q7. What is Framework?
A7:** A JavaScript framework is a collection of JavaScript code libraries that provide a web developer with pre-written code for routine programming tasks. Frameworks are structures with a particular context and help you create web applications within that context.

It is completely possible to build strong web applications without JavaScript frameworks, but frameworks provide a template that handles common programming patterns. Each time you have to build an application, you don’t need to write code for every single feature from scratch. Instead, you can build upon an existing feature set.
Comparing strings
Published: 2022-10-19 05:05:14

var assert = require('assert');
     const path = require("path");
     const fs = require("fs");
//const  F5 = artifacts.require("F5")
//const ST5= artifacts.require("ST5")

module.exports = async function(callback) {
try {
     //var ctr =0;
     let Str = [];
     Str = "fundame"
     Str2 = []
     for(i=0; i<7;i++){
        ch = Str.charAt(i)
        Str2[i] = ch
        Str2.join("");
        console.log(Str2)
        if(Str2 == "fundame")
           console.log("Found")
        else
           console.log("Not found")
    }
     
}//try
  catch(error) {
    console.log(error)
  }

  callback()
}

[ 'f' ]
Not found
[ 'f', 'u' ]
Not found
[ 'f', 'u', 'n' ]
Not found
[ 'f', 'u', 'n', 'd' ]
Not found
[ 'f', 'u', 'n', 'd', 'a' ]
Not found
[ 'f', 'u', 'n', 'd', 'a', 'm' ]
Not found
[ 'f', 'u', 'n', 'd', 'a', 'm', 'e' ]
Not found