teleren/devto huggingface dataset:
Lua String Manipulation
Tags: webdev, programming, tutorial, devops
Published: 2023-09-08 12:17:33

We are discussing **Lua String Manipulation**, hoping that it would help the learners. Lua provides a number of functions for manipulating strings. Some of the most common functions include:

string.len(): Returns the length of a string.
string.sub(): Returns a substring of a string.
string.upper(): Converts a string to uppercase.
string.lower(): Converts a string to lowercase.
string.gsub(): Replaces all occurrences of a substring in a string.

The string.len() function returns the number of characters in a string. For example, the following code will print the number of characters in the string "Hello, world!":

Lua
str = "Hello, world!"

len = string.len(str)

print(len)
Use code with caution. Learn more
This code will print the following output:

13

The string.sub() function returns a substring of a string. The substring is specified by two arguments: the start position and the end position. The start position is the index of the first character in the substring. The end position is the index of the last character in the substring.

For example, the following code will print the substring "Hello" from the string "Hello, world!":

Lua
str = "Hello, world!"

substring = string.sub(str, 1, 5)

print(substring)
Use code with caution. Learn more
This code will print the following output:

Hello
The string.upper() function converts a string to uppercase. For example, the following code will convert the string "hello, world!" to "HELLO, WORLD!":

Lua
str = "hello, world!"

uppercase_str = string.upper(str)

print(uppercase_str)
Use code with caution. Learn more
This code will print the following output:

HELLO, WORLD!
The string.lower() function converts a string to lowercase. For example, the following code will convert the string "HELLO, WORLD!" to "hello, world!":

Lua
str = "HELLO, WORLD!"

lowercase_str = string.lower(str)

print(lowercase_str)
Use code with caution. Learn more
This code will print the following output:

hello, world!
The string.gsub() function replaces all occurrences of a substring in a string with another substring. The string.gsub() function takes three arguments: the string to search, the substring to search for, and the replacement substring.

For example, the following code will replace all occurrences of the space character in the string "Hello, world!" with an underscore character:

Lua
str = "Hello, world!"

new_str = string.gsub(str, " ", "_")

print(new_str)
Use code with caution. Learn more
This code will print the following output:

Hello_world!

These are just a few of the many string manipulation functions available in Lua. By using these functions, you can easily manipulate strings to create the desired output.

Conclusion

**[Lua string manipulation](https://mrexamples.com/lua/lua-strings/)** is a powerful tool that can be used to modify strings. By following the examples in this forum post, you can learn how to use these functions to manipulate strings in Lua.
JavaScript : Async/Await And Promises (English/Hindi)
Tags: webdev, javascript, programming
Published: 2023-09-08 12:12:12

## English

**Promises:**
Promises are a way to handle asynchronous operations in a more organized and readable manner. They represent a value that might be available now, or in the future, or never.

```javascript
function fetchData() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      const data = "Fetched data from server";
      // Simulating success
      resolve(data);
      // Simulating error
      // reject("Error fetching data");
    }, 2000);
  });
}

fetchData()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });

```

**Async/Await:**
Async/Await is a more recent feature in JavaScript that simplifies asynchronous code even further. It allows you to write asynchronous code that looks similar to synchronous code, making it easier to understand and maintain.

```javascript
async function fetchDataAsync() {
  try {
    const response = await fetchData();
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

fetchDataAsync();

```

## Hindi

**Promises:**
Promises ek tareeka hai asynchronus operations ko ek vyavasthit aur padhne mein sahaj tarike se handle karne ka. Ye ek aisa mauka hai jo abhi maujood ho sakta hai, ya bhavishya mein ho sakta hai, ya kabhi na ho.

```javascript
function fetchData() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      const data = "Server se data liya gaya";
      // Utpanna huaa safalata
      resolve(data);
      // Utpanna huaa karan
      // reject("Data liye jaane mein error");
    }, 2000);
  });
}

fetchData()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });

```

**Async/Await:**
Async/Await ek nedee haaal mein JavaScript mein aayi feature hai jo asynchronus code ko aur bhi saral bana deti hai. Isse aap aisa asynchronus code likh sakte hain jo sankramit code ki tarah lagta hai, jisse samajhna aur maintain karna aasan ho jata hai.

```javascript
async function fetchDataAsync() {
  try {
    const response = await fetchData();
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

fetchDataAsync();

```
AI Food Recognition : Classifying 36 Fruits and Vegetables in TensorFlow
Tags: ai, python, opencv, imageclassification
Published: 2023-09-08 11:57:52

Hi,

🍏🥕🍅 In this tutorial, we guide you through the process of building a neural network capable of classifying 36 different fruits and vegetables using TensorFlow and Python. 🎥
📚 Here's what you'll learn: 

🔹 Data Preparation: Explore the dataset and learn how to preprocess and organize your image data effectively. 
🔹 Model Building: Construct a deep neural network with TensorFlow and Keras, layer by layer. 
🔹 Model Training: Witness the training process and fine-tuning for impressive accuracy. 
🔹 Model Evaluation: Assess how well the model performs on new, unseen data. 
🔹 Predictions: Discover the inner workings of the model as it makes predictions on individual images.


If you are interested in learning modern Computer Vision course with deep dive with TensorFlow , Keras and Pytorch , you can find it here  : http://bit.ly/3HeDy1V
Perfect course for every computer vision enthusiastic

Actually recommend this book for deep learning based on Tensorflow and Keras : https://amzn.to/3STWZ2N

Check out our tutorial here : https://youtu.be/w5T86Z3lod0

Enjoy
Eran

#Python #openCV #TensorFlow #Deeplearning #DeepLearningTutorial #TensorFlowFruitClassification #PythonNeuralNetwork #AIFoodRecognition #MachineLearningProject #ImageClassificationTutorial #FruitandVegetableClassifier
Siemens Hearing Aid Dealers In Chennai
Published: 2023-09-08 11:50:49

Get the best hearing aid from the best **[hearing aid centre near me](https://www.adrohearingaid.com/price-list/)**. For hearing disorders go for the best hearing aid centre in Chennai. They have professional well-trained doctors and nurses to analyse the hearing problem and make the best choice to buy the correct hearing aids. They always provide high-quality hearing accessories at an affordable price. They always care for our customers by providing the best accessories as per the audiologist instruction. **[Siemens Hearing Aid Dealers In Chennai](https://www.adrohearingaid.com/siemens-products/)** is affordable with the best offers.
Warning: Cannot update a component while rendering a different component.
Published: 2023-09-08 11:35:52


![Warning: Cannot update a component while rendering a different component](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqqcggn84aiaqfde1zwt.png)

The warning message "Cannot update a component while rendering a different component" is React's way of telling you that you are trying to modify the state or props of a component while it is in the process of rendering another component. React is designed to prevent such scenarios to maintain a predictable rendering flow and to avoid potential issues like infinite loops.

Let's try to understand this error with an example.

```react
import React, { useState } from 'react';

export default function App() {
  const [name, setName] = useState('');

  return (
    <div>
      <input
        placeholder="Enter your name"
        type="text"
        onChange={(e) => setName(e.target.value)}
      />
      <Updatename setName={setName} />
      Hello, {name}!
    </div>
  );
}

function UpdateName(props) {
  // This component updates the state provided in props
  props.setName('John Doe'); // This will cause the error
  return null;
}

```
In this example, the `UpdateName` component updates the state provided in props during rendering, which triggers the error.



## How to solve this error?
Using useEffect can be a useful approach to prevent the error in certain situations. Here's how you can use useEffect to mitigate the error:

```react
import React, { useState, useEffect } from 'react';

export default function App() {
  const [name, setName] = useState('');

  useEffect(() => {
    if (name === '') {
      setName('John Doe');
    }
  }, [name]); // Run the effect whenever the 'name' state changes

  return (
    <div>
      <input
        placeholder="Enter your name"
        type="text"
        value={name}
        onChange={(e) => setName(e.target.value)}
      />
      <DisplayName name={name} />
    </div>
  );
}

function DisplayName(props) {
  return (
    <div>
      <h1>Your name is {props.name}</h1>
    </div>
  );
}
```
In this example, we use the useEffect hook to check whether the name state is empty, and if it is, we set it to 'John Doe'. The useEffect hook runs whenever the name state changes, ensuring that the state update happens after the rendering is complete, thus preventing the error.

Here's a breakdown of the key points:

1. We pass `[name]` as the dependency array to useEffect. This means that the effect will run whenever the name state changes.
2. Inside the effect, we check if name is empty. If it is, we update it to 'John Doe'. This is a safe operation because it happens after the rendering phase.
3. In the input element, we use the value prop to bind the input's value to the name state, ensuring that the input field reflects the current state.

By using useEffect in this manner, you can safely manage state updates and prevent the "Cannot Update a Component While Rendering a Different Component" error in cases where conditional state updates are necessary.
Friends Don't Let Friends ANTIPATTERN
Tags: webdev, coding
Published: 2023-09-08 11:35:00

When we were updating our legacy ASP.NET WebForms application, we needed to add Dependency Injection. We talk about what considerations we had in the level of refactoring we could make, and what framework we decided to use.

This got us into a small discussion about what is an AntiPattern and why they are bad.

https://youtu.be/KPtMmh5YW_E

{% youtube https://youtu.be/KPtMmh5YW_E %}
A comprehensive guide on how to design a responsive website.
Tags: webdev, programming, beginners, tutorial
Published: 2023-09-08 11:33:27

In today’s digital age, the internet is accessible from a multitude of devices, ranging from smartphones and tablets to desktop computers and even smart TVs.

As a web developer, it’s your responsibility to ensure that the websites you create are not only visually appealing but also functional on all screen sizes. 

This is where responsive web design comes into play. It is important because it ensures that users have a consistent experience no matter what device they are using.

**What is a Responsive Web Design?**
Responsive web design is an approach that aims to make web pages render well on different devices and window or screen sizes.

The primary goal is to ensure that users have a consistent and user-friendly experience regardless of the device they are using to access a website.

## Table Of Contents
- Understanding Responsive Web Design
- Mobile-First Approach
- Viewport and Media Queries
- Flexible Grid Systems
- Images and Media for Different Devices
- Responsive Typography
- Testing and Debugging
- Frameworks and Tools
- Performance and Page Speed
- Closing Thoughts

In this blog, You’ll explore the concept of responsive web design and discuss best practices for building websites that adapt seamlessly to various devices and screen resolutions.

So, fasten your seat belts and get ready to embark on a journey of designing a responsive website by visiting to [Canopas Blog](https://blog.canopas.com/guidelines-to-consider-while-designing-a-responsive-website-bbee716d0389#cf25).

Follow [Canopas](https://blog.canopas.com/) for our latest technical blog posts!
Laravel 10 File Upload Example
Published: 2023-09-08 11:28:11

You can use the validate() method to validate incoming request data. This method accepts an array of validation rules as its first argument. For example, if you want to validate a file, you can use the file rule in laravel 10 apps.

## Laravel 10 File Upload with Validation Example Tutorial

To upload a file with validation in Laravel 10, you can follow these steps:

- Install Laravel 10.
- Configure the database.
- Create a model and configure migration.
- Create a file controller.
- Create routes.
- Create a blade file.
- Start the Laravel application.

Read More [Laravel 10 File Upload Example Tutorial](https://www.tutsmake.com/laravel-10-file-upload-tutorial)
How to Convert a Word Document into Images Using the Syncfusion Word Library
Tags: webdev, dotnet, csharp
Published: 2023-09-08 11:13:09

Learn how to convert a Word document into images using the Syncfusion Word Library. This video demonstrates how to convert entire pages in a Word document into images. It also shows you how to convert a specific range of pages or just the first page into images. 

The Word Library (Essential DocIO) is a native .NET Word library used by developers to create, read, write, and convert Microsoft Word documents. It is a non-UI component that provides a full-fledged document instance model similar to the Microsoft Office COM libraries to iterate with the document elements explicitly and perform necessary manipulation. All the elements of a typical Word document like text, formatting, images, tables, sections, headers, and footers are accessible through a comprehensive set of APIs. It only takes a few lines of code to create or manipulate richly formatted Word documents. 

Create fillable forms with legacy form fields in Word documents for users to complete or print. Create more functional forms with content controls like plain text, rich text, pictures, check boxes, combo boxes, drop-down lists, date pickers, etc., in Word Open XML Format document. 

Design reports using Microsoft Word and use Word Library to dynamically populate them with data. Create, read, and edit popular text file formats like DOC, DOT, DOCM, DOTM, DOCX, DOTX, HTML, RTF, TXT, and XML (WordML). 

Convert Word documents to PDF, image (PNG, BMP, JPEG), and ODT files. A comment is a note or annotation that an author or reviewer can add to a document. Also, edit and remove an existing comment from a document. Accept and reject changes that are tracked within a Word document. 

**Product overview:** https://www.syncfusion.com/document-processing/word-framework/net

**Explore our tutorial videos:** https://www.syncfusion.com/tutorial-videos

{% youtube hoV3i7nl85I %}
Boost Your Confidence and Score High with Reliable Exam Dumps Websites: Unbiased Reviews for Successful Students
Published: 2023-09-08 11:12:52

These are much more complex scenario-based questions so knowing the format, style, and difficulty before you take the real exam is a massive advantage. Why use AWS Solution Architect Associate dumps when you can find high-quality training materials at inexpensive prices and smash your exam legitimately? Another problem with dumps is that they can really trip you up. Many Best Exam Dumps Websites Reviews have not identified the correct answer and the explanations can often be misleading. On some sites, people get the chance to [Best Exam Dumps Websites Reviews](https://examtopicsfree.com/other-exams/best-exam-dumps-websites-reviews/) comment, and often lots of people just reaffirm whatever the first commenter chose (even if it was wrong). Also, AWS exams change all the time. New questions are added constantly and slight variations of existing questions are made. So you absolutely need to know the subject matter if you want to pass your exam. Lastly, the main reason to get a certification is to get a job or promotion. With AWS certification you’re going into an extremely competitive profession and you really need to be able to demonstrate a strong skill set to get hired or move within your company. 

Click Here More Info: https://examtopicsfree.com/other-exams/best-exam-dumps-websites-reviews/
SEARCH RESULTS SHOULD BE ARRANGED ACCORDING DATE
Published: 2023-09-08 11:09:35

I noticed that search engine results are not arranged according to date or the latest information on the subject.

For example, "latest iphone" search will give you links to information on iphone releases. But the links are not arranged by date they were posted. 

The first link will take you to 2005 release while the second link will take you to tomorrow's release.

With this issue, you might get an information that is old and dead, when a new information already exists.

For those of us who use desktop computers often, we have noticed that arranging information accoding to date it was put on the computer is relevant.

This issue I have also noticed on youtube. Youtube results are probably arranged according to views or some other criteria, 

and not by how recent the video was posted. Therefore you might watch a video that gives you an old information when the new information already exists.

I believe that making it possible to view results according to the latest information might be useful, especially for students and technology buyers.
Problems with django-admin function?
Tags: webdev, django, newbie, beginners
Published: 2023-09-08 11:07:59

Django is basically a backend framework that utilizes Python as its main language to integrate with front-end web development.
[More info about Django here](https://www.djangoproject.com/)

Using Django as a newbie can be tough. So much new stuff to do as well as new terms to understand. And nothing hurts more than starting a new language and being hit with..... **_an error message_**. 

Many Django users know that to start Django, you need to first install it under Python with "pip". Now after installation, to use Django you need to create a project. The **project** is the entire directory/folder. Within the project, one can now create an **app** which is basically the application that will be used in your website. The project-app relationship is sort of similar to a folder-file relationship, where apps make up the files and project the folder.

So to create a new Django project, navigate to your desired directory in your terminal or Command prompt using 'cd'. Now here is where the problem may arise. The standard code for creating the Django project is 

```
django-admin startproject PROJECT_NAME
```
where the PROJECT_NAME is the desired name for your project. Now, if it this goes well for you, Hallelujah. But some of us may be unfortunate to be hit with this:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxoxqegpsyphfx1r6jb7.png)
Now don't panic, that is the purpose of this article. I asked Bing AI for any debugging tips and [here was the response](https://sl.bing.net/gLB2FgE3zAO)
Still I found no help. So I experimented for a while and tried this

```
python -m django startproject article
```

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

AND IT WORKED!!

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

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

**NOTE: This was tested in Windows OS.**

In a nutshell, I have explained a little bit of how to fix a minute Django problem and also how to understand a bit of Django. I hope you enjoyed this. Please share and Happy Dev'ing
Laravel 10 Ajax Crop and Upload Image using Croppie js
Tags: laravel, ajax, croppiejs, image
Published: 2023-09-08 11:07:49

Using croppie js in laravel 10, you can integrate Croppie.js with Laravel to allow users to upload and crop images on your web application. This can be useful for various purposes, such as profile pictures, cover photos, or any situation where precise image cropping is required.


## Laravel 10 Ajax Crop and Upload Image using Croppie js

To crop and upload an image with Croppie js in Laravel 10, you can follow these steps:

- Install Fresh Laravel.
- Create a model.
- Connect to a database.
- Add routes to display the form for croppie view.
- Create a controller CropImageController.php.
- Create a new blade file croppie.blade.
- Add a Blade View File.
- Create a Controller File.

Read More [Laravel 10 Ajax Crop and Upload Image using Croppie js](https://www.tutsmake.com/laravel-10-crop-upload-image-using-jquery-ajax)
Testing React App: Introduction
Published: 2023-09-07 20:33:10

The main reason why we need to test is to test whether the app behaves as expected on not. Apps may have  some errors which we may not discover but using react test library in the best solution.

React Testing is grouped into 3 categories.

 **1. Unit Test**
- whereby we test a single  a component.

 **2. Integration test**
- whereby we test multiple components

**3. End to End test (E2E)**
- where we test the whole App from Frontend-Backend.

Let's dive into :

 **Unit test**
1. Select a component you would like to test.
2. Copy and paste the name of that component. In my case the name of the my component is 
`PayButton`
 The name of the file is 
`PayButton.jsx`
and after pasting I will rename the file to `PayButton.test.js` 
3. You need to add the description of what you what to test in that test file(`PayButton.test.js`).
4. You need to import the component into that test file too.

Below is how my test file looks like `PayButton.test.js`



```
import {render, screen} from "@testing-library/react"
import PayButton from "./PayButton"

test('on initial render, the pay button is disabled,', () =>{

render(<PayButton/>);

screen.debug();
}
)

```

Once you are done, you now go to terminal and run the command



```
npm test
```

if you are using `npm `




```
yarn test
```


if you are using `yarn`.

You can also fix the errors in that test file too in that test file depending on the errors you are seeing.

Let's move on to **Integration** testing