teleren/devto huggingface dataset:
onClick={someFunction} VS onClick={()=>someFunction}
Tags: react, webdev, javascript, reactjsdevelopment
Published: 2024-06-22 03:26:45

The difference between `onClick={someFunction}` and `onClick={() => someFunction}` in React (or JavaScript in general) lies in how and when they handle the execution of the `someFunction` when the click event occurs :

### `onClick={someFunction}`

- **Direct Reference**: This syntax directly references the function `someFunction`.
- **When Clicked**: The function `someFunction` will be called when the `onClick` event is triggered (e.g., when the element is clicked).
- **No Extra Function Call**: No additional function is created; React simply uses the function reference you provided.
- **Example**: If `someFunction` is defined as `function someFunction() { console.log('clicked'); }`, then `onClick={someFunction}` will log 'clicked' when the element is clicked.

### `onClick={() => someFunction()}`

- **Arrow Function**: This syntax uses an arrow function to call `someFunction`.
- **Creates a New Function**: Each time the component renders, a new function is created. The arrow function wraps the call to `someFunction`.
- **Immediate Invocation**: Within the arrow function, `someFunction` is called immediately when the `onClick` event is triggered.
- **Use Case**: Useful when you need to pass arguments to the function or need to do additional work before calling `someFunction`.
- **Example**: If you want to pass an argument to `someFunction`, you can use `onClick={() => someFunction('argument')}`. This will call `someFunction` with 'argument' when the element is clicked.

### When to Use Each

- **Direct Reference (`onClick={someFunction}`)**:
    - Use this when you want to avoid creating an extra function on each render, which can be more efficient.
    - Preferable for simple event handlers where no additional arguments or operations are needed.
- **Arrow Function (`onClick={() => someFunction()}`)**:
    - Use this when you need to pass arguments to the function or perform additional operations before calling the function.
    - Useful for inline operations or when dealing with closures.

### Practical Examples

### Direct Reference

```jsx
function handleClick() {
  console.log('Button clicked');
}

<button onClick={handleClick}>Click Me</button>

```

- `handleClick` will be called directly when the button is clicked.

### Arrow Function

```jsx
function handleClick(message) {
  console.log(message);
}

<button onClick={() => handleClick('Button clicked')}>Click Me</button>

```

- The arrow function calls `handleClick` with the argument 'Button clicked' when the button is clicked.

Understanding these differences helps in optimizing performance and achieving the desired behavior in React components.
AddGraph supports straight line connection, curve connection, and polyline connection
Published: 2024-06-22 03:05:16


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

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

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

[demo](https://addgraph.com/biglargemodelmath)
HackerRank Challenges
Tags: javascript, beginners, help
Published: 2024-06-22 03:00:36

I'm trying other websites to exercises DSA and I started with HackerRank, 10 days of JavaScript. In this journey my focus is to spend the necessary time to think, search and solve the problems, without being so fixed with deliver challenges in the right days.

Also, I'd like some help with a basic problem with loop:
[10 Days of JavaScript - Day 2](https://www.hackerrank.com/challenges/js10-loops/problem) (In the link you can check the problem and the see the complete code).
The main problem is to complete the vowelsAndConsonants function that print each vowel in  on a new line in the same order as it appeared and after do the same thing for consonants too.

What I did was start with an array storing the vowels and separe in two parts, vowels and not vowels. 
In the for loop I started a counter that started at zero, was smaller than the size of the string that the user would provide and the step would be i = i + 1. Then I ask console.log to display the string entered by the user within the function conditions according to the for loop.

```
function vowelsAndConsonants(s) {
    let vowels = ['a', 'e', 'i', 'o','u'];
    
    for(let i=0; i<s.lenght; i++){
    if(vowels.includes(s[i]))
    console.log(s[i]);
    }
    
    
    for(let i=0;i<s.lenght;i++){
    if(!vowels.includes(s[i]))
    console.log(s[i]); 
    }

}
```

input:

```
javascriptloops

```
my output:

```
~ no response on stdout ~

```
expected output:

```
a
a
i
o
o
j
v
s
c
r
p
t
l
p
s
```

In the exercise itself there is a main function that calls the function vowelsAndConsonants and captures what the user types.
But I'm not understanding what I'm doing wrong for my output don't return anything. Someone can help me?
"Blockchain Unleashed: The Cat Diary Chronicles"
Tags: devchallenge, cschallenge, computerscience, beginners
Published: 2024-06-22 02:56:29

*This is a submission for [DEV Computer Science Challenge v24.06.12: One Byte Explainer](https://dev.to/challenges/cs).*

## Explainer

<!-- Explain a computer science concept in 256 characters or less. -->

Blockchain is a digital cat diary. Every time Mittens the cat eats, naps, or chases a laser, a secure, unchangeable entry gets added. Everyone agrees Mittens did those things, and no one can sneak in a fake entry claiming Mittens did their homework!

## Additional Context

Using humor engages the audience, making the explanation memorable and more likely to be shared or discussed.
"Blockchain Unleashed: The Cat Diary Chronicles"
Tags: devchallenge, cschallenge, computerscience, beginners
Published: 2024-06-22 02:56:26

*This is a submission for [DEV Computer Science Challenge v24.06.12: One Byte Explainer](https://dev.to/challenges/cs).*

## Explainer

<!-- Explain a computer science concept in 256 characters or less. -->

Blockchain is a digital cat diary. Every time Mittens the cat eats, naps, or chases a laser, a secure, unchangeable entry gets added. Everyone agrees Mittens did those things, and no one can sneak in a fake entry claiming Mittens did their homework!

## Additional Context

Using humor engages the audience, making the explanation memorable and more likely to be shared or discussed.
การสร้างผู้ใช้งาน และให้สิทธิความเป็นเจ้าของฐานข้อมูล PostgreSQL บน Ubuntu
Published: 2024-06-22 02:39:23

บทความนี้จะแสดงการสร้างผู้ใช้งาน และให้สิทธิความเป็นเจ้าของฐานข้อมูล PosgreSQL ผ่าน command line บน Ubuntu Linux

> วิธีดังกล่าวสามารถนำไปใช้กับ PostgreSQL ที่ติดตั้งในระบบปฏิบัติอื่นๆได้

เมื่อเราติดตั้ง PostgreSQL ในครั้งแรกจะมีผู้ใช้งานเบื้องต้นชื่อ postgres ซึ่งจะเป็นเจ้าของฐานข้อมูลทุกตัวที่สร้างขึ้นมา ในกรณีที่ เราสรา้งระบบที่ต้องการใช้งานฐานข้อมูล เราต้องใช้ผู้ใช้งาน postgres ในการเข้าถึงฐานข้อมูล ซึ่งถ้ารหัสผ่านหลุด อาจทำให้ผู้ไม่หวังดีสามารถเข้าถึงทุกฐานข้อมูลได้
เราจึงต้องสร้างผู้ใช้งาน และมอบสิทธิความเป็นเจ้าของให้ฐานข้อมูลนั้นเพื่อให้สามารถเข้าถึงฐานข้อมูลนั้น และในกรณีที่รหัสผ่านของผู้ใช้งานนั้นหลุดก็มีผลกระทบแค่กับฐานข้อมูลนั้น

## การสร้างผู้ใช้งานใหม่บน PostgreSQL
1.เข้าใช้งาน psql เพื่อเข้าใช้งาน PostGreSQL ผ่าน command line ที่ terminal ใน Ubuntu พิมพ์
```bash
# sudo -u postgres psql
```  
จะเข้าสู่ shell ของ postgres
```bash
postgres-#
```
2.แสดงรายการผู้ใช้งานใน PostgreSQL ผ่านคำสั่ง
```bash
postgres-# \du หรือ \du+ 
```
จะแสดงรายชื่อผู้ใช้งานในฐานข้อมูล

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

3.สรา้งผู้ใช้งานชื่อ demo โดยกำหนดรหัสผ่านเป็น demo1234 ผ่านคำสั่ง SQL
```sql
postgres-# CREATE USER demo WITH PASSWORD 'demo1234';
```
เมื่อใช้คำสั่ง \du จะพบชื่อผู้ใช้งาน demo ที่สร้างขึ้นใหม่
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z64395mc4gkh76qkupk5.png)

## การมอบสิทธิเจ้าของฐานข้อมูลให้ผู้ใช้งานที่สร้างขึ้น
1.สรา้งฐานข้อมูล demodb ผ่านคำสั่ง SQL
```sql
postgres-# CREATE DATABASE demodb;
```
2.มอบทุกสิทธิในฐานข้อมูล  demodb ให้กับผู้ใช้งาน demo ผ่านคำสั่ง
```sql
postgres-# GRANT ALL PRIVILEGES ON DATABASE demodb TO demo;
```
3.มอบสิทธิความเป็นเจ้าของ demodb ให้กับผู้ใช้งาน demo ผ่านคำสั่ง
```sql
postgres-# ALTER DATABASE demodb OWNER TO demo;
```
4.ตรวจสอบความเป็นเจ้าของฐานข้อมูล โดยใช้ \l แสดงรายชื่อฐานข้อมูล
```bash
postgres-# \l
```
ในรายชื่อฐานข้อมูล demodb ที่คอลัมถ์ Owner จะแสดงค่าเป็น demo
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/khorymah629uwu44oake.png)

> **<u>หมายเห</u>**ตุ เราสามารถสร้างฐานข้อมูลพร้อมกำหนดเจ้าของได้ในคำสั่งเดียวผ่าน
>```sql
>postgres-# CREATE DATABASE demodb WITH OWNER demo;
>```
>จะเป็นการสรา้งฐานข้อมูล demodb พร้อมกับกำหนดเจ้าของเป็น demo ในคำสั่งเดียว
ADRIAN LAMO HACKER - RECOVERY SOLUTION FOR STOLEN CRYPTO ASSETS
Published: 2024-06-22 02:12:19

Losing access to my bitcoin wallet with 50,000 GBP due to misplacing my private keys was a distressing experience. The realization that my hard-earned funds were seemingly irretrievable left me feeling helpless and anxious. However, my despair turned to hope when I discovered Adrian Lamo Hacker, a reputable firm specializing in assisting individuals in recovering lost cryptocurrency assets.Upon reaching out to Adrian Lamo Hacker and sharing the details of my predicament, I was met with a swift and empathetic response. Their team of experts demonstrated a deep understanding of the complexities involved in recovering assets from lost private keys and immediately set to work on devising a strategy to help me reclaim my bitcoins. Throughout the process, their efficiency, and dedication were truly remarkable. They provided me with regular updates, guidance  instilling a sense of confidence and reassurance during what had initially seemed like an insurmountable ordeal. Thanks to their diligent efforts, I was able to recover a significant portion of my lost funds—a result that surpassed my expectations and brought immense relief during a tumultuous time. Adrian Lamo Hacker's unwavering commitment to helping individuals in need was instrumental in turning what initially seemed like a hopeless situation into a success story. I highly recommend Adrian Lamo Hacker services to anyone facing a similar situation Telegram: @ADRIANLAMOHACKERTECH / Email: Adrianlamo@consultant.com  . Their expertise in recovering lost cryptocurrency assets, combined with their exceptional professionalism and dedication, make them a trusted partner for anyone seeking assistance in reclaiming their funds.This has served as a poignant reminder of the importance of safeguarding private keys and exercising caution when managing cryptocurrency assets. Moving forward, I am committed to implementing robust security measures to prevent the loss of access to my digital wallets and seeking professional guidance to ensure the security of my assets.I am deeply grateful for Adrian Lamo Hacker in helping me recover a significant portion of my lost bitcoins. Their exemplary service has not only restored my financial security but has also provided me with peace of mind amidst a distressing experience. I am immensely thankful for their unwavering dedication and would not hesitate to recommend their services to anyone in need of assistance in recovering lost cryptocurrency assets. Website: https://adrianlamohackpro.online/
WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowxz
Tags: javascript, webdev, react, computerscience
Published: 2024-06-22 01:56:16

WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowldjeu
WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowki
Tags: webdev, javascript, programming, beginners
Published: 2024-06-22 01:53:56

WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call now
WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowoi
Tags: javascript, webdev, beginners, programming
Published: 2024-06-22 01:46:47

WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call now
WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call now
Tags: webdev, programming, react, ai
Published: 2024-06-22 01:44:41

WealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call nowWealthsnaP loAn app custOmer care helpline number +91)9030860074-}8961038445 call now
Pseudocode/Python Project
Tags: beginners, webdev, python
Published: 2024-06-22 01:02:58


Hey All.
I am writing a program that uses conditionals as well as a while loop.
I am running into problems with the while loop.
The loop is set to run if the user doesn't enter 'yes' or 'no' when asked whether they would like to make a payment. No matter where I try to place the loop it seems to get stuck if I enter anything other than 'yes' or 'no' then enter either 'yes' or 'no' after the loop.
It seems that if I try to catch someone not entering either of the two acceptable entries the program gets stuck.
```
def Credit_card():
    ccb=float(input("What is your credit card balance?\n"))
    pur=float(input("How much have you spent in purchases?\n"))
    minpymt=pur*.12
    print("Your minimum payment is ${0}".format(minpymt))
    dectopay=input("Would you like to make a payment?\n Please type 'yes' or 'no'\n")
    if (dectopay=="yes"):
        pymt=float(input("Wonderful! How much would you like to pay?\n"))
        while(pymt<minpymt):
          pymt=float(input("We're sorry, but your payment must be greater than or equal to your minimum payment of ${0}\nHow much would you like to pay?\n").format(minpymt))
        print("Thank you for your payment!\n")
        print("Your new credit card balance is ${0}\n".format((ccb+pur)-pymt))     
    elif(dectopay=="no"):
        print("Your credit card balance is ${0}. Thank you for visiting Credit Central. \n Have a wonderful day!".format(ccb+pur))
    while (dectopay!="yes")or(dectopay!="no"):
            dectopay=input("We're sorry. You must answer either 'yes' or 'no'\n")
    

           
    
Credit_card()

          
```
Building Custom PCs for Developers: Three Different Approaches
Tags: productivity, devtoys, webdev, custompc
Published: 2024-06-22 01:00:59

When it comes to building a custom PC for development work, there are several factors to consider. The ideal setup varies depending on the types of development work you do, your budget, and your personal preferences. In this article, we’ll explore three different approaches to building a custom PC for developers: a budget-friendly option, a mid-range powerhouse, and a high-end beast.

👀 ===> [Building Custom PCs for Developers: Three Different Approaches](https://devtoys.io/2024/06/21/building-custom-pcs-for-developers-three-different-approaches/)
How To Create And Connect To A Linux Virtual Machine Using A Public Key
Tags: virtual, microsoft, system, technology
Published: 2024-06-22 00:17:21

To do this effectively, you must follow the below steps; 




**1. Sign up to Azure portal**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9vx3xtf4rm5p0qxmlyuc.png)

**2. Click on Virtual Machine**

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

**3. Click on Create**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1wg2azb4hi1v6dwtdfo.png)
**

**4. On the dropdown. click Azure Virtual Machine**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bs8xlo8lar95709bvuwx.png)
 
**5.** Under the **Project details**, make sure the right subscription is selected and then choose to **Create new** resource group and enter LinuxVm

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

**6.**Under **Instance details** enter LinuxVm for the  **Virtual Machine Name**, and choose Ubuntu Server 20.04 LTS-x64 Gen2 (free services eligible) for your **Image**.  Choose No infrastructure Redundancy required  for **Availability Option**, Select Standard for **Security Type**  and leave the other defaults

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

**7.** Under **Administrative account**, select **Password**
**8.** In Username, enter Moderntech
**9.** Input your Password

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c64z3uud49pxfmy9rav3.png)
**10.** At the **Inbound port rule**, choose **Allow selected ports** on the Public inbound port

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

**11.** Review + Create
This is for validation to take place

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlw8gyd7kfe0ckuvxpft.png)
**12. ** Create.
This is to complete the deployment

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dd5riud7lx9kr2wxu5jg.png)
**13.** Click on Resource

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

**14.** Connect to powershell
Any opinions on this new AI powered mutation testing tool?
Tags: opensource, discuss, webdev, python
Published: 2024-06-21 23:44:02

I read a [Medium](https://medium.com/codeintegrity-engineering/transforming-qa-mutahunter-and-the-power-of-llm-enhanced-mutation-testing-18c1ea19add8) article about this software testing [tool](https://github.com/codeintegrity-ai/mutahunter) that uses AI. I’m curious to know if someone with deep experience in software testing would use a tool like this.
I just created a simple & stupid notepad (Looking for advice)
Tags: csharp, help, programming, beginners
Published: 2024-06-21 23:39:22

Salam (Peace) everyone! I've recently started learning C# coding. After mastering the basics and console apps, I've moved on to GUI using WinForms to gain more experience and develop my skills in C#. I hope someone here can assist me in developing this notepad application. I'm facing several issues, particularly with the find & replace feature. I've tried numerous times, but unfortunately, it's not working for me :( Your help would be greatly appreciated. Thank you!

GitHub: https://github.com/DZ-T/Notepad


I just code new version with better functions. I faced a problem in replace & find so i delete the code till i find a solution Thanks again. Let's make this Notepad less "stupid" and more awesome together!
How to create a resource group in Azure Portal
Tags: webdev, beginners, tutorial, productivity
Published: 2024-06-21 23:32:45

**What is a Resource group?**: A resource is a logical container for housing our resources in Azure.

**Here are the steps to create one in Azure**

Step1: Search for resource in the search resource, documents& services field and click enter

![step1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ergr54gxwttm9za1zbam.png)

Step2: Click on the + create button

![step 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1f34t4fdu8gx71szsft6.png)

Step 3: On the basics tab, fill in the project details which comprises of the resource and the subscription

![step 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gl0egy52azkr5uotn7rk.png)
Rush Mommy
Published: 2024-06-21 23:31:28

RushMommy **<a href=https://rushmommy.com/wordpress-hosting/>WordPress hosting</a>** provides a streamlined experience with features like rapid load speeds, robust security protocols, and easy site management tools. Their hosting solutions cater to both beginners and advanced users, offering one-click WordPress installations, automatic updates, and comprehensive customer support. Designed to handle high-traffic websites and online stores, RushMommy ensures reliability and scalability, making it a top choice for those looking to enhance their digital footprint.