teleren/devto huggingface dataset:
Build a CRUD Rest API in JavaScript using Nodejs in 5 min
Published: 2023-02-15 06:24:00

First, we'll need to set up our project and install the necessary packages. We'll be using Express, a popular [Nodejs framework](https://www.nileshblog.tech/leetcode-solving-snakes-and-ladders-with-bfs-algorithm/) for building web applications, and Mongoose, a package for interacting with MongoDB databases.

Create a new directory for your project and navigate into it:

`mkdir my-api
cd my-api
`

Initialize a new Nodejs project with NPM:


`npm init`
Install Express and Mongoose:

`npm install express mongoose`
Now we're ready to start building our API!

Create a new file called server.js and add the following code:
javascript

`const express = require('express');
const mongoose = require('mongoose');
const app = express();
const port = 3000;
// Connect to MongoDB
mongoose.connect('mongodb://localhost/my-api', { useNewUrlParser: true, useUnifiedTopology: true })
  .then(() => {
    console.log('Connected to MongoDB');
  })
  .catch((error) => {
    console.error(error);
  });
const schema = new mongoose.Schema({
  name: String,
  age: Number,
});
// Create a model from the schema
const User = mongoose.model('User', schema);
// Set up routes for our API
app.get('/users', async (req, res) => {
  const users = await User.find();
  res.send(users);
});
app.post('/users', async (req, res) => {
  const user = new User(req.body);
  await user.save();
  res.send(user);
});
app.put('/users/:id', async (req, res) => {
  const { id } = req.params;
  const user = await User.findByIdAndUpdate(id, req.body, { new: true });
  res.send(user);
});
app.delete('/users/:id', async (req, res) => {
  const { id } = req.params;
  await User.findByIdAndDelete(id);
  res.sendStatus(204);
});
// Start the server
app.listen(port, () => {
  console.log(`Server started on port ${port}`);
});``
Let's go through this code step by step:

- We import the necessary packages, set up our Express app, and define a port to listen on.
- We connect to our MongoDB database using the Mongoose package. Replace the mongodb://localhost/my-api URL with the URL of your own database if you're using a different one.

If you are looking for a great tech blog that offers insightful content on the latest technology trends and gadgets, be sure to check out [CLICK HERE](http://nileshblog.tech/). With its in-depth articles and helpful tips, this blog is a valuable resource for anyone interested in staying up-to-date on the latest advancements in the tech world. And if you're looking to boost your own website's visibility, be sure to include a do-follow
Get notified when there are commits to pull in IntelliJ
Tags: programming, java, tutorial, webdev
Published: 2023-02-15 06:17:35

With the help of GitLive’s new pull reminders, you can now pull sooner, reduce the chances of conflicts, and merge faster!

Get notified the moment your remote has been updated and there are commits to pull from your tracking branch. 


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

We'll even notify you on falling behind your base branch (the branch you plan to merge your changes back into once you're done), we figure out your base branch by checking the git reflog to see which branch you originally branched off when you created your current branch. 


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

It's not always possible to tell where you branched from in the local reflog, in these cases we'll assume it was your default branch if possible, otherwise, we'll just ask you to pick one. In any case, you can easily change the base branch by clicking *Change base* on the notification.



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

You can also select *No base branch* to suppress notifications for your root branch (typically your main/trunk branch). Once the relationship between your branches is correctly set, you'll be notified when you are behind any branch in the chain of bases up to your root branch.

<sup>
  💡 <b>Example:</b> If you follow a <i>GitFlow</i> style branching strategy with main and develop branches, and your current feature branch was branched off develop, you'll not only be notified if your branch is behind develop but also if develop is behind main.
</sup>

Finally, you can click *Show changes* on the notification to open the **repository view** where you can inspect the changes in the branches you are behind.


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

The repository view also shows all the remote feature branches ahead, in terms of commits, of your current branch, check out this article to learn more:

{% embed https://dev.to/gitlive/see-how-others-changes-compare-to-your-own-in-intellij-48ig %}


***

Don't have the GitLive extension installed yet? You can find it [here](https://plugins.jetbrains.com/plugin/11955-gitlive), and if you want to learn more about the latest release, check out [this blog post](https://blog.git.live/GitLive-16.1-get-notified-when-you-fall-behind-the-remote-and-more-new-features).
লারাভেল কাস্টম মিডিলওয়ার তৈরী
Tags: laravel, vue, api
Published: 2023-02-15 06:12:14

আমাদের অনেক প্রয়োজনে [লারাভেলে](https://laravel.com/) কাস্টম মিডিলওয়ার তৈরি করার দরকার পরে। আমরা চাইলে কোনো থার্ডপার্টি প্লাগিন ব্যবহার না করে সহজেই একটি লারাভেল মিডিলওয়ার তৈরী করে নিতে পারি। তাহলে চলুন দেখা যাক।

প্রথমে নিচের আর্টিসান কমান্ডটি দিয়ে একটি মিডিলওয়ার তৈরী করে নেই।

```
php artisan make:middleware CheckRole
```

এই কমান্ডটি চালানোর পর আমাদের একটি নতুন ক্লাস তৈরী হবে app/Http/Middleware এই ফোল্ডারে। এখন ফাইলটি ওপেন করি।

```
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class CheckRole
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request, Closure $next)
    {
        return $next($request);
    }
}

```

আমাদের চেক করা প্রয়োজন যে কোনো ইউজারের কোনো একটি কাজ করার অনুমতি আছে কিনা। তাহলে লারাভেল কোডটি হবে নিচের মতো।


```


<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class CheckRole
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request, Closure $next)
    {
        if(Auth::user()->role == 'customer'){

            return redirect(route('customerDashboard'));
        }
        else{
            return redirect(route('adminDashboard'));
        }

        return $next($request);
    }
}

```
এখন সহজেই যেকোনো রোল দিয়ে চেক করা যাবে যে ইউজার ওই রোল এ আছে কিনা।আমরা আমাদের মিডিলওয়ার রেজিস্টার করে নেই। রেজিস্টার করার জন্য app/Http/Kernel.php এই ফাইলটি ওপেন করুন এবং নিচের মতো আমাদের মিডিলওয়ার টি এড করে দেই।

```


// Within App\Http\Kernel Class...

protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
    'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
    'can' => \Illuminate\Auth\Middleware\Authorize::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'CheckRole' => \App\Http\Middleware\CheckRole::class,
];

```


এখন আমরা কন্ট্রোলারে যাই এবং নিচের লাইন যোগ করি।

`
//At our Controller

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('CheckRole');
    }
`


ধন্যবাদ।
First Things First!
Published: 2023-02-15 06:03:04

I will start writing about my learning journey as a software developer, where I will talk about the hard and soft skills I learn, and this is my first post. Since it will include technical concepts, I wanted to share some articles about technical writing, and I hope you find them useful!

- [A Starting Point for writing Technical Blog Posts](https://dev.to/elizabethschafer/a-starting-point-for-writing-technical-blog-posts-n2o)

- [Technical Writing Process: How to write a Good Technical Article](https://dev.to/the_greatbonnie/technical-writing-process-how-to-write-a-good-technical-article-j67)

- [A brief Introduction to Technical Writing](https://dev.to/radiomorillo/a-brief-introduction-to-technical-writing-53bh)

#### Stay Hungry; Stay Foolish!
Understanding useEffect with useState easily
Tags: reactnative, react, tutorial, beginners
Published: 2023-02-15 05:55:47

I have often been asked how to create a placeholder effect whilst the data is being fetched.

When you add a placeholder to the content, the user gets a feeling that the data is 'almost' loaded now.

I am writing this blog for my students to follow up incase they need a ready reference to check.

You need to 2 things. **useState** and **useEffect**

**useEffect** is a _function_ that is used to manage side effects in your components. Side effects are things that your component needs to do that are **not related to rendering** content on the screen, such as fetching data from an API.

The best way to use useEffect() is in combination of useState().

Let me get down to the code to explain better. Check this out:

```react
import React, { useState, useEffect } from 'react';
import { Text, View } from 'react-native';

function MyComponent() {
  const [data, setData] = useState(false);

  useEffect(() => {
    fetch('https://example.com/api/getdata')
      .then(response => response.json())
      .then(data => setData(data));
  }, []);

  return (
    <View>
      {data ? <Text>{data}</Text> : <Text>Loading...</Text>}
    </View>
  );
}

```

Now following this...

under `View` I have added a ternary operator to check if the `data` is true or false. By default it is false, thus the user will see `loading...`

When the useEffect reaches the second then, that is, processed json, it will set state of the `data` with the data from the API. This making it false-positive, or a True.

Alternatively, we can also create another state which changes and uses absolute _True_ and _False_

To do that, check the code below:

```react
import React, { useState, useEffect } from 'react';
import { Text, View } from 'react-native';

function MyComponent() {
  const [data, setData] = useState(null);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    fetch('https://example.com/api/getdata')
      .then(response => response.json())
      .then(data => {
        setData(data);
        setLoading(false);
      });
  }, []);

  return (
    <View>
      {loading ? (
        <Text>Loading...</Text>
      ) : (
        <Text>{data}</Text>
      )}
    </View>
  );
}

```
This puts `loading` as a boolean with either a true or a false, instead of false and true-y.

Hope this helps.

If you have more questions, you know where to reach me!

Be good. Get Good. Have fun!
How to Create Users, Manage Them and Assign Roles in Jenkins | Jenkins Tutorial for Beginners.
Tags: webdev, beginners, programming, tutorial
Published: 2023-02-15 05:33:23

In this video, we will create two users and manage them, assign the roles in Jenkins.

{% embed https://youtu.be/Bz3ArJxQWR8 %}

We will create Dev and Tester role, they will have different access to job.

✅✅ Download Slides + NOTES - https://sdet.live/notes


Plugin Used - https://plugins.jenkins.io/role-strat...


✅✅ Role-based Authorization Strategy
Creating global roles, such as admin, job creator, anonymous, etc., allowing to set Overall, Agent, Job, Run, View and SCM permissions on a global basis.
Creating project roles, allowing to set only Job and Run permissions on a project basis.
Creating agent roles, allowing to set node-related permissions.
Assigning these roles to users and user groups
Extending role and permissions matching via Macro extensions

———————————————————————————

🔗 Join the Facebook Group - http://scrolltest.com/fb

🔗 Learn API Testing(with Postman) - https://learnapitesting.com/

🔗 Rest API Testing with Python - http://masterapitesting.com/

🔗 E2E Frontend Testing with Cypress - http://cypresstutorial.com/

🔗 Join Our Automation Newsletter - http://scrolltest.com/tta

🔗 Master API Testing Bundle - https://apitesting.co/bundle

🔗 Rest Assured MasterClass- https://apitesting.co/enroll


———————————————————————————

Who is this for?

✅ Anyone who wants to learn How Jenkins works, basics and more.
✅ Want to run your own projects on Jenkins

✅✅ What is Jenkins?

**Jenkins** – an open source automation server which enables developers around the world to reliably build, test, and deploy their software.

https://www.jenkins.io

https://en.wikipedia.org/wiki/Jenkins...
)

✅ *An open source automation server which enables developers around the world to reliably build, test, and deploy their software*

✅ Why we need to Learn Jenkins?

Jenkins has become an indispensable tool for both Java programmers and DevOps engineers. **Jenkins allows you to set up continuous integration (CI) and continuous deployment (CD) pipeline**, which reduces risk on Software development and delivery

✅ What are the benefits of Jenkins?

- *Runs Automated Test Suites*
- *Run you Web, Mobile Automation SUITE*
- *API Monitoring*
- *Report and Email Notification*
- *Trends and detailed failure that can be shared.*
- *You can use slave to make build and run fast.*

How to install Jenkins on Windows, Mac and Ubuntu

1. Go the [https://www.jenkins.io/
](https://www.jenkins.io/)download

2. Install the file or follow steps
3. Install the default plugins
4. Navigate to localhost:8080

✅ *Do I need to know coding to learn Jenkins?* 

No, OPnly in some cases you need to learn Groovy

#jenkins #jenkinstutorial #jenkinsinstall
String Methods (python)
Published: 2023-02-15 05:25:20

## String Methods

- **Slicing**

With slicing we can access substrings. It can get optional start and stop indices.

```{python}
a='pythonfullstack'
a= a[3:9]
# 'honful'
```
- **strip()**

strip() method makes the string Return a copy of the string with the leading and trailing characters removed. default characters of this method removes whitespace

```{python}
a= '      python    '
a= a.strip()
#'python'
```
- **replace()**
Return a copy of the string with all occurrences of substring old replaced by new.

```{python}
a= ' hi folks'
a= a.replace('hi','hello')
# ' hello folks'
```
- **split()**
split() methods uses for returning the list of words in a string, using sep as the delimiter string

```{python}
a= ' hi folks good morning'
a= a.split()
# ['hi', 'folks', 'good' ,'morning']
```

- **join()** 
Return a string which is the concatenation of the strings in iterable.

```{python}
a=['hi', 'folks', 'good' ,'morning']
a= ' '.join(a)
# 'hi folks good morning'
```
- **upper(), lower(), capitalize()**
Return a copy of the string with all the cased characters converted to uppercase, lowercase, or first character capitalized and the rest lowercased.
```{python}
a= 'python'
a= a.upper()
#'PYTHON'
a='pyThOn'
a= a.lower()
# 'python'
a= 'pyTHoN'
a=a.capitalize()
# 'Python'
```

- **isalpha(), isnumeric(), isalnum()**

isalpha() is to check a string whether it contains alphabets only.

isnumeric() is to check a string whether it contains numbers only.

isalnum() is to check a string whether it contains alphabets or  numbers.

```{python}
s= 'justchill'
s.isalpha() #output : True
s='9887'
s.isnumeric() # output: True
s='30jno'
s.isalnum() #output: True
```
- **count()**
count() method is used to count the particular substrings in a string.
```{python}
s='hello'
s.count('l') # 2
```
- **find()**
Return the lowest index in the string where substring sub is found within the slice s[start:end]
```{python}
s= 'run python'
ind= s.find('y') # 5

```
- **swapcase()**

Return a copy of the string with uppercase characters converted to lowercase and vice versa.

```{python}
s= 'HeLLo'
s=s.swapcase()
# 'hEllO'

```
Navigate Your Way Through Web Development
Tags: webdev, javascript, programming, tutorial
Published: 2023-02-15 05:21:36

_The Power of JavaScript’s Navigator Object_


---

> "Have you ever gone on a treasure hunt? Sometimes, you need a map to find your treasure. A navigator in JavaScript is like a map for your computer. It helps your computer find things on the internet, like websites and pictures. It’s like a guide that shows your computer where to go!”

---


## What the hell is a navigator?

The navigator object is a built-in object in JavaScript that provides information about the user’s web browser and operating system. This object is available in all modern web browsers, including Google Chrome, Mozilla Firefox, and Microsoft Edge.

Some of the most common properties and methods of the navigator object include:

- **userAgent**: This property returns a string that contains information about the user’s web browser, such as its name and version.

```
console.log(navigator.userAgent);
```

- **platform**: This property returns a string that describes the user’s operating system, such as Windows or macOS.

```
console.log(navigator.platform);
```

- **cookieEnabled**: This property returns a Boolean value indicating whether or not the user’s web browser is set up to accept cookies.

```
console.log("Cookies enabled: " + navigator.cookieEnabled);
```

- **geolocation**: This property provides access to the user’s current location, if the user has granted permission to access their geolocation.

```
navigator.geolocation.getCurrentPosition(function(position) {
  console.log("Latitude: " + position.coords.latitude);
  console.log("Longitude: " + position.coords.longitude);
});
```

- **language**: This property returns a string that specifies the user’s preferred language for web content.

```
// languages: gives all of the supported languages (list)
// language: give the current set language
console.table({ languages: navigator.languages, language: navigator.language})
```

 **screen**: This will display the dimensions of the user’s screen, in pixels.

```
console.log("Screen resolution: " + screen.width + "x" + screen.height);
```

## Conclusion

The Navigator interface represents the state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities.A `Navigator` object can be retrieved using the read-only `window.navigator` property.

The most common uses are in service workers & to check if the internet connection is available or not.

P.S: check out {% embed https://developer.mozilla.org/en-US/docs/Web/API/Navigator %} 

(SUPRISE!!)
Mengurus keuangan bisnis dengan bantuan aplikasi modern
Tags: magangsrdkomatik2023, projectidea
Published: 2023-02-15 05:04:30

Pada era ini banyak sekali para pemuda – pemudi yang ingin menerjunkan dirinya dalam suatu bidang yaitu dengan cara memiliki bisnisnya sendiri. Perkembangan bisnis pada saat ini sangatlah melejit, ini terjadi dikarenakan adanya dukungan kemajuan teknologi yang ada. Tapi untuk memulai bisnis tidaklah mudah dan membutuhkan banyak perhatian dan pengorbanan terutama masalah keuangan.

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

Tanpa adanya penyusunan keuangan yang baik dalam suatu perusahaan bisnis maka dapat terjadinya kerugian dalam perusahaan tersebut dan pada akhirnya dapat menyebabkan kebangkrutan bagi usaha tersebut. Penyusunan keunganan dapat dilakukan dengan berbagai metode seperti dengan pembukuan atau yang lebih canggihnya dapat menggunakan sebuah software pendataan yaitu Excel, akan tetapi dengan cara ini data tidak terjamin akan selalu aman maka dibutuhkan sebuah solusi yang lebih modern untuk mencegah adanya kehilangan data – data yang telah dikumpulkan.

Dengan masalah ini maka kita dapat membuat solusi berupa adanya aplikasi yang dapat membantu para pengusaha muda untuk menyusun keuangan bisnis mereka. Dengan aplikasi tersebut pengusaha dapat melakukan pendataan terhadap pemasukkan dan pengularan yang dilakukan oleh usaha atau bisnis-nya tersebut. Aplikasi ini juga akan selalu men-tracking apakah bisnis yang pengguna miliki dalam keadaan merugi atau untung pada setiap bulannya dengan data – data yang telah dimasukkan oleh pengguna. Adapun keunggulan aplikasi ini adalah dengan adanya penggunaan database online dalam aplikasi ini maka pengguna tidak perlu ketakutan apabila datanya akan hilang karena masalah – masalah yang biasa ditimbulkan dengan cara lama. Dengan adanya penggunaan database juga  para pengguna dapat mengakses data yang telah dimasukkan ke dalam aplikasi kapanpun dan dimanapun pengguna inginkan.
Top nhà cái uy tín - Nhà cái uy tín hàng đầu Châu Á
Published: 2023-02-15 05:00:16

https://nhacaiuytin.bet/ Top nhà cái uy tín - Là trang web chuyên đánh giá các nhà cái ✔️ bóng đá✔️ lô đề✔️ xổ số... tại thị trường Việt Nam và trên thế giới hiện nay ✔️✔️✔️
Tai Seng Bavet SEZ on 161km of NH1, Ta Pov Village, Bavet City, Svay Rieng, Campuchia
https://heylink.me/nhacaiuytinbet/
http://www.bloggang.com/mainblog.php?id=nhacaiuytinbet
https://boosty.to/nhacaiuytinbet
https://velog.io/@nhacaiuytinbet
https://pbase.com/nhacaiuytindotbet/nhacaiuytinbet