teleren/devto huggingface dataset:
How to Create a Docker MySQL Container and Link it with a Spring Boot Application
Tags: spring, mysql, docker
Published: 2023-03-23 10:23:37

## Step 1: Create a Docker Network

Create a Docker network to allow the containers to communicate with each other. You can create a network using the following command:

```
docker network create --subnet=172.18.0.0/16 mynetwork
```
This command creates a Docker network named "mynetwork" with a subnet of 172.18.0.0/16.

## Step 2: Create a MySQL Container

Create a MySQL container using the following command:

```
docker run -d --name mysql-db --ip 172.18.0.2 --network mynetwork -e MYSQL_ROOT_PASSWORD=root mysql:latest
```
This command creates a MySQL container named "mysql-db" with an IP address of 172.18.0.2 and attaches it to the "mynetwork" network. It also sets the root password for the MySQL server.

## Step 3: Create a Spring Boot Application

Create a Spring Boot application using your preferred IDE or text editor. You can use the Spring Initializr to generate a new Spring Boot project with the necessary dependencies.

## Step 4: Configure Spring Boot Application

In your Spring Boot application, add the following configuration to your application.properties file:

```
spring.datasource.url=jdbc:mysql://mysql-db:3306/testdb
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
```

The above configuration sets the database URL, username, password, and driver class name for the MySQL server.

## Step 5: Build and Run the Spring Boot Application

Build your Spring Boot application using Maven or Gradle. Then, run the application using the following command:

```

docker run -p 8080:8080 --name spring-app --network mynetwork <image-name>
```
This command runs your Spring Boot application in a Docker container named "spring-app" and maps port 8080 of the container to port 8080 of the host machine.

Note that you will need to replace <image-name> with the name of the Docker image you built for your Spring Boot application.

```

Step 6: Test the Application
```

Open your web browser and navigate to http://localhost:8080. If everything is configured correctly, you should see your Spring Boot application running and connected to the MySQL container.
What is Android - Services
Tags: android
Published: 2023-03-23 10:22:47

In Android, a Service is a component that runs in the background to perform long-running operations without interacting with the user interface. A Service can be used to perform tasks that do not require user interaction, such as downloading data from the internet, playing music, or recording location data. For more details, You can even check in-depth and Upskill yourself Android - Services concepts from [Android development course](https://www.edureka.co/android-development-certification-course).

**There are two types of services in Android:**

**Started Services:** A started service is one that is started by an application component (such as an activity) and runs in the background until it completes its task or is stopped by the application component that started it. Started services are useful for performing one-time operations that do not require on going interaction with the user.

**Bound Services:** A bound service is one that allows other application components to bind to it and interact with it. A bound service can be used to perform long-running operations that require ongoing communication between the service and the application component. Bound services are useful for implementing features such as music players, where the service provides ongoing playback and the application component (such as an activity) provides the user interface.

Services are an important component of Android development, as they allow applications to perform long-running operations without interfering with the user experience. By using services, developers can create more efficient and responsive applications that provide a better user experience.
I Created An Open-Source Portfolio Website Template For Developers Called WowFolio 🦄
Tags: webdev, beginners, javascript, programming
Published: 2023-03-23 10:15:00

![WowFolio - Open Source Portfolio Template Demo GIF](https://i.postimg.cc/jq4vz736/68747470733a2f2f692e706f7374696d672e63632f774d68747a6677372f657a6769662d636f6d2d6769662d6d616b65722d.gif)

---

## WowFolio 🦄 - A Simple & Clean Portfolio Template For Developers 👨‍💻

---

Exciting news, everyone! 🎉

I'm thrilled to share my latest open-source project called [Wowfolio](https://github.com/rammcodes/wowfolio) with you all. Wowfolio is a clean and simple portfolio website template designed specifically for developers. It's available for free on GitHub, and I encourage you to check it out and give it a try. 💻💡

Wowfolio also comes with a colour picker feature, which allows you to test the template with different colours and pick your own theme colour while building your own portfolio website. 🎨 This means you can customize your site to match your personal brand and style. 🔥

In addition to being easy to use and customize, Wowfolio is also inspired by my previous project, [Dopefolio](https://github.com/rammcodes/dopefolio) which was launched in 2021 and is now being used by developers globally. 🌎 I'm honored that Dopefolio has been such a success, and I'm excited to see how Wowfolio will be received. 🚀

So if you're a developer looking for a simple and customizable portfolio website template, be sure to check out Wowfolio on GitHub. And please feel free to share your feedback and ideas – I'd love to hear from you! 😊👍

Checkout WowFolio **[here](https:///github.com/rammcodes/wowfolio)**

Don't forget to drop a Star ⭐ on Github 🔥

Hope this helps ✅

---

𝗙𝗼𝗹𝗹𝗼𝘄 me on **[Linkedin](https://Linkedin.com/in/rammcodes)** for more:
Tips 💡+ Guides📜 + Resources ⚡ + Quizzes 🎲 related to Programming and Web Development 👨‍💻

[![Ram Maheshwari (@rammcodes) Linkedin](https://i.postimg.cc/NfnLKNtK/www-linkedin-com-in-rammcodes-2.png)](https://linkedin.com/in/rammcodes)

---

Do **Follow** me here on dev.to ✅⬇️
How ElasticSearch Works in Magento 2
Tags: webdev, magento, magento2tutorials
Published: 2023-03-23 10:06:02

Search is a fundamental component for any online business site, as it assists clients with finding the items they're searching for rapidly and without any problem. 

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

While Magento 2, a famous web based business stage, has its own underlying hunt usefulness, it very well may be upgraded by incorporating a strong web index like Elasticsearch. Elasticsearch is an open-source web crawler that is known for its quick presentation and high level hunt highlights.

In this blog, we will talk about How Elasticsearch works in Magento 2  and how it can further develop the quest insight for clients on your site.

For more info, visit https://webguru.dev/how-elasticsearch-works-in-magento-2/
How to Deploy Magento 2 on Server
Tags: webdev, magento, magento2tutorials
Published: 2023-03-23 10:02:50

Sending an online business stage like Magento 2 on a server can be a difficult undertaking, particularly for organizations of any size. To guarantee a smooth and viable site activity, understanding the sending system is fundamental.

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

This guide gives an extensive prologue to the sending of Magento 2 on a server. It covers the key stages, from server prerequisites to Magento 2 establishment, design, and streamlining. Whether you're an accomplished engineer or simply beginning, this guide will tell you The best way to learn how to deploy Magento 2 on Server effortlessly and certainty.

Making top notch composing requires context oriented significance and cognizance. Likewise, perplexity and burstiness are two essential factors that make composing more complicated and shifted. Our point is to deliver satisfaction with the most significant level of perplexity and burstiness, integrating longer and more mind boggling sentences close to more limited ones.

For more info, visit https://webguru.dev/how-to-deploy-magento-2-on-server/
Programmatically Scheduling and Cancelling Task with Spring Boot
Tags: scheduled, springboot, java
Published: 2023-03-23 10:00:22

Spring offers `@Scheduled` annotation to configure and schedule tasks. Methods annotated with `@Scheduled` are automatically scheduled. If you are not familiar with this read the following article by Eugen. 

https://www.baeldung.com/spring-scheduled-tasks

We will be leveraging Spring's `ThreadPoolTaskScheduler` to implement our custom task scheduler which we can programmatically trigger.

The `ThreadPoolTaskScheduler` helps manage threads internally by assigning tasks to the `ScheduledExecutorService` and implements `TaskExecutor` interface. With just one instance, it can handle tasks that might run asynchronously, including those marked with the `@Scheduled` annotation.

```
public class CustomTaskScheduler extends ThreadPoolTaskScheduler {

    private final Map<String, ScheduledFuture<?>> scheduledTasks = new IdentityHashMap<>();

    public void scheduleAtFixedRate(Runnable task, Duration period, String id) {
        ScheduledFuture<?> future = super.scheduleAtFixedRate(task, period);
        scheduledTasks.put(id, future);
    }
}
```

Just like `@Scheduled(fixedRate = 1000)`, `super.scheduleAtFixedRate(task, period)` we have provided a fixed `Duration`. We will later implement our `Runnable` task.

`super.scheduleAtFixedRate(task, period)` returns a `ScheduledFuture` which is basically a delayed result that can be cancelled at any time. So to get hold of it later we are keeping `ScheduledFuture` in `scheduledTasks`.

Let's see how we can cancel the `ScheduledFuture`.

```
public void cancelScheduledTask(String id) {
        ScheduledFuture<?> future = scheduledTasks.get(id);
        if (null != future) {
            future.cancel(true);
        }
    }
```

If the task has not started when cancel is called, the task will never run. If the task has already started, then the `future.cancel(true)` accepts a boolean parameter, `mayInterruptIfRunning`, which determines whether the thread executing this task is interrupted in an attempt to stop the task. Passing true means interrupted the task if needed.

Now, let's implement task which we need to schedule.

```
public class RunnableTask implements Runnable {

    private String id;

    public RunnableTask() {
    }

    public RunnableTask(String id) {
        this.id = id;
    }

    @Override
    public void run() {
        // perform task here
    }
}
```

An example to schedule task:

```
String id = UUID.randomUUID().toString();
RunnableTask task = new RunnableTask(id);
customTaskScheduler.scheduleAtFixedRate(task,Duration.ofMinutes(1, id);
```
Next-Image with virtual relative path
Tags: nextjs
Published: 2023-03-23 09:51:27

I'm building a next.js application, and the production server is IIS, the backend team have created a virtual directory inside the client/public folder, and they put images inside that virtual directory. they return the relative path of the images including the virtual directory. when I use that virtual relative path as a src for my images, it does not work.

Is it even possible to use a virtual relative path as a img src ??
Laravel Relationships
Tags: laravel, laravelrelationships, beginners, eloquent
Published: 2023-03-23 09:39:53

Laravel Eloquent provides an easy-to-use and expressive way to define relationships between database tables. There are several types of relationships that can be defined in Eloquent, including:

**1. One-to-One Relationship:**
         In a one-to-one relationship, a record in the parent table (e.g. users) can be associated with only one record in the child table (e.g. profiles), and vice versa. Here's an example:

```
// User Model
class User extends Model
{
    public function profile()
    {
        return $this->hasOne(Profile::class);
    }
}

// Profile Model
class Profile extends Model
{
    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

```
In this example, the `User` model has a `hasOne` relationship with the `Profile` model, and the `Profile` model has a `belongsTo` relationship with the `User` model. To retrieve the profile of a user, you can use:

```
$user = User::find(1);
$profile = $user->profile;

```

**2. One-to-Many Relationship:**
         In a one-to-many relationship, a record in the parent table (e.g. posts) can be associated with multiple records in the child table (e.g. comments), but a record in the child table can be associated with only one record in the parent table. Here's an example:

```
// Post Model
class Post extends Model
{
    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}

// Comment Model
class Comment extends Model
{
    public function post()
    {
        return $this->belongsTo(Post::class);
    }
}

```
In this example, the `Post` model has a `hasMany` relationship with the `Comment` model, and the `Comment` model has a `belongsTo` relationship with the `Post` model. To retrieve all comments of a post, you can use:

```
$post = Post::find(1);
$comments = $post->comments;

```
**3. Many-to-Many Relationship:**
          In a many-to-many relationship, a record in one table (e.g. users) can be associated with multiple records in another table (e.g. roles), and vice versa. Here's an example:

```
// User Model
class User extends Model
{
    public function roles()
    {
        return $this->belongsToMany(Role::class);
    }
}

// Role Model
class Role extends Model
{
    public function users()
    {
        return $this->belongsToMany(User::class);
    }
}

```

In this example, the `User` model has a `belongsToMany` relationship with the `Role` model, and the `Role` model has a `belongsToMany` relationship with the `User` model. To retrieve all roles of a user, you can use:

```
$user = User::find(1);
$roles = $user->roles;

```

That's it! We've successfully completed basic relationships, for advance level we will meet soon.
Who is Shabeeb ?
Published: 2023-03-23 09:29:42

Hi Everyone, 
well I'm Ahamed "Shabeeb" On here I just share who  am and how i started coding? and how i reach here? i doesn't think that it's will be an interesting blog to you but something special to you :).

     Well, I'm a student who studying Plus two / Under Graduation Period, one day I with my family comes from my mother's house on the way my Father reached Cyberpark Calicut and stop the car there and he goes into the ATM near cyberpark It's an evening time so I saw some employees come from their office to the tea shop there and my mind glows "What's inside the cyberpark, on that i searched lots about it and i got the mystery "The Developing / The Coding" so, there is the Begining.

     I like to study Coding and be becomes a Software Developer and I searched on Youtube to Teach coding !! funny, it's never but, on that search, i found the correct place for me "The Brototype", Simply saying Brototype was a Youtube Channel Which is on the content Tech on there I studied C++, JAVA, HTML, CSS, JAVASCRIPT,NODE.JS, DART, FLUTTER and studying going on 

Did you ever notice what makes me more Interested to study all of these ????????????????
  I think you don't, But, Don't worries I share it with you On my First starting from the YT channel Brototype they were conducting a challenge called 100k coding challenge at the last with the help them I created a calculator yah the calculator and its works:))))))))))))))))))))) that working on the calculator makes me more interested and happier here and I'm started and planned my future on here be a developer 

and now i will does the languages HTML,CSS,JAVA SCRIPT,C++,C#,JAVA,DART etc......... 
and also I will be a designer also who deals with Photoshop, Illustrator, After Effect  
      
Thank you for read a wastable Blog :)0
Free MySQL course from PlanetScale
Tags: webdev, tutorial, mysql, database
Published: 2023-03-23 09:21:07

[Planetscale](https://planetscale.com/) is a serverless MySQL platform - it's built for developers who just want a database and not have to worry about the stress of managing it, and it comes with a bunch of developer-centric tools like branching of databases and rolling back schema changes. Lovely.

Planetscale have recently released a **_free_** course on MySQL, which covers all of the basics. It's well written and well presented, and covers things from queries, schema and indexing.

In the modern development world everything has moved away from writing raw SQL. Most modern developers are using a framework of some sort that has abstracted away from writing SQL directly and instead uses an ORM of some flavour.

There's nothing wrong with using an ORM, but over time you will undoubtedly encounter issues which will be **much** easier to resolve if you have a solid understanding of what the ORM is actually doing under the hood. Every decent ORM will allow you to view the raw SQL it generates, which will give you insight on exactly what is going on. Let's be honest, we've all got ourselves confused when chaining relationships across dozens of models and not getting the data we're expecting.

[Check out the course here.](https://planetscale.com/courses/mysql-for-developers/introduction/course-introduction)

If you're already comfortable with MySQL and database design then you might be interested in our [Database Design Fundamentals certification](https://accreditly.io/certifications/database-fundamentals). The certification will help prove your abilities to future (or current) employers and clients. 🚀
Ethereum Chains
Tags: blockchain, web3, webdev, ethereum
Published: 2023-03-23 09:18:13

This document is reference for the networks I use regularly, and is usually up to date. If something doesn't work, you should use [ChainList](https://chainlist.org/). You can convert chainIds to hex using tools like [eserialize](https://eserialize.com) to do so.

Example: [Convert Polygon Mumbai chainId](https://eserialize.com/?input=number&output=hex&value=137)


## Mainnets

| Network | RPC URL | Chain | Hex | Symb | Explorer URL |
| ------- | --- | ----- | --- | ------ | ------------------ |
| Mainnet | [eth.llamarpc.com](https://eth.llamarpc.com)  | 1 | 0x1 | ETH | [etherscan.io](https://etherscan.io) |
| Polygon | [polygon-rpc.com](https://polygon-rpc.com) | 137 | 0x89 | MATIC | [polygonscan.com](https://polygonscan.com) |
| Optimism | [mainnet.optimism.io](https://mainnet.optimism.io) | 10 | 0xa | ETH | [optimistic.etherscan.io](https://optimistic.etherscan.io) |

## Testnets

| Network | RPC URL | Chain | Hex | Symb | Explorer URL |
| ------- | --- | ----- | --- | ------ | ------------------ |
| Mumbai | [rpc-mumbai.maticvigil.com](https://rpc-mumbai.maticvigil.com) | 80001 | 0x13881 | MATIC | [mumbai.polygonscan.com](https://mumbai.polygonscan.com) |
| Goerli | [goerli.blockpi.network](https://goerli.blockpi.network/v1/rpc/public) | 5 | 0x5 | ETH | [goerli.etherscan.io](https://goerli.etherscan.io) |
How to install PHP GRPC extensions in Ubuntu OS
Tags: php, grpc, ubuntu, pecl
Published: 2023-03-23 09:14:37

First install the below library to make compatible with pecl

```
sudo apt install php-dev php-pear autoconf zlib1g-dev


```

Now install the grpc using pecl with below command

```
sudo pecl install grpc
```

Now open your php.ini file and add the below line any where 

```
extension=grpc.so
```

Now restart your web server if required.

For more details visit the below links:
[GRPC Install Steps](https://cloud.google.com/php/grpc)
Problem solve with PHP: Two sum
Tags: php, leetcode, programming
Published: 2023-03-23 08:58:58

**Problem: **Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Here is [leetcode problem](https://leetcode.com/problems/two-sum/), where all details are explain.

As far, I can solve the problem in three ways.

**Solution 1**
```
class Solution {

    /**
     * @param Integer[] $nums
     * @param Integer $target
     * @return Integer[]
     */
    function twoSum($nums, $target) {
        $n = count($nums);
        
        for ( $i=0; $i<$n-1; $i++ ) {
            for ( $j=$i+1; $j<$n; $j++ ) {
                if ( $nums[$i] + $nums[$j] === $target ) {
                    return [$i, $j];
                }
            }
        }

}
```

**Solution 2**

```
class Solution {

    /**
     * @param Integer[] $nums
     * @param Integer $target
     * @return Integer[]
     */
    function twoSum($nums, $target) {
        $n = count($nums);

        for ( $i = 0; $i < $n -1; $i++ ) {
            $remain = $target - $nums[$i];
            $arr_remain = array_slice( $nums, $i + 1 );
            
            if ( in_array( $remain, $arr_remain ) ) {
                $pos = array_search( $remain, $nums );
                if ( $pos === $i ) {
                    $arr_keys = array_keys( $nums, $remain );
                    $pos = $arr_keys[1];
                }
                return [ $i, $pos ];
            }
        }
    }
}
```

**Solution 3**

```
class Solution {

    /**
     * @param Integer[] $nums
     * @param Integer $target
     * @return Integer[]
     */
    function twoSum($nums, $target) {
        $n = count($nums);

        $hash_table = [];
        for ( $i = 0; $i < $n - 1; $i++ ) {
            $remain = $target - $nums[$i];
            if ( in_array( $remain, $hash_table ) ) {
                $arr_key = array_keys( $hash_table, $remain );
                return [ $arr_key[0], $i ];
            }
            $hash_table[$i] = $nums[$i];
        }
        
    }
}
```
However, the 3rd solution should better optimized in algorithmic context, but I get the 1st solution is more fast. Any idea is most welcome for the reason of speed.
05 berufliches Vorwärtskommen: Was ist dein Warum
Tags: career, austausch, motivation, discuss
Published: 2023-03-23 08:55:39

Moin Moin,

[Im letzten Teil dieser Serie↗](https://dev.to/amustafa16421/04-berufliches-vorwartskommen-empfehlungen-zum-vorwartskommen-3ggo) sagte ich, dass wenn man sein „Warum“ kennt, es einfach ist einen Karriere-Weg ( Weg zum beruflichen Vorwärtskommen ) zu gehen. Gehörst du zu denjenigen, die sagen, dass sie ihr „Warum“ nicht kennen ?


Gehen wir in uns und schauen woher diese Ungewissheit kommt. Vielleicht denkst du dir, dass _Geld_ dich nicht antreiben darf, oder _Ansehen_, oder eine _Veränderung_ in der Welt zu bewirken. 


- Würdest du das Geld für gute Zwecke nutzen ?
- Stell dir vor, dass du dein Ansehen nutzt, um Arbeitsbedingungen für Software-Entwickler zu verbessern
- Wärst du erfüllt, wenn du dich nie drum bemühen würdest, die Veränderung zu erreichen ?


Vielleicht gab es bei dir einen bestimmten Moment in deiner Kindheit oder in deiner Jugend, der dazu führte, dass du diesen Weg gegangen bist. Besinne dich darauf und schöpfe daraus Kraft.


Beste Grüße,
Mustafa