teleren/devto huggingface dataset:
Using Entity Framework Core 8 Owned Types HasData()
Tags: entityframework, dotnet8, ownedtypes
Published: 2023-10-26 17:21:15

- First, let's write two sample classes
``` csharp
public class Person
{
    public int Id { get; set; }
    public string FirstName { get; set; } = null!;
    public string LastName { get; set;} = null!;

    public Contact PersonalInformation { get; set; } = null!;
}
```

``` csharp
using Microsoft.EntityFrameworkCore;

[Owned]
public class Contact
{
    public string PhoneNumber { get; set; } = null!;
    public string EmailAddress { get; set; } = null!;
}
```

- 
Let's create the Person Table with the help of DbContext class and Entity Framework Core.

``` csharp
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
{
    public DbSet<Person> People => Set<Person>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity<Person>(p =>
        {
            p.HasData(
                new Person
                {
                    Id = 1,
                    FirstName = "Person 1",
                    LastName = "Surname 1"
                },
                new Person
                {
                    Id = 2,
                    FirstName = "Person 2",
                    LastName = "Surname 2"
                },
                new Person
                {
                    Id = 3,
                    FirstName = "Person 3",
                    LastName = "Surname 3"
                });

            p.OwnsOne(e => e.PersonalInformation).HasData(new
            {
                PersonId = 1,
                EmailAddress = "EmailAddress 1",
                PhoneNumber = "1111111111111111"
            },
            new
            {
                PersonId = 2,
                EmailAddress = "EmailAddress 2",
                PhoneNumber = "22222222222222"
            },
            new
            {
                PersonId = 3,
                EmailAddress = "EmailAddress 3",
                PhoneNumber = "3333333333333333"
            });
        });
    }
}
```

- Now it's time to create the database with the entity framework migration command and then update the database.

```powershell
Add-Migration Initial
```

```powershell
Update-Database
```
that is all . enjoy your work 😊
celery beat crash
Tags: celerybeat
Published: 2023-10-26 17:19:07

I am having issues with celery beat crashing  at specific time everyday "[supervisor] : celery_beat crashed at 2023-10-2323:00:45,771,"
and from the logs it looks like, celery beat crashes after backend_cleanup runs, but unable to figure out why its crashing, beat process run normally after the crash.

[2023-10-25 22:51:59,876: DEBUG/MainProcess] Writing entries...
[2023-10-25 22:55:00,145: DEBUG/MainProcess] Writing entries...
[2023-10-25 22:58:00,389: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:49:26,654: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:49:26,775: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:49:26,775: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:49:30,757: DEBUG/MainProcess] DatabaseScheduler: initial read
[2023-10-25 23:49:30,757: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:49:30,776: DEBUG/MainProcess] DatabaseScheduler: Fetching database schedule
[2023-10-25 23:49:30,797: DEBUG/MainProcess] Current schedule:
<ModelEntry: celery.backend_cleanup celery.backend_cleanup(*[], **{}) <crontab: 0 4
         * *
          * (m/h/d/dM/MY), UTC>
        >
[2023-10-25 23:49:35,820: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:52:36,073: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:55:36,312: DEBUG/MainProcess] Writing entries...
[2023-10-25 23:58:36,573: DEBUG/MainProcess] Writing entries...
Use of useDebounce while searching data. Send data on value change using useRouter hook next
Tags: webdev, nextjs, javascript
Published: 2023-10-26 17:16:59

## 1. Step 1 to get value and send via routes
 

```
const [searchValue, setSearchValue] = useState("");
  const [searchQuery] = useDebounce(searchValue, 600);

  useEffect(() => {
    if (!searchQuery) {
      router.push("/");
    } else {
      router.push(`/search?q=${searchQuery}`);
    }
  }, [searchQuery, router]);
```

## 2. On the search page get data using useSeachParams

```
const searchParams = useSearchParams();
const searchTextValue: any = searchParams.get("q");
```

## 3. Add filter logic 

```
const filterSearchProduct = liveProducts?.filter((elm: any) => {
    return elm.title?.toLowerCase()?.includes(searchTextValue?.toLowerCase());
  });

Then render data where you want to show it!


```
Vs code shortcuts you don't want to miss🤔
Tags: vscode, productivity, programming, javascript
Published: 2023-10-26 17:03:38


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zo3iz1q60z391bs5pnnr.jpeg)
In this post I am sharing three vs code shortcuts that will definitely boost your efficiency and decrease the time consumption on basic repeatetive things.

So here It starts😃

1) **Ctrl + W**
This shortcut helpes in closing the opened file in a project so you cna ose the opened file with this shortcut.

2) **Ctrl + P** 
This shortcut is helpful in finding the file in a second without need of checking whole file directory.

3) **Ctrl + B**

Through this shortcut you can toggle side bar(file explorer) ie you can show and hide the Vscode file explorer.


Try these shortcuts as they might look simple but I literally found these shortcuts very very useful.

You can check video here 

https://youtube.com/shorts/SZnUuc8VvEw
Placeholder Contributor
Tags: hack23contributor
Published: 2023-10-26 16:59:30

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a contributor. Is this your first Hacktoberfest, or have you contributed to others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your learning or career goals changed since working on these new projects? -->
Making the Python Port Scanner More User-Friendly
Published: 2023-10-26 15:12:23

## Discovery of the Issue

While browsing through various open-source projects on GitHub, I stumbled upon the Python Port Scanner. Curious to see how it works and potentially contribute, I decided to give it a try. Utilizing GitHub's search functionality, I navigated through the repository's issues to understand the current state of the project and identify any areas that might need improvement. That’s when I noticed Issue #10, which highlighted the need for clearer error messages and improved handling during scanning processes.

## The Journey to Improvement

Recognizing the importance of user-friendly messages, especially when dealing with network-related tasks, I decided to dive into the codebase. My objective was clear: enhance error messages, provide better feedback during scans, and ensure that users have a smooth and informative experience while using the port scanner.

### Step 1: Setting Up the Environment

First things first, I cloned the repository and set up the development environment. Following the instructions provided in the README, I installed the necessary dependencies and got the port scanner up and running.

### Step 2: Understanding the Code

Next, I spent some time familiarizing myself with the code. The port scanner was well-structured, and it didn’t take long to identify the sections responsible for error handling and user feedback.

### Step 3: Making Enhancements

Armed with a good understanding of the codebase, I began making enhancements. I focused on two main areas:

1. **Clearer Error Messages:** I ensured that whenever there was an issue resolving a target’s hostname, the tool provided a clear and informative message, guiding the user on what might have gone wrong.

2. **Improved Scanning Feedback:** I enhanced the feedback given during the scanning process, ensuring that users were informed if a port scan was taking longer than usual and providing additional details for other potential issues.

### Step 4: Testing the Changes

After making the changes, I rigorously tested the port scanner to ensure that the enhancements were working as intended. I simulated various scenarios, including invalid hostnames and slow ports, to validate that the new error messages and feedback were being displayed correctly.

### Step 5: Opening a Pull Request

Satisfied with the improvements, I proceeded to open a pull request on the project’s GitHub repository, providing a detailed description of the changes made and mentioning that the PR addressed Issue #10.

## Conclusion

Contributing to open-source projects is an enriching experience. It not only helps in improving one’s coding skills but also provides a sense of community as you work alongside others to enhance and elevate projects. Through this experience with the Python Port Scanner, I’ve learned more about network scanning, improved my Python skills, and hopefully made the tool more user-friendly for everyone.

[Repo](https://github.com/theinit01/portscanner)
[PR](https://github.com/theinit01/portscanner/pull/21)
CodeMonkey Unveils Exciting New AI Mini-Course, "AI Is A Hoot, Pose Detection"
Tags: ai, learning, code, career
Published: 2023-10-26 16:54:46

CodeMonkey is introducing a **new mini-course** called **"AI is a Hoot, Pose Detection"** just in time for the **Global Hour of Code **week-long event in December 2023. This **free hour-long** course aims to make coding education accessible to young learners worldwide. 

The mini-course allows students to delve into artificial intelligence and pose detection by training an AI model to recognize various poses using their webcam. The course begins with students capturing their own poses, which are then used to control the actions of an owl game character in an interactive and engaging learning experience. 

CodeMonkey prioritizes children's privacy and ensures that no images are collected or stored during the process. "AI is a Hoot" offers a fun and educational way for students to explore the world of AI and participate in the Hour of Code event.

For more information about CodeMonkey and the "AI is a Hoot, Pose Detection" mini-course, please visit www.codemonkey.com/hour-of-code/ai-is-a-hoot-hour-of-code/

Head to [Techdogs ](https://www.techdogs.com/tech-news/globe-newswire/codemonkey-unveils-exciting-new-ai-mini-course-ai-is-a-hoot-pose-detection-in-celebration-of-the-global-hour-of-code-week-long-event-this-december)to read the full news article!

Like what you read? Head to the [TechDogs homepage](https://www.techdogs.com/) to find the latest tech content infused with drama and entertainment. We've got[ Articles](https://www.techdogs.com/resource/td-articles), [Videos](https://www.youtube.com/@techdogs_inc/shorts), [News](https://www.techdogs.com/resource/tech-news) and [Events & Webinars](https://www.techdogs.com/resource/events) - the complete lot to help you Know Your World of Technology.
Exclusive collection of free SVG icons download for commercial projects without attribution
Tags: developers, html, javascript, reactjsdevelopment
Published: 2023-10-26 16:23:59

Explore, search and find the best fitting icons or vectors for your projects using wide variety vector library. Download free SVG Vectors for commercial use.

This is also beautiful website for free svg icon — [custicon.com](https://custicon.com/)
24000+ free icons for use in web, iOS, Android, and desktop apps. Support for SVG. License: MIT, Free for commercial or personal use.
This provide svg icon and svg code and also provide the icon image and it should be free

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


<a href="https://www.buymeacoffee.com/nikrunic" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 30px !important;width: 108px !important;" ></a>
Create custom CSS property using @property CSS at-rule
Published: 2023-10-26 16:22:27

This is interesting. Ever wanted to create a custom CSS property? It seems now that it is possible.

> The @property CSS at-rule is part of the CSS Houdini umbrella of APIs. It allows developers to explicitly define their CSS custom properties, allowing for property type checking and constraining, setting default values, and defining whether a custom property can inherit values or not.

The @property rule represents a custom property registration directly in a stylesheet without having to run any JS. Valid @property rules result in a registered custom property, as if registerProperty() had been called with equivalent parameters.

Source: [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/@property).

## Syntax

```CSS
@property --property-name {
  syntax: "<color>";
  inherits: false;
  initial-value: #c0ffee;
}
```

Read more about [@property on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/@property).
Hidevs
Published: 2023-10-26 16:16:34

# Creating a RESTful API with Flask: GET and POST Methods

In this article, we'll explore how to create a RESTful API using the Flask web framework in Python. We'll focus on two essential HTTP methods: GET and POST.

## Prerequisites

Before you start, make sure you have the following installed:

- Python: You'll need Python installed on your system.
- Flask: You can install Flask using `pip install Flask`.

## Setting Up Your Flask Application

Start by creating a new directory for your project and a Python file (e.g., `app.py`) to hold your Flask application.

```
# Import the Flask module
from flask import Flask, request, jsonify

# Create a Flask app
app = Flask(__name__)

# Dummy data for demonstration
data = []

# Define a route for the root URL
@app.route('/')
def hello_world():
    return "Hello, World!"

# GET Method
@app.route('/api/data', methods=['GET'])
def get_data():
    return jsonify(data)

# POST Method
@app.route('/api/data', methods=['POST'])
def add_data():
    new_item = request.json  # Get JSON data from the request body
    data.append(new_item)   # Append data to the list
    return jsonify({"message": "Data added successfully!"})

if __name__ == '__main__':
    app.run(debug=True) 
   ```
Purpose of @SpringBootApplication Annotation in Spring Boot
Tags: springboot, java, backend
Published: 2023-10-26 16:09:56

The `@SpringBootApplication` annotation is a powerful and fundamental annotation in the Spring Boot framework. It encapsulates several other annotations and serves as the entry point for your Spring Boot application.

## What is @SpringBootApplication?

The `@SpringBootApplication` annotation is a combination of three annotations:

1. `@SpringBootConfiguration`: Denoting that this class provides configuration for the application.
2. `@EnableAutoConfiguration`: Enabling Spring Boot's auto-configuration mechanism, which automatically configures the application based on the libraries on the classpath.
3. `@ComponentScan`: Instructing Spring to scan the specified package (and sub-packages) for annotated components.

## Why Use @SpringBootApplication?

This annotation simplifies the setup of a Spring Boot application. By placing it on your main class, you declare it as the starting point of your application. Spring Boot then handles much of the configuration and bootstrapping for you.

## Example Usage:

Let's consider a basic Spring Boot application with the `@SpringBootApplication` annotation:

```java
@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}
```

In this example, `MyApplication` is marked with `@SpringBootApplication`. The `main` method then uses `SpringApplication.run(...)` to bootstrap the application.

## Benefits:

1. **Simplified Setup**: The annotation-driven approach reduces the need for manual configuration, allowing you to focus more on writing application logic.

2. **Auto-Configuration**: Spring Boot's auto-configuration feature sets up your application with sensible defaults based on the libraries you have in your classpath.

3. **Component Scanning**: The application will automatically scan for annotated components like `@Component`, `@Service`, `@Repository`, etc., making it easy to wire dependencies.

4. **Readability and Maintainability**: By using `@SpringBootApplication`, you clearly indicate the entry point of your application, making it easier for other developers to understand your code.

## Conclusion:

The `@SpringBootApplication` annotation is a cornerstone of Spring Boot development. By using it, you leverage the power of auto-configuration and component scanning, simplifying the setup and development process of your application. This annotation-driven approach encourages best practices and accelerates your development workflow.

Check out my Youtube channel for more content:-
[SaurabhNative Youtube](https://www.youtube.com/@SaurabhNative/featured)
DPDPA Evolution: A Comprehensive Analysis of Old vs. New
Tags: dpdpa, dataprotectionact, dataprivacylaw, dpdpa2023
Published: 2023-10-26 16:05:20

**Introduction**

In the realm of crafting captivating content, two pivotal facets come to the fore: “enigma” and “cadence.” Enigma, fundamentally, appraises the intricacy inherent in the prose, while cadence delves into the ebb and flow of sentence structures.

**Let’s compare the conventional and contemporary approaches within the realm of **[DPDPA (Digital personal data protection act)](https://dpdpa.co.in/)**.**

The “old DPDPA” can be likened to a venerable family recipe passed down through generations, steadfastly adhering to established practices. It’s akin to your grandmother’s culinary secrets, timeless and unwavering. This approach, while reliable, tends to resist the allure of innovation.

In stark contrast, the “new DPDPA” resembles that tech-savvy cousin who eagerly embraces the latest gadgets and techniques. It embodies adaptability, constantly evolving to confront the ever-changing landscape of digital threats.

When it comes to linguistic choices, the “old DPDPA” relies on the comfort of familiar, time-tested terminology, much like your grandmother’s endearing colloquialisms. In contrast, the “new DPDPA” thrives on the adoption of fresh, innovative jargon, akin to a trendy teenager effortlessly incorporating the latest slang into their vocabulary.

Picture the “old DPDPA” as following a rigid daily routine, akin to performing the same chores day in and day out. In contrast, the “new DPDPA” assumes the role of a nimble gymnast, ready to contort and adapt to confront any data security challenge that arises.

While the “old DPDPA” may offer a sense of cozy predictability, it is the “new DPDPA” that stands as the agile sentinel, prepared to navigate the ever-evolving landscape of digital threats. To truly grasp this distinction, envision it as examining a multifaceted gem from various angles, each revealing a unique facet of its brilliance.

**In conclusion**, the contrast between the “traditional and modern **[DPDPA](https://dpdpa.co.in/)**” goes beyond mere wordplay; it highlights different approaches to data protection. While tradition certainly has its merits, in a time characterized by innovation and flexibility, it’s the latter that leads us into the future, safeguarding our data in our constantly evolving digital landscape.
How DPDPA is Transforming the Financial Industry
Tags: dpdpa, dataprotectionact, dataprivacylaw, dpdpa2023
Published: 2023-10-26 15:56:48

**Introduction**

In the fast-moving world of finance, change is the name of the game. And recently, a new term has been making waves — DPDPA. But what is DPDPA, and how is it changing finance? In this article, we dive into the world of DPDPA to explore how it’s reshaping the financial industry.
**
Decoding DPDPA: What Is It?**

Let’s start with the basics. **[DPDPA](https://dpdpa.co.in/)** stands for the Data Protection and Digital Privacy Act. It’s a set of rules designed to keep digital information safe. But it’s more than just words on paper; it’s a big shift in how financial companies work.

**Changing How Data Is Handled**

Financial companies have always had a lot of your pinfo, from your ID to your bank transactions. But with DPDPA, things are different. Now, these companies have to be super careful with your data, making sure it stays private and secure.
**
Why Customers Trust It**

In a world where data leaks are common news, DPDPA is like a superhero for customers. It has strict rules that keep your info safe, making you trust financial companies more. You know your data is protected by law.

**Making Rules Easier**

One cool thing about **[DPDPA](https://dpdpa.co.in/)** is how it simplifies the rules. Financial companies must follow strong data protection rules. This doesn’t just keep your data safe; it also makes it easier for companies to follow the law and avoid fines.

**Going Digital**

DPDPA is pushing finance into the digital age. Companies are now using fancy tech to keep your data safe. This switch to digital not only makes things run smoother but also sparks new ideas for innovation.

**Getting Ahead**

In the super competitive world of finance, being on top is a big deal. Companies that embrace DPDPA and follow its rules get an edge. They get more customers and keep the ones they have because they promise to keep your data safe.

**The Ripple Effect**

DPDPA doesn’t stop at big companies. It’s changing the whole financial world. Even smaller companies and traditional banks are changing how they handle data to match the new rules.

**Conclusion: A Safer Financial Future**

In the end, **[DPDPA](https://dpdpa.co.in/)** is transforming finance in a big way. It’s not just about following laws; it’s about making data protection and digital privacy a priority. As finance keeps evolving, DPDPA is like a guiding light, leading the way to a safer, more secure, and tech-savvy future.

In a world full of data, **[DPDPA](https://dpdpa.co.in/)** is here to protect it and make finance better for everyone.
CSS Flexbox Tutorial
Tags: webdev, css, flex, flexbox
Published: 2023-10-26 15:55:21

Alright friends, I finally created a much-requested CSS Flexbox tutorial.  Learn the key principles of how flex box works instead of just randomly adding values to see what happens!  You'll be able to confidently write flexbox code after watching my quick 30 minute overview.

{% embed https://www.youtube.com/watch?v=w9lsR2tvkvQ %}
I am in science and it's boring
Tags: discuss
Published: 2023-10-26 15:53:50

Bro LoL look what I found: It's because what we are shown in school often fails to foster curiosity in us. With textbooks and complicated diagrams, we often find ourselves dozing off or thinking about what we'll have for dinner during classes. And this perception that science is boring easily follows us from childhood to adulthood.


Don't forget to follow! (written by Asher) See Ya!