teleren/devto huggingface dataset:
CRUD Operations in PostgreSQL: A Step-by-Step Guide
Tags: postgressql, webdev, database, beginners
Published: 2024-06-05 17:26:07


CRUD operations are the fundamental actions that can be performed on data in a database. They are the building blocks of database management and are essential for managing and manipulating data in a database.

Why is PostgreSQL Important?

PostgreSQL is a powerful and flexible database management system that is widely used in many industries. It is known for its reliability, scalability, and ability to handle large amounts of data.


Here is a step-by-step guide to performing CRUD operations in PostgreSQL:

1.Create: Insert new data into a PostgreSQL database using the 
 `INSERT` command.

2.Read: Retrieve existing data from a PostgreSQL database using the 
 `SELECT` command.

3.Update: Modify existing data in a PostgreSQL database using the 
 `UPDATE` command.

4.Delete: Remove data from a PostgreSQL database using the `DELETE` 
  command.


Mastering CRUD operations in PostgreSQL is an essential skill for any developer. By following this step-by-step guide, you'll be able to effectively manage your data and take your database management skills to the next level.

Read the Full Blog on hashnode:

[CRUD operations in PostgreSQL](https://jaygupta.hashnode.dev/crud-operations-in-postgresql-a-step-by-step-guide)
MANUAL TESTING
Published: 2024-06-05 17:23:51

MANUALTESTING:
Manual testing is a technique to test the software that is carried out using the functions and features of an application . In manual software testing, a tester tests the software by following a set of predefined test cases. In this testing ,testers make test cases for the codes, test the software ,and give the final report about that software. 
 
Characteristics of MANUAL TESTING:
1. Human performance
2. Investigative Testing
3. Flexibility
4. Initial testing
5. Examining complex situations
6. Testing User interfaces

Need for Manual Testing:
1. Bug-free and stability(stable ,requirement& delivers a stable product to the customers)
2. Familiarity(write correct test cases for the software)
3. Fixing the defects

Manual testing process:
Unit testing:
Unit Testing is also called Module Testing or Component Testing. It is done to check whether the individual unit or module of the source code is working properly. 
 
Integration testing:
Integration Testing is the process of testing the interface between the two software units. 

Regression testing:
Repeated testing of an already tested program, after modification, to discover any defects introduced or uncovered as a result of the changes in the software being tested or in another related or unrelated software components.
user interface testing:
security testing:
performance &acceptance testing:

Example: car is a software
Unit testing-->Engine

Types of Manual testing:
1.Black Box Testing:
Black Box Testing is a software testing method in which testers evaluate the functionality of the software under test without looking at the internal code structure. This can be applied to every level of software testing such as Unit, Integration, System and Acceptance Testing. 

2.White Box Testing:
White Box Testing is also called as Glass Box, Clear Box, and Structural Testing. It is based on applications internal code structure. In white-box testing, an internal perspective of the system, as well as programming skills, are used to design test cases.

3.Grey Box Testing:
Grey box is the combination of both White Box and Black Box Testing. The tester who works on this type of testing needs to have access to design documents. This helps to create better test cases in this process.

Benefits of manual testing:
1.Fast and accurate visual feedback(detects almost every bug in the software application)
2.Less expensive(specific type of tool)
3.No coding is required(black box testing method using)
4.Efficient for unplanned changes

Drawbacks of manual testing:
1.Less reliable(not provide testing on all aspects testing)
2.Can not be reused(separate test cases for new software)
3.Time -consuming
4.Large human resources required
How to Create a Web Crawler with Puppeteer and Bun
Tags: webdev, javascript, programming, tutorial
Published: 2024-06-05 17:13:36

Web crawling is a powerful technique used to gather data from websites. Whether you're collecting data for research, monitoring prices, or scraping content, building a web crawler can be incredibly useful. In this post, I'll walk you through the process of creating a web crawler using Puppeteer and Bun, two popular JavaScript tools.

### Introduction to Puppeteer and Bun
Puppeteer is a Node.js library that provides a high-level API to control headless Chrome or Chromium browsers. It's perfect for web scraping and automating browser tasks.

Bun is a fast, modern JavaScript runtime similar to Node.js but optimized for speed and performance. It's designed to work seamlessly with existing JavaScript libraries.

### Step-by-Step Guide to Building a Web Crawler
**Step 1**: Setting Up Your Environment
First, ensure you have Node.js installed. Then, install Bun by following the instructions on the Bun website.

Next, create a new project directory and initialize it with Bun:

```sh
# Copy code
mkdir web-crawler
cd web-crawler
bun init
```
**Step 2**: Installing Puppeteer
Install Puppeteer using Bun:

```sh
# Copy code
bun add puppeteer
bun node_modules/puppeteer/install.js # -> the secret sauce 
```

**Step 3**: Writing the Web Crawler Script
Create a new JavaScript file, crawler.js, and start by importing Puppeteer:

```javascript
// Copy code
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');

  // Extract data
  const data = await page.evaluate(() => {
    return document.querySelector('h1').innerText;
  });

  console.log(data);

  await browser.close();
})();
```

In this script, we launch a headless browser, navigate to a website, and extract the text of an <h1> element.

**Step 4**: Running the Script
Run your script using Bun:

```sh
## Copy code
bun run crawler.js
## You should see data printed in your terminal.
```

### Conclusion
Creating a web crawler with Puppeteer and Bun is straightforward and efficient. Puppeteer handles the browser automation, while Bun provides a fast and modern runtime for your JavaScript code. This combination makes for a powerful tool in your web scraping toolkit.

For more advanced use cases, you can extend your script to handle navigation, interact with page elements, and scrape more complex data structures. Happy crawling!

#### About the Author

I am Ian, a practiced computer programmer with a strong interest in website design and automation. I have worked extensively with Web Technologies and always follow the latest in technological advancements enabling me to help others create effective scalable applications.
Starting of a new Chapter
Tags: linux, opensource, ubuntu, unix
Published: 2024-06-05 17:06:25

Just started my new session on Linux operating system. Had my first session today with one of my colleague around how Linux came into existence. How a problem to buy the driver for a printer led to creating a whole new world of open source. How people were restricted to using proprietary software where they were not able to do the changes. Different group of people came together from different parts of the world, some build the code some build the kernel and together they called it **Linux GNU** . Well!! that was all for the basic session. See you fellas tomorrow with something new.
Footer UI Example | ReadymadeUI
Tags: readymadeui, footerui, ui, webdesign
Published: 2024-06-05 16:52:09


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


## Stylish Footer with Gradient

This beautifully designed footer built with Tailwind CSS, featuring a gradient background that creates a visually appealing base. It includes two key sections:

**Newsletter Signup**: A prominent newsletter signup form at the top, allowing visitors to easily subscribe for updates.

**Informative Links**: The bottom section provides clear and concise internal links to important pages like "Services," "Resources," and "About Us." A copyright notice is also included at the bottom.

**Hover Effect for Interaction**: Links change color on hover, adding a touch of interactivity and user feedback.

**Responsive Design**:  The footer utilizes a responsive grid layout that automatically adjusts to a single column on mobile screens.

**[Demo and code](https://readymadeui.com/tailwind-components/footer)**
Difference between Asynchronous Javascript and Synchronous Javascript
Tags: javascript, webdev, beginners
Published: 2024-06-05 16:39:51

Synchronous JavaScript:
In synchronous JavaScript, code is executed sequentially, one line at a time. Each operation blocks the execution of subsequent operations until it completes. This means that if one operation takes a long time to finish, it can delay the execution of other operations, potentially causing the application to become unresponsive. Synchronous code is straightforward to read and write, as it follows a linear flow, making it easier to reason about the program's behavior.

Asynchronous JavaScript:
On the other hand, asynchronous JavaScript allows code to run independently of the main execution thread. Asynchronous operations, such as fetching data from a server or waiting for a user input, are initiated, but the program doesn't wait for them to finish before moving on to the next operation. Instead, it registers a callback function to be executed once the asynchronous task is complete. This non-blocking behavior ensures that the application remains responsive, even when performing time-consuming tasks.

Example:
Consider the scenario of fetching data from a server. In synchronous JavaScript, the code would wait for the server to respond before proceeding with any other tasks, potentially causing the application to freeze until the data is received. However, in asynchronous JavaScript, the code would initiate the data-fetching operation and continue executing other tasks while waiting for the server's response. Once the data is available, a callback function would be invoked to handle the retrieved data, allowing the application to remain responsive throughout the process.

Benefits of Asynchronous JavaScript:
- Improved performance: Asynchronous operations prevent the main execution thread from being blocked, resulting in a more responsive user experience.
- Better utilization of resources: By allowing multiple tasks to run concurrently, asynchronous JavaScript maximizes the utilization of CPU and memory resources.
- Enhanced scalability: Asynchronous programming is essential for handling large-scale applications that require concurrent processing of multiple tasks, such as web servers and real-time applications.

In summary, synchronous JavaScript executes code sequentially, blocking subsequent operations until each one is completed, while asynchronous JavaScript allows code to run independently, registering callback functions to handle tasks once they're finished. Understanding the differences between synchronous and asynchronous JavaScript is crucial for building efficient and responsive web applications.
Array / Array Method / Function
Published: 2024-06-05 16:25:41


1-**Array**
2-**Array Method**
3-**Function**


**Array**:
JavaScriptda array, ma'lumotlarni to'plab borish uchun ishlatiladigan turli hil ma'lumotlardan iborat bo'lgan o'zgaruvchan turidir. JavaScriptning barcha elementlari ko'rsatkich index orqali chaqiriladi va 0 dan boshlab hisoblanadi. Array ichiga birma-bir ma'lumotlarga indekslar orqali murojaat qilish mumkin.

Array shu ko'rinishda yaratilishi mumkin:

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

Arrayning indexi quydagicha hisoblanadi
JavaScriptda array elementlariga murojaat qilish uchun, ularning indeksini yozish kerak. Indeks 0 dan boshlanadi:

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


**Array Metodlari**:
JavaScriptda arraylarni boshqarish uchun ko'p qo'llaniladigan metodlar mavjud, masalan, .push(), .pop(), .shift(), .unshift(), .slice() va boshqalar. Bu metodlar orqali siz arrayning ichidagi ma'lumotlarni qo'shishingiz, o'chirishingiz, o'zgartirishingiz va boshqalarini bajarishingiz mumkin.

Array metodlarining ishlatilishi:

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

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


**Functions** Funksiyalar:

Javascriptdagi barcha funksiya turlari;

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

javascriptda ko'p ishlatiladigan va asosiy funksiyalar bu function declaration,function expressions,arrow function:

**Function Declaration** quydagicha ko'rinishda

```
// Function Declaration


function sayHello(){
    alert("Salom!");
}

sayHello();

```
Function declaration boshqa funksiyalardan farqi,funksiyani o'zidan yuqorida ham o'zidan keyin ham chaqirish mumkin.

```
// Function Declaration


sayHello();

function sayHello(){
    alert("Salom!");
}


```

**Function expressions** quydagiya korinishda

```
// Function Expression
const app=function(a,b,c){
cansole.log(a,b,c);
}

app(1,12,11)

```

Function Expression o'zidan yuqorida chaqirilmaydi,funksiyani faqatgina o'zidan keyin chaqirish mumkin.

```
// Function Expression

const app=function(a,b,c){
cansole.log(a,b,c);
}

const Funct=app; <== //o'zgaruvchi chaqiriladi

Funct(23,32,43) <== o'zlashtiriladi
app(1,12,11)

```

Function Expression funksiyasida o'zgaruvchi bilan qiymatini o'zlashtirish mumkin.


**Arrow Function** quydagicha ko'rinishda

```
// Arrow Function

const ArrowFunction=(a,b,c)=>{
cansole.log(a,b,c)
}

ArrowFunction(22,33,44)

```

Arrow Function funksiyasida o'zgaruvchi bilan qiymatini o'zlashtirish mumkin.
o'zidan yuqorida chaqirilmaydi!
Custom Magnetic Closure Boxes
Tags: custommagneticboxes, magneticlosureboxes, printingmagneticboxes
Published: 2024-06-05 16:18:06

Companies use **[magnetic Closure Boxes](https://www.clawscustomboxes.com/product/magnetic-closure-boxes/)** for product promotion. The neat touch of closure boxes makes them an exquisite choice for packing various items. Personalized closure boxes are durable and with any inventory and finishing options. Custom magnetic boxes are usually made from paper and are widely used in jewelry stores for better packing.

What can use these boxes to send classy quality to your corporate customers, friends, and loved ones? Custom Magnetic box packaging for wholesale is a type of rigid packaging that uses magnets to keep the box closed. Get high-quality decorative storage boxes with  Magnetic Closure Rigid Boxes at wholesale rates.

Buy **[Custom Magnetic Boxes](https://www.clawscustomboxes.com/product/magnetic-closure-boxes/)** at wholesale can be used as precious souvenirs and show your feelings to your recipients. These boxes, together with inserts, are used for delicate products that can transport over long distances. You can print personal information on boxes. However, designing and printing an excellent magnetic seal hard case requires professional expertise. These sturdy, Flip top magnetic closure boxes are customized to help your brand shine.
Manage your GET query parameters with a react hook
Tags: react, javascript
Published: 2024-06-05 16:15:55

For example, if I have this query  `/api/couriers?status[]=READ&status[]=SENT&status[]=UNREAD&urgency.value[]=0&urgency.value[]=25&importance.value[]=50&importance.value[]=25&importance.value[]=0&category.id[]=/api/categories/17&category.id[]=/api/categories/10&direction=incoming`

And I want to remove the "importance", add another filter I find this solution:

```javascript
import { useState } from 'react';

const useQueryParams = (initialState = {}) => {
  const [state, setState] = useState(initialState);

  const setProperty = (key, value) => {
    setState(prevState => ({
      ...prevState,
      [key]: value,
    }));
  };

  const addElement = (key, element) => {
    setState(prevState => {
      if (!prevState.hasOwnProperty(key)) {
        return {
          ...prevState,
          [key]: [element],
        };
      }

      if (!prevState[key].includes(element)) {
        return {
          ...prevState,
          [key]: [...prevState[key], element],
        };
      }

      return prevState;
    });
  }

  const removeElement = (key, element) => {
    setState(prevState => {
      const newArray = (prevState[key] || []).filter(item => item !== element);
      if (newArray.length === 0) {
        delete prevState[key]
      } else {
        return {
          ...prevState,
          [key]: newArray,
        };
      }
    });
  };

  const clear = () => {
    setState({})
  }

  return { state, setProperty, addElement, removeElement, clear };
};

export default useQueryParams;
```
How to Improve the Pull Request Process
Tags: pullrequest, programming, productivity, github
Published: 2024-06-05 16:11:00

The pull request (PR) process is essential but often disliked. Despite its critical role in maintaining code quality, many developers find it frustrating. Let's explore common issues and solutions to make PRs more effective and enjoyable.

## Common Issues with the PR Process

**1. Focusing on the Developer Rather Than the Code**

Reviewers often direct comments at the developer instead of the code. Using second-person pronouns like "you" or "your" can make comments seem personal and toxic. Instead, focus on technical aspects and the code itself.

**Solution:**
- Concentrate on the code, not the person.
- Avoid personal pronouns; use objective language.

**2. Skimming Through Reviews**

Large PRs often lead to superficial reviews. It's easy to overlook issues in big chunks of code.

**Solution:**
- Break down large PRs into manageable pieces.
- Allocate focused time (25-45 minutes) for thorough reviews.
- Encourage collaborative code ownership.

**3. Writing Ineffective Comments**

Comments can be subjective, unclear, and lack actionable outcomes.

**Solution:**
- Be objective: Explain why changes are needed with clear, factual reasoning.
-  Be specific: Point out exact lines or methods.
- Focus on outcomes: Use the Triple R pattern (Request, Rationale, Result).
- Labels for Comments:

    needChange: Minor changes.
    needRework: Major changes requiring discussion.
    nitpicks: Subjective comments that don't affect functionality.
    TODO: Conventional comments for future work.

Example: 

> Can we move this method to Class AX? Similar methods are in Class AX, consolidating them will streamline business logic processing.


**4. Not Being Your Own First Reviewer**

Authors should review their code before submitting it.

**Solution:**

- Use draft PRs to self-review and refine code.

**5. Not Using Automation**

Automation can catch lower-stakes issues before the review.

**Solution:**
- Implement linting, formatting tools, and static analysis.
- Ensure tests pass before submitting PRs.

**6. Unmanageable PRs**

Large, unfocused PRs are difficult to review.

Solution:
- Make PRs narrow and specific.
- Focus on atomic changes.
- Split large features into multiple smaller PRs.

**7. Treating PRs as Mystery Novels**

PRs should be clear and informative.

**Solution:**
- Provide context and a clear title.
- Explain the purpose and changes in the PR description.

**8. Taking Feedback Personally**

Feedback is an opportunity to improve, not a critique of your abilities.

**Solution:**
- Embrace feedback as a team effort to enhance code quality.



## Additional Tips
- Create a Team Working Agreement: Define coding conventions and processes, and establish a "definition of done."

- Use PR Templates: Standardize PR descriptions for clarity.

- Auto-Assign Reviewers: Ensure timely reviews.
- Celebrate Code Complements: Recognize good work.

By addressing these issues and implementing these solutions, we can improve the PR process, making it more efficient and less stressful for everyone involved.
Glam Up My Markup: Beaches
Tags: frontendchallenge, javascript, beginners, css
Published: 2024-06-05 16:06:06

This is a submission for [Frontend Challenge v24.04.17]((https://dev.to/challenges/frontend-2024-05-29), Glam Up My Markup: Beaches

## What I Built
First CSS/Javascript challenge that I participate here. just a very simple slider animation with some pictures and videos to introduce those beautiful beaches. Enjoy!
## Demo
Repo:
https://github.com/wangtienp/challenges/tree/main/front-end-june-challenge

website url:
https://wangtienp.github.io/challenges/front-end-june-challenge/
Replacing the internal tooling we used at Meta (Facebook)
Tags: startup, tooling
Published: 2024-06-05 15:42:47

## A common startup dilemma

As an early-stage startup, you can afford to spend time building things that are not core to your product.

This might be controversial, but my experience has been to pick and choose the battles you want to face.

While all startups are different, we eventually encounter a common dilemma: "Do you buy a solution or build one yourself?"

Some startup teams opt for the scrappy approach, building in-house tools/ finding an open-source solution, while others default to buying a SaaS vendor.

Statsig was no different. However, since the founding engineering team were all ex-Meta (Facebook), they looked to replace the tooling they used before.

## Sharing your tech stack is cool, but sharing your story is more helpful
The biggest takeaway for me while sharing their story is that posts about your tech stack might be cool on social, but they leave out the most important part: how you arrived there. What battles did you face and what tradeoffs did you make trying different tools?

Below is a full breakdown of Statsig's tooling & tech stack, and we wrote about the struggles we faced along the way to get there.

(...My favorite story is how we tried to save money by using an open-source Notion alternative. Yeah, that didn't work out.)

If you're curious, we wrote about [our story here](https://scalingdown.substack.com/p/when-you-miss-the-tools-you-used).

## A peek into an ex-meta tech stack
![A peek into our tech stack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3hsuri2ocuwywzh2tqm3.png)

Let me know which tools you replaced and with what. Would love to hear how you solved your startup dilemma.
Perform RAG in JSON formatted data
Published: 2024-06-05 15:30:46

I have json data look like this, 
{ { 'id': 'p1', 'category': 'category1', 'description': 'description1' }, { 'id': 'p2', 'category': 'category2', 'description': 'description2' }, { 'id': 'p3', 'category': 'category3', 'description': 'description3' } }
I want to perform similarity search in only in description and get the relevant top 5 'id's. Free to use any embedding technique. What is the best vector store and how to do this task