teleren/devto huggingface dataset:
Exploring the Enchantment of Software Testing: An Easy Guide
Tags: webdev, testing, programming, discuss
Published: 2023-08-20 11:16:46


Have you ever watched a movie and wondered how those high-flying stunts are performed? Well, testing in software development is a bit like having stunt doubles for your code. Let's dive into this exciting world of testing and unveil the mystery behind it.

**What's this "Testing" Thing, Anyway?**

Imagine you're baking a cake. You wouldn't just throw the ingredients together and hope for the best, right? You'd taste a bit of the batter before baking it to make sure it's turning out delicious. That's testing in the software world – making sure your code works as expected before sharing it with the world.


**> Introducing Test Doubles: Your Secret Actors**


In movies, stunt doubles step in for actors during risky scenes. Similarly, in software testing, we have "test doubles" that replace real parts of our code when things get complicated. Just like a stunt double keeps actors safe, test doubles keep our code safe by letting us test it in controlled environments.

**Different Types of Test Doubles**

1) Fake:

Stunt doubles in movies for dangerous scenes instead of the main actors. For instance, you might replace a real database with an in-memory database to make your tests faster and simpler.


2)Dummy: 

Picture having extras on a movie set who don't say anything. Dummies are objects we put in our tests that don't really matter but keep the scene realistic.


3)Stub: 

Think of an actor delivering lines as scripted in a play. A stubbed method is like giving our code hardcoded answers during testing. It helps us see how our code reacts to different situations.


4) Spy:

 Ever seen a detective gathering evidence undercover? That's a spy. In testing, a spy watches and records interactions between parts of our code. It's like being the detective of our software.


5) Mock: Think of a play director guiding actors to perform perfectly. Mocks let us set up expectations for how our code should behave. They help us ensure that our code does what it's supposed to do.


**Why Do We Need Test Doubles?**

Imagine a recipe that needs an ingredient from the moon – not easy, right? Similarly, some parts of our code depend on things that are hard to use in tests, like real databases or networks. Test doubles step in and make our tests achievable, just like stunt doubles make action scenes achievable.


If you're interested in delving further into software testing and related topics, feel free to follow me or stay tuned for more insightful content.
Giảm dung lượng file word chứa nhiều ảnh
Tags: documentation, msword, sep490
Published: 2023-08-20 10:32:50

---
series: SEP490
---


Nhiều nhóm, sau khi chèn một đống ảnh vào, đặc biệt ở report 3 và report 6, thường sẽ tạo ra 1 cái file khổng lồ nặng vài chục tới vài trăm MB (đặc biệt khi các bạn dùng màn 4K chụp full screen) 
để khắc phục việc này, có nhiều cách, đơn giản và hiệu quả nhất là "compress picture" 

cách làm như sau 

1. chọn 1 bức ảnh bất kì trong file Word 
2. trong tab Picture Format, chọn Compress Picture 
3. **bỏ tick** ở dòng "Apply only to this picture"
4. chọn option Email (96 ppi) 
5. nhấn OK và enjoy cái file từ 100MB+ còn lại 10MB 

![image](https://i.imgur.com/cDk8Evz.png)
"Vue 3 : Smooth migration from the Options API to the Composition API in Vue 3"
Tags: vue, compositionapi, optionsapi, vue3
Published: 2023-08-20 10:25:06

##Introduction
With the introduction of Vue 3, a new component option and a new advised pattern were added to the framework for creating apps. You may get top-level bindings using this magical script setup> method of implementing the logics without having to go through the extra trouble of declaring an export default and a setup().

## Why <**script setup**> ?

Leaner codebase, faster development, readable and easier coding experience by reducing component choices into a single block. With each of these features, Reactivity makes things more simpler.

## Using Props with `<script setup>`

Using the <**script setup**> , a function called defineProps() is utilized. This function is a compiler macro, so there is no need to import it.

``` HTML
<template>
  <div>
    <p>Received Prop: {{ propValue }}</p>
  </div>
</template>
```

### Options API :
```HTML
<script>
export default {
  props: {
    propValue: String
  }
};
</script>
```

### Composition API :
``` HTML
<script setup>
const props = defineProps({
  propValue: String
});
</script>

```

## Using Methods with `<script setup>`

Methods will be specified as consts and available in your template just like they were in the Options API, since methods are no longer considered objects.

### Options API :

``` HTML
<template>
  <div>
    <button @click="incrementCounter">Increment</button>
    <p>Counter: {{ counter }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      counter: 0
    };
  },
  methods: {
    incrementCounter() {
      this.counter++;
    }
  }
};
</script>


```





### Composition API :

``` HTML

<template>
<div>
<button @click="incrementCounter()">Increment</button>
<p>Counter: {{ counter }}</p>
</div>
</template>

<script setup>
import { ref } from 'vue';

const counter = ref(0);

const incrementCounter = () => {
counter.value++;
};
</script>


```

## Using Computed with <**script setup**> 

Computed  in Composition API operate as reactive data variables. They perform the role of a function, returning calculated values depending on reactive dependencies.




### Options API :


``` HTML

<template>
  <div>
    <button @click="incrementCounter">Increment</button>
    <p>Counter: {{ counter }}</p>
    <p>Double Counter: {{ doubleCounter }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      counter: 0
    };
  },
  computed: {
    doubleCounter() {
      return this.counter * 2;
    }
  },
  methods: {
    incrementCounter() {
      this.counter++;
    }
  }
};
</script>


```


### Composition API :



``` HTML

<template>
  <div>
    <button @click="incrementCounter">Increment</button>
    <p>Counter: {{ counter }}</p>
    <p>Double Counter: {{ doubleCounter }}</p>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';

const counter = ref(0);

const doubleCounter = computed(() => {
  return counter.value * 2;
});
</script>
````
Setting up PostgreSQL and Replication between Two Servers - Ubuntu Server
Published: 2023-08-20 09:50:09

Setting up PostgreSQL and replication between two servers (web-server-001 and web-server-002) involves several steps. Here's a high-level guide to get you started. Please note that this is a general outline and might require adjustments based on your specific environment and requirements.

**Step 1: Install PostgreSQL on Both Servers**

SSH into each server and update the package list:

```bash
sudo apt update
```

Install PostgreSQL on both servers:

```bash
sudo apt install postgresql postgresql-contrib
```

**Step 2: Configure PostgreSQL on web-server-001**

Edit the PostgreSQL configuration file on web-server-001:

```bash
sudo nano /etc/postgresql/{version}/main/postgresql.conf
```

Make sure to replace `{version}` with the appropriate PostgreSQL version number. Find and update the following lines:

```conf
listen_addresses = 'localhost,web-server-001-ip'
```

Replace `web-server-001-ip` with the actual IP address of web-server-001.

**Step 3: Allow Remote Access on web-server-001**

Edit the PostgreSQL `pg_hba.conf` file on web-server-001:

```bash
sudo nano /etc/postgresql/{version}/main/pg_hba.conf
```

Add the following line to allow access from web-server-002:

```conf
host    replication     postgres        web-server-002-ip/32         md5
```

Replace `web-server-002-ip` with the actual IP address of web-server-002.

**Step 4: Create Replication User**

Log in to PostgreSQL on web-server-001:

```bash
sudo -u postgres psql
```

Run the following SQL commands to create a replication user:

```sql
CREATE USER replication_user REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD 'your_password';
```

Replace `'your_password'` with a strong password.

**Step 5: Take a Base Backup**

On web-server-002, take a base backup from web-server-001:

```bash
pg_basebackup -h web-server-001-ip -U replication_user -D /var/lib/postgresql/{version}/main -P --xlog-method=stream
```

**Step 6: Configure PostgreSQL on web-server-002**

Edit the PostgreSQL configuration file on web-server-002 as in Step 2, but replace occurrences of `web-server-001` with `web-server-002`.

**Step 7: Start PostgreSQL on Both Servers**

Start PostgreSQL on both servers:

```bash
sudo systemctl start postgresql
```

**Step 8: Test Replication**

Log in to PostgreSQL on web-server-001:

```bash
sudo -u postgres psql
```

Run the following SQL command to check replication status:

```sql
SELECT pg_is_in_recovery();
```

This should return `true` on web-server-002.

That's the basic outline for setting up PostgreSQL replication between two servers. Keep in mind that PostgreSQL replication can be complex and might require additional configurations and considerations based on your specific use case. It's recommended to refer to the official PostgreSQL documentation for more detailed guidance and troubleshooting.
How to show Nerd Fonts in Visual Studio Code
Published: 2023-08-20 09:38:36

Nerd Fonts offer a fantastic collection of icons that seamlessly integrate into various applications on your computer, from Notepad to email clients. However, configuring these icons to appear in Visual Studio Code requires a specific setup. In this article, we will guide you through the process of displaying Nerd Fonts within Visual Studio Code.

## Installing Nerd Fonts
To install Nerd Fonts, follow the official website's instructions. If you're a Mac user, I recommend using the 'brew' command for the installation. You can find the fonts and installation details at:
https://www.nerdfonts.com/font-downloads

## Setting Visual Studio Code
Without proper configuration, Visual Studio Code unfortunately doesn't display Nerd Fonts icons correctly. Therefore, you need to perform the following setup in your Visual Studio Code:

1. Open the Settings Page.
2. Search for settings using the keyword 'terminal.integrated.fontFamily'.
3. Enter "'Hack Nerd Font'" into the 'Editor: Font Family' field, as shown below:

The steps outlined above are demonstrated in the following movie:

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

(Note: I attempted to configure the settings according to the official website's instructions as https://code.visualstudio.com/docs/terminal/appearance, which suggested using "Hack NF" for the 'Editor: Font Family' field. However, this didn't work as expected. Instead, using "'Hack Nerd Font'" in the field worked properly.)

## Conclusion
After configuration, Nerd Fonts icons appear in your Visual Studio Code.　Have a good VSCode life!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/016ijcx8swikoyquw686.png)
Installing PostgreSQL + pgvector on Debian
Published: 2023-08-20 09:32:37

If you're building any kind of AI app that requires storage of vectors for embeddings, and you need an open source storage solution, it's hard to go wrong with PostgreSQL + the [pgvector](https://github.com/pgvector/pgvector) extension.

You could go with a hosted solution, such as Supabase's [vector storage](https://supabase.com/vector). You can also host it yourself. 

It's easy and I show you how to do it for the Debian OS below, which would allow you to add this to a Debian hosted website. This is also the exact setup I'm using for [clarifypdf.com](https://clarifypdf.com/?utm_campaign=content-marketing&utm_source=dev.to&utm_medium=website), a "Chat with PDF" AI app.

## Prerequisities

You'll need root access to your Debian environment. 

## Steps

SSH into your server, with your username and server's IP address

```
$ ssh user@ip.add.re.ss
```

Install [pgvector](https://github.com/pgvector/pgvector#installation-notes)


```
sudo apt install postgresql-15-pgvector
```

Login to PostgreSQL


```
$ psql -U db-username db-name
```

Enable pgvector 

```
# CREATE EXTENSION pgvector;
```

Check that it's enabled

```
# \dx
```

You should see the extensions list, with pgvector in it.

![Screen shot of PostgreSQL extensions list showing that pgvector is enabled.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7u4obsg51b8ssdbp2fo.png)

That's it! You're ready to create embeddings with PostgreSQL!
What is Signal
Published: 2023-08-20 09:21:41

Signal is a secure messaging app known for its strong focus on privacy and end-to-end encryption. It allows users to send text messages, voice messages, make voice and video calls, and share multimedia files. Signal's encryption ensures that only the intended recipient can read the messages, making it highly secure and protecting user privacy. It's often used by individuals and organizations who prioritize confidentiality in their communication.
Perl Weekly Challenge #230 - Turning Numbers into Characters and Words into Numbers
Tags: perl, perlweeklychallenge
Published: 2023-08-20 09:18:22

Hi everybody! I'm finally back with another PWC/TWC blog post for week 230.

#### Separate Digits

For the first challenge we want to split all the numbers in the array into single digits. Here's the code:

    use v5.36;
    my @nums;
    push(@nums, split(//, $_)) for @ARGV;
    say $_ for @nums;

It very simply splits anything in its arguments into individual characters and pushes them onto a new array.

#### Count Words

Our second challenge asks us to count the words that start with the given prefix. Here's a 4-liner (minus boilerplate) to help us out with this one:

    use v5.36;
    my $pattern = shift;
    my $count;
    for (@ARGV) {$count++ if $_ =~ /^$pattern/}
    say $count // 0;

We take the pattern and then add to the count if our regex prefix matches the start of any of the strings in the arguments.

That's all for this week, two nice easy challenges! Hope I'll be able to post again next week maybe.
What is Department
Tags: eng, department, cse, webdev
Published: 2023-08-20 09:00:49

A department typically refers to a distinct functional division within an organization or institution, responsible for specific tasks, functions, or areas of expertise. Departments help to organize and streamline various activities, resources, and personnel to achieve specific goals or objectives. They can exist in various types of organizations, such as businesses, government agencies, educational institutions, and more. Each department focuses on a particular aspect of the organization's operations, allowing for specialization and efficient management.
How to first migrate custom User model within models directory
Published: 2023-08-20 08:59:47

For a Django rest_framework project I wanted to create several models (User and Contributor model in 'accounts' and Project, Issue and Comment in 'project'). Normally I create several apps to create these models.

for visualisation, project tree with several apps:

```
# project tree

.
├── accounts
│   ├── __init__.py
│   ├── models.py
├── api
├── main.py
├── manage.py
├── project
│   ├── __init__.py
│   ├── models.py
└── project_name
    ├── asgi.py
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py
```

I realized that it is really hard to implement the Router for the Django rest_framework, I was not able to make it work. So, I had to come up with an other strategy. 

now my project tree:

```
# current project tree 

.
├── api
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   ├── models
│   │   ├── accounts.py
│   │   ├── __init__.py
│   │   ├── project.py
│   ├── serializers
│   │   ├── accounts.py
│   │   ├── __init__.py
│   │   └── project.py
│   ├── urls
│   │   ├── accounts.py
│   │   ├── __init__.py
│   │   └── project.py
│   └── views
│       ├── accounts.py
│       ├── __init__.py
│       └── project.py
├── db.sqlite3
├── manage.py
└── project_name
    ├── asgi.py
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py
```

I add the the app and the rest_framework variable into the `settings.py` file:

```python
# settings.py

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    # custom api
    "api",
    "rest_framework",
]
```

I create the models for custom User and Contributor in models directory in `accounts.py` file. And the models for Project, Issue and Comment is located inside the models directory in `project.py`.

In `settings.py` I set:
```python
# settings.py

AUTH_USER_MODEL = "api.User"
```
The AUTH_USER_MODEL has to be defined as: "_app_label.ModelName_"
My app name is "api" and the modelname is "User"

Add the models into the `admin.py` file.

<hr>

After creating the models I wanted to make the migrations. 

After using `python manage.py migrations` I got the error: 
```
# terminal 

django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'api.User' that has not been installed
```

This error typically occurs when there is an issue with the configuration of the custom user model in Django.


To get rid of this error, in my case, I had to add this inside the `__init__.py` file of the models directory.

```python
# models/__init__.py

from .accounts import *  # noqa
```

To ensure that the User model is found I had to import all contents of the `accounts.py` file.

`noqa` most likely stands for "no quality assurance". It tells code-analysis software to ignore warnings.

After adding this line into the `__init__.py` file the `python manager.py makemigrations` was working fine. 

If is possible to just import parts of the `accounts.py` file.
How We Achieved Minimal Downtime During Our PostgreSQL Database Upgrade
Tags: postgres, database
Published: 2023-08-20 08:47:07

Hello everyone, I’m Kenny, a Backend Engineer from [Dcard](https://about.dcard.tw/).

Recently, we upgraded the primary PG 9.6 Cluster of Dcard’s services to the 11 version, managing to limit write downtime within ten minutes, and successfully rebuilt the OfflineDB and CDC services within an hour. In this [article](https://blog.kennycoder.io/2023/08/19/How-We-Achieved-Minimal-Downtime-During-Our-PostgreSQL-Database-Upgrade-English-version/), we will share how we accomplished this challenging task.

Because English is not my native language, the grammar and semantics of the article might not be entirely accurate. However, while undergoing the upgrade, I also reviewed numerous upgrade articles from international companies and personal blog. As a result, I'd like to share my own upgrade experience. :)

Feel free to ask me any question !
Tailwind Css Grid Layout Generator
Tags: tailwindcss, react, webdev, opensource
Published: 2023-08-20 08:41:02


🚀 Excited to unveil my latest project: Tailwind CSS Grid Generator! 🎉

Easily craft stunning grid layouts with a user-friendly interface. Customize rows, columns, and more, then grab the instant Tailwind CSS code for seamless integration. Simplify your web design process today! 💻

Give a star to the project on GitHub: [https://github.com/AhmerAli412/GridLayoutGenetrator] ⭐

[https://grid-layout-genetrator.vercel.app/] 

#TailwindCSS #WebDesign

"Give a star to the project on GitHub" request!
Improved Docker setup for MySQL access generator utility
Tags: mysql, database, generator, utility
Published: 2023-08-20 08:39:26

Check out MySQL database access generator utility on GitHub at [github.com/podlom/generate-mysql-db-access](https://github.com/podlom/generate-mysql-db-access)

It uses my [Random Password Generator](https://rndpwd.info/) service to make MySQL database passwords.
Weekly reading digest #1
Tags: php, backend, symfony, softwareengineering
Published: 2023-08-20 08:12:11

**2023/08/14-2023/08/20**

[The PHP stat cache explained](https://tideways.com/profiler/blog/the-php-stat-cache-explained)

[About Symfony Messenger and Interoperability](https://jolicode.com/blog/about-symfony-messenger-and-interoperability)

[Granular events](https://sebastiandedeyne.com/granular-events)

[Unit Tests Are Overrated: Rethinking Testing Strategies](https://thenewstack.io/unit-tests-are-overrated-rethinking-testing-strategies/)

[Just normal web things](https://heather-buchel.com/blog/2023/07/just-normal-web-things/)

[A Brief, Incomplete, and Mostly Wrong History of Programming Languages](https://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html)
How to archive IMAP emails like a Pro
Published: 2023-08-20 08:01:27

If you want to find a reliable IMAP archive tool that works for you, you can get Mail backup X software. 

This **IMAP archive tool** is created to make sure that you get to modify your email archive during the process. Even if you are a complete beginner, you can still use this tool to backup, restore, convert and also archive your emails. 

This IMAP archive tool gives you access to all features related to email management. There has never been another tool that offers so many features in one place and that too in such a budget. 

Make sure that you do not fall into the trap of any free tool that offers you free email archiving. Free tools are mostly unable to protect your emails and may even cause data loss in the long run. 

## What makes Mail backup X the best IMAP archive tool?

There are a lot of factors that make it the best tool to archive IMAP emails and do other things 

- You get to set up your own email profile 
- You get to choose any emails you want to archive 
- Backup all major email services 
- Restore your backed up emails 
- Archive your emails as PDF files 
- Split large PST files into smaller ones 
- Selective email backup and recovery 
- You get multiple packages to choose from 
- Smart backup and resume feature 
- Auto USB backup and sync feature
- You can set up automatic incremental backups 
- Choose how often your emails are backed up 
- You get to encrypt your email profile 

These are just some of the things that make Mail backup X the ideal choice for email management. If you are an email user who wishes to **[archive your IMAP emails](https://www.mailbackupx.com/archive-imap/)**, you should definitely get this tool. 

## These are the packages that you can choose from 

## Single user version

The single user version of the tool can be used by a single user on two computers. You can use this to backup up to 5 mail profiles per user. You can get a $20 top up and get 10 more mail profiles to manage. 

## Team version 

The team version of the tool is offered for 5, 10, 20, 30 users and more. This version gives you 5 mail profiles to work with. You can get a $20 top up to get 10 more email profiles. If you want, you can also use the tool remotely for other users if you are the admin. 

## You should get the free demo right now

If you are curious about how this tool will work for you, you should test its free demo version. The free trial of this tool is created to work for 15 days. You get to use all the features of the tool without any features being hidden from you. This is what makes this tool so remarkable. 

You can get the free trial of the tool right here - https://www.mailbackupx.com/archive-imap/