teleren/devto huggingface dataset:
How to Prevent Future Errors in Your C# Code
Tags: csharp, webdev, programming, dotnet
Published: 2023-08-26 20:28:33

## Hey There! 👋🏻
Today's post is short and quick, I just wanted to share this small tip with you that I recently learned about, and I think it's a game changer, even though it's only a single line of code, not even in C#, but bare with me, it'll surely help you write more efficient and less error-prone code in your projects.

## Let's Get Started 🚀
Since the release of .NET 6, the compiler started giving out warnings of things that it thinks could cause errors and exceptions to be thrown at some point in time, so the compiler would show those **warnings**, to tell you that, hey, this is some dangerous code right here, do something about it, and when you run a project (That's built with .NET 6 and later.), you would see a bunch of warnings just thrown all over the place, like this:


![Compiler warnings in .NET 6 and later](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ialrz2iih2hczfaue9mq.png)

Now your project will still run just fine, but there's a greater likelihood it'll break due to something that's probably mentioned within that pile of warnings, and it happens **A LOT**, like **NullReferenceException** and similar exceptions.

## What's The Solution? 🔎
There's a compiler setting, that you define inside  the **.csproj** file, which tells the compiler to treat those warnings as **errors**, yes you heard that right, those warnings you have seen in that screenshot, will all be converted into errors, and if you have like 50+ warnings, then I just recommend staying away from this, because handling 50 errors at once is tough.

To enable this setting, double click the project, that will open the project file, simply add this line:



![The fixed version of the compiler setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb8ltxdq09qm74m289yn.png)

> ⚠️ NOTE: When I first published this post, I had put the value **enable** for that setting, and that doesn't work, the setting takes either true or false. Sorry for the confusion if it didn't work for you at first!

## Why's That Useful? 💡
You might be asking how introducing more errors is something good? Well, **firstly**, I recommend doing this when you're starting out with a new project, with fresh code, and not couple thousand lines with like 100+ warnings. **Secondly**, those warnings are originally potential errors, and the compiler is pointing them out for you to ensure that you properly handle them, so when you're forced to fix them, since your project won't even run without doing so, you're ensuring that your code is very less likely to crash due to some exception that was mentioned in the warnings, you'll take the time to properly tune the code so that it won't fail or crash, and therefore making your code more **robust**, less **error-prone**, and **safe**.
Easiest way to learn JavaScript
Tags: webdev, javascript, beginners, tutorial
Published: 2023-08-26 19:51:21

If you really want to learn anything, not just programming or any programming language, you can do so in a relatively fast way.

However, before you start learning anything, please keep in mind that you can't learn everything at once or in just one day. 

Now, let's come to the solution. JavaScript is often used to manipulate and enhance web pages. I assume that you are already familiar with HTML and CSS. If you are not familiar with HTML and CSS, you can visit W3Schools.com to gain an understanding of them.

The easiest way to start learning is to begin with the 10% of the programming language that is used 70 to 80% of the time. Learning JavaScript, like any programming language, requires practice to become proficient. You won't become proficient in just a few days, but starting with this initial 10% can help you become really good at learning any programming language, not just JavaScript."

1. Variables and Data Types
2. Operators
3. Control Structures
4. Functions
5. Objects
6. Arrays
7. Event Handling
8. DOM Manipulation
9. Asynchronous JavaScript
10. Modules
11. JSON
12. ES6 Features
13. Regular Expressions
14. Promises and Async/Await


Remember that the specific topics you need to focus on may vary depending on your project or job requirements. However, a strong understanding of these fundamental concepts will provide a solid foundation for JavaScript development and cover a significant portion of what you'll encounter in real-world coding tasks.
i Cant seem to find my extracted text.
Tags: python
Published: 2023-08-26 19:45:28

is my code correct? import pytesseract
from PIL import Image
import os
import shutil

# Hardcoded folder path for images
folder_path = r"C:\Users\steve\Desktop\Images for text extraction"

# Path to the folder where you want to save the extracted text
save_folder_path = r"C:\Users\steve\Desktop\extracted_text"

# Function to extract text from images in the folder
def extract_text_from_images():
    # Get a list of all image files in the folder
    image_files = [os.path.join(folder_path, file) for file in os.listdir(folder_path) if file.endswith((".png", ".jpg", ".jpeg"))]

    # Create a dictionary to store the extracted text from each image
    extracted_text_dict = {}

    # Loop through each image file
    for image_path in image_files:
        # Load the image file
        image = Image.open(image_path)

        # Use pytesseract to extract text from the image
        extracted_text = pytesseract.image_to_string(image)

        # Create a notepad file with the same name as the image in the save folder
        notepad_path = os.path.join(save_folder_path, os.path.basename(image_path) + ".txt")

        # Save the extracted text to the notepad file
        with open(notepad_path, "w") as file:
            file.write(extracted_text)

        # Store the extracted text in the dictionary
        extracted_text_dict[os.path.basename(image_path)] = extracted_text

        print(f"Text extracted from {image_path} and saved to {notepad_path}.")

    print("Text extraction from all images completed.")

    return extracted_text_dict

# Rest of the code...


# Function to answer questions from the extracted text
def answer_question(extracted_text_dict, question):
    # Search for the question in the extracted text
    for image_name, extracted_text in extracted_text_dict.items():
        if question.lower() in extracted_text.lower():
            print(f"Answer from {image_name}:")
            print(extracted_text)
            return

    print("Question not found in the extracted text.")

# Main loop to interact with the user
while True:
    user_input = input("Enter a command: ")

    if user_input.lower() == "robot":
        print("Hello, how may I assist you?")
    elif user_input.lower() == "extract":
        extracted_text_dict = extract_text_from_images()
    elif user_input.lower() == "ask":
        question = input("Ask a question: ")
        answer_question(extracted_text_dict, question)
    elif user_input.lower() == "exit":
        print("Goodbye!")
        break
    else:
        print("Invalid command. Please try again.")
Handling Bluetooth Programmatically on Windows
Tags: bluetooth, windows, cli
Published: 2023-08-26 19:17:20

>I use a command to connect to my Pixel Buds now, and switch between Bluetooth devices. It's pretty convenient, especially if you're still on Windows 10, with its buggy Bluetooth auto-connection.

## Install [Bluetooth Command Line Tools](https://bluetoothinstaller.com/bluetooth-command-line-tools)

This is the CLI tool provided by [bluetoothinstaller.com](https://bluetoothinstaller.com/), which has provided a humble suite of Bluetooth quality of life tools since 2009.

## Connecting to a Bluetooth Device

You can connect by associating a COM service with a Bluetooth device. This is done via the [btcom](https://bluetoothinstaller.com/bluetooth-command-line-tools/btcom.html) command.

```
btcom {-c|-r} {-b BluetoothAddress | -n FriendlyName} [-s {sp|dun|GUID|UUID}]
      
  -c  Create association between COM port and a remote service (Enable non-COM service).
  -r  Remove association between COM port and a remote service (Disable non-COM service).
  -s  Remote service to use (Default is Serial Port Service)
  -b  Bluetooth address of remote device in (XX:XX:XX:XX:XX:XX) format. 
  -n  Friendly name of remote device.
  -h  Prints this help screen.
```

You'll need to figure out the specific COM services that you want to hook into. Windows connects headsets via two COM services: A2DP (110b) and HFP (111e), so you may need to connect to both for it to work properly.

If you're having issues connecting (-c), try disconnecting (-r) the device first. This has worked effectively for me, although it will generally take a few seconds longer to connect.

### Connect

```
btcom -n "Shane's Pixel Buds" -c -s110e
btcom -n "Shane's Pixel Buds" -c -s110b
```

### Disconnect

```
btcom -n "Shane's Pixel Buds" -r -s110e
btcom -n "Shane's Pixel Buds" -r -s110b
```

## What Bluetooth Devices Are Available?

The Friendly Name for my Pixel Buds is "Shane's Pixel Buds". You can list available Bluetooth devices and COM services using [btdiscovery](http://bluetoothinstaller.com/bluetooth-command-line-tools/btdiscovery.html) command. This will list the ID as well as the Friendly Name.

```
btdiscovery [-i Seconds] [-b BluetoothAddress | -n FriendlyName] [-d Format] [-s [Format]]

  -i  Set the length of inquiry to the specified number of seconds.
  -b  Bluetooth address of remote device in (XX:XX:XX:XX:XX:XX) format.
  -n  Friendly name of temote device.
  -d  Set output format for the list of discovered devices.
  -s  Make service discovery. Optionally set output format for the list of services.
  -h  Prints help screen.
```
HackerRank Minimum Absolute Difference
Tags: python, challenge, algorithms
Published: 2023-08-26 19:16:49

As you may know, HackerRank has a series of interview challenges varying from easy to hard. This challenge presented now is in the package [Interview Preparation Kit > Greedy Algorithms](https://www.hackerrank.com/interview/interview-preparation-kit/greedy-algorithms/challenges) and is considered easy.

It basically gives an array and you must check the absolute difference of every pair of numbers.

```python
difference = []
for x in range(len(arr)):
    for y in range(x+1, len(arr)):
        difference.append(abs(arr[x], arr[y]))
```

But there is a catch! If you simply check all numbers, you will check unnecessary numbers. It's much better if you just check a number with the nearest neighbors of it. For example if `arr` is

```py
arr = [-59, -36, -13, 1, -53, -92, -2, -96, -54, 75]
```
and if we sort it, we just need to check each number twice (or once in the case of extremities)

```py
arr.sort()
print(arr) # [-96, -92, -59, -54, -53, -36, -13, -2, 1, 75]
```
Now we clearly see for example that we just need to test **-36** with -53 and -13. It's not possible that the sub-array [-96, -92, -59, -54] have a smaller difference with -36 than -53.

The complete algorithms is this:

```py
def minimumAbsoluteDifference(arr):
    arr.sort()
    differences = []
    for x in range(len(arr) - 1):
        differences.append(abs(arr[x] - arr[x + 1]))
    return min(differences)
```
Generate API docs under a minute in Django
Tags: programming, django, python, api
Published: 2023-08-26 18:09:36

Greetings everyone!

In this post, I'll be telling you, how we can generate API docs for any Django rest framework project, in less then a minute!

If that sounds interesting, follow along😁

### Step 1: Installing the drf_yasg package
> Note: you may find other packages for auto generating your API docs, but most of them are outdated and not maintained, that's why I'll recommend you to stick with `drf_yasg`

let's start by installing the `drf_yasg` package into your local development environment
```bash
(env) $ pip install drf_yasg
```

Once the package is installed, include it to the `INSTALLED_APPS` array, in your `settings.py` file

```python
# settings.py
...
INSTALLED_APPS = [
    # other packages
    'drf_yasg'
]
...
```

with this drf_yasg will be installed in your django project

### Step 2: Update your root urls file
Once the package is installed, open the root `urls.py` file of your project

```bash
/mydjangoproject
  |-mydjangoproject
  |   |-__init__.py
  |   |-wsgi.py
  |   |-asgi.py
  |   |-urls.py     # <---- This file
  |   |-settings.py
  |-app1
  |-app2
```

Once it is opened, update it with following code-
```python
# existing imports
...

# import get_schema_view and openapi from drf_yasg
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

# create the schema view
schema_view = get_schema_view(
    openapi.Info(
        title="My Django APIs",
        default_version='v1',
        description="Creating API docs was never this easy!!",
    ),
    public=True
)

# include the schema_view in the urlpatterns
urlpatterns = [
   # existing routes
   ...

   path('docs', schema_view.with_ui('swagger', cache_timeout=0)),
   path('redoc', schema_view.with_ui('redoc', cache_timeout=0)),
]
```

And it's done, now open [127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) route and you'll see the swagger page with all of your apis!

If you want the redoc version, just go to the [127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc) page and redoc api docs will appear there!


#### Swagger Page
![Swagger Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bnxghca90x3mdjc6dgy.gif)

If you have any problems mention them on the comments😉
Cheers!
Java - Singly Linked Lists: Goodbyes with `deleteWithValue(data)` 🌊
Tags: java, computerscience, singlylinkedlist, dsa
Published: 2023-08-26 18:05:59



Hello Dev.to enthusiasts! 🌟

We've spoken about adding to our singly linked list. Today, let's tackle the slightly heartbreaking act of saying goodbye, or more technically, deleting nodes. Introducing...(drum-roooolls) the `deleteWithValue(data)` method.

### A Quick Refresher: Singly Linked List 🎒

Just in case someone's late to the party:

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```


### The Delicate Art of Deletion 🗑

Deleting a node is all about finding it first, and then, well, letting it go. Let's delve into the method:

```java
public void deleteWithValue(int data) {
    // If the list is playing hide and seek (is empty), there's nothing to delete
    if (head == null) return;
    
    // If the head node is our target
    if (head.data == data) {
        head = head.next;
        return;
    }
    
    // If not, we go on finding our node
    Node current = head;
    while (current.next != null && current.next.data != data) {
        current = current.next;
    }
    
    // If the node isn't found, we exit the stage 
    if (current.next == null) return;
    
    // Finally... snip it out of the list
    current.next = current.next.next;
}
```

### Why Delete? 💔

Sometimes, data changes. Maybe a value is no longer relevant, or perhaps there's an error in your dataset. In such times, it's crucial to have the ability to cleanly and efficiently remove specific nodes from your list.

### To Wrap It Up 🌌

The `deleteWithValue(data)` method may seem like a simple tool, but it ensures our singly linked list remains relevant and error-free. 

In [`the next article`](https://dev.to/hunorvadaszperhat/java-singly-linked-lists-showcasing-with-printlist-2ecc) we will look at `printlist()` method


Cheers and happy coding! 🚀
When is Rhinestone prom dress suitable for wearing
Published: 2023-08-07 06:27:50

Rhinestone prom dresses are glamorous and eye-catching garments that can make a statement at any formal event, particularly prom night. These dresses are adorned with rhinestones, which are artificial gemstones made of glass or crystal, adding a touch of sparkle and luxury to the overall look. The suitability of wearing a rhinestone prom dress depends on various factors, including the event's dress code, the individual's style preferences, and the overall theme and ambiance of the occasion.

Prom Night: The most obvious and appropriate occasion to wear a rhinestone prom dress is, of course, prom night. Prom is a special and formal event in a student's life, often marking the end of high school. It is a time to celebrate and create lasting memories, and a rhinestone dress can contribute to the excitement and glamour of the evening. Many young women dream of wearing a stunning, sparkly dress for this momentous occasion, and a rhinestone prom dress fits the bill perfectly.

Formal Gala or Ball:  <a href="https://www.angellavish.com/">Rhinestone prom dress</a> are also suitable for other formal events such as galas, balls, or formal parties. These occasions usually call for elegant and sophisticated attire, and a rhinestone dress can add a touch of opulence and elegance to the wearer's look. However, it's essential to ensure that the dress aligns with the specific dress code of the event.

Red Carpet Events: If you are attending a red carpet event or any event where you want to make a glamorous entrance, a rhinestone prom dress can be a show-stopping choice. The shimmering rhinestones catch the light and draw attention, making you feel like a star.

Pageants and Competitions: Rhinestone prom dresses are commonly worn by contestants in beauty pageants, talent competitions, and modeling contests. The dazzling effect of the rhinestones on stage enhances the performer's presence and adds extra flair to their performance.

Special Celebrations: For milestone celebrations such as Sweet 16 parties, quinceañeras, or formal birthday celebrations, a rhinestone prom dress can be a fitting choice, especially if the event's theme allows for glitz and glamour.

Evening Weddings: Depending on the wedding's formality and theme, a rhinestone prom dress can be suitable for guests attending evening weddings. However, it's essential to ensure that the dress does not outshine the bride's attire and adheres to any specific dress code or color scheme set by the couple.

In summary, a rhinestone prom dress is suitable for various formal and celebratory occasions, with prom night being the most popular and obvious choice. It can add a touch of sparkle, luxury, and elegance to the wearer's look and create a memorable and glamorous presence at any event. However, it's crucial to consider the specific dress code and theme of the occasion to ensure the dress is appropriate for the event.
Mastering The Web : TypeScript Vs JavaScript Showdown
Tags: javascript, typescript, webdev, beginners
Published: 2023-08-26 17:53:52

      
**_Here We Go: Introduction Time_:**
    Someone just starting out in front-end web development might struggle to decide whether to use TypeScript or JavaScript for their web projects.This weblog will resolve the confusion using explaining the terms JavaScript and TypeScript and explaining a number of the differences between them.

**_Getting Cozy with JavaScript: Your Coding BFF!:_**
     	JavaScript is the handiest form of scripting language used to create dynamic net pages and add capability to web pages written in HTML. JavaScript is a smooth-to-learn, cross-platform translation language whose code is written into HTML documents with the usage of tags, so it is embedded in HTML. JavaScript programs run in an internet browser with no initial configuration.JavaScript's syntax is kinda similar to C, but when it comes to naming stuff, it's more like Java. In the old days, JS was all about front-end stuff, but as tech evolved, newer versions also got your back for server-side things. So now, you can use JS for both making websites look cool and powering the stuff behind them.

_**TypeScript Fun:**_
      TypeScript is an open supply programming language that evolved by using Microsoft in 2012.TypeScript is the syntax of JS, which means it consists of all the functions to be had in JS plus some extras which can be lacking in JS. essentially.TypeScript consists of instructions, inheritance, encapsulation, and so forth. It's by far an effective superset of JS with item-oriented programming capabilities as the reason that a JS application is a superset of JS, it is taken into consideration as TypeScript software. TypeScript is a scripting language, so code will now not be carried out until you assign the proper facts type to a variable. Like JS, TypeScript is a platform impartial language and supports all JS libraries.

_**TypeScript vs JavaScript: What's the Deal? :**_
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5io01epx9upyvoomj56.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b6zidqvpk7ycg1uj6dg8.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mey4gfmim82pru1plac4.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8mytx03mes5fre21sdd.jpg)

_**Conclusion :**_
     You know, it's really just your own take on which language rocks and which one doesn't. I mean, JS is like the easy-peasy choice for a lot of devs because everyone's into it. But hey, if you're tackling big, fancy projects, TypeScript is where it's at. Think about it, it's like JS on steroids – gives you all those OOP goodies, fancy IDE support, and lets you do things that plain JS can't. So, when you're deciding, don't forget about TypeScript, buddy.


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

 And that's a wrap, my friends. Until we meet again in the blogosphere, keep being your amazing selves!
          Happy Learning!