teleren/devto huggingface dataset:
Query Processing in PostgreSQL ( Part 2 )
Tags: postgres, database
Published: 2023-05-07 18:32:54

we will summarize the cost estimation of PostgreSQL for "Single-table query"

Recall : 
- The planner subsystem in PostgreSQL is "Cost-based optimization".
- The cost is just a "Relative" indicator of performance, not an absolute one.


**Cost estimation in PostgreSQL** 
- cost estimation is done by functions from the "costsize.c" file.
- each operation has its corresponding function, that is used to measure its performance or calculate its cost. 
- types of cost : 
   - 1. Start-up cost 
   - 2. Run cost 
   - 3. Total cost


**Start-up cost**
- the cost expended until the first tuple is fetched. 

**Run cost** 
- the cost expended to fetch all tuples.

**Total cost**
- the sum of both start-up and run costs.

**N.B**
- both Start-up, Run costs are independent costs since they are calculated independently of any other cost.
- Total cost is a dependent one since, it's calculated as the sum of both start-up and run costs.

**SQL EXPLAIN statement** 
- provides information about how PostgreSQL executes statements ( Query plan tree ).
- also provides cost estimation information, start-up cost, and total cost for each query node ( operation in the query plan ).


**N.B**
- Popular operations in query plan tree ( appears using EXPLAIN )  
  - sequential (seq.) scan  
  - index scan 
  - sort 

**1. Sequential (seq.) scan**
- Sequential scan, scans the entire relation (table) as stored on disk.
- it's cost estimated by "Cost-seqScan" from "CostSize.c" file we mention before.
- it has a Start-up cost "Zero"
- and for the Run cost, there is a defined formula used for its estimation 

The formula : 

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

**N.B**
- Here in cost-estimation, we assume the "Worst" case scenario where we consider that all pages will read from storage (neglecting the case of some pages retrieved from the shared buffer)

**2. Index scan**
- there are many indexing methods in Pg. for indexing like Btree, Gist, GIN, or BRIN 
- the cost estimated by the "cost_index" function.
- **Start-up** cost for the index scan is defined as the cost to read the index pages to access the first tuple in the target table, and estimated using a defined formula, 


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


- **Run cost** for index scan is defined as the cost to read the index pages to access the first tuple in the target table, and estimated using a defined formula, 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5wd8lhxt5zod6mawha7.png)
[vue3] Why is the length of a reactive Array always undefined?
Tags: vue
Published: 2023-05-07 18:32:21

I once spent a lot of time due to my superficial knowledge of Vue reactivity. I saw it very clearly and simply, but I never really thought about how it works.

For example, we have an empty **array of strings** that will be filled after user actions.

```
const inputData = ref<string[]>([])
```

> You'll always use ref() for primitives, but ref() is good for objects that need to be reassigned, like an array.



After the user's action and filling the array, we need to show him some information in the template, but before that it was hidden. So we add a computed property to keep track of the length of the array.

```
const inputLength = computed(() => {
  return inputData.value.length
})
```
```
<template v-if="inputLength ">
 some information
</template>
```

**Problem:**
At first glance this seems correct (to me), but it doesn't work because since we're using `ref`, our `inputData` is not an array of strings, but a **ref object** that has one property **value**. And `inputData.value` is also not an array of strings, but a **proxy object**.
So our inputLength computed property is always _undefined_.
For a long time I could not understand what was wrong here.

All we need to do is use `Object.keys` and get the number of keys of the proxy object.

**Solution:**
```
const inputLength = computed(() => {
  return Object.keys(inputData.value).length
})
```
MDToolbar error
Tags: kivy, beginners, python, discuss
Published: 2023-05-07 18:18:54


I took this code from github . But this give MDToolbar error . I couldn't able to resolve this regardless of efforts to clear this one , it still shows the same error ,Since I'm Newbie in this I don't Know what to do . Please somebody spare some time and help at this one , I will also provide the source code if you need . Pls let me know.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s28ynadr549qlaeo2kvv.png)
New AI coding language Mojo
Tags: discuss, ai, machinelearning, beginners
Published: 2023-05-07 18:13:53

Recently a new language was released by the developers of Swift, which is called Mojo. it is claimed by the developers that this language is almost 3600x faster than python but has all the capabilities that python offers in mechine learning. 
If anyone knows anything more about the language, please share
Maximizando a eficiência do versionamento com padrões de commits no GitHub
Tags: braziliandevs, productivity, git, github
Published: 2023-05-07 17:42:39

Resolvi escrever este post para dar mais destaque a este tema.

Enquanto estudava e enviava projetos para o Git, comecei a perceber que meus commits não estavam com o contexto muito claro. Então, comecei a pesquisar se existiam padrões que poderiam ser usados para que as mensagens dos commits ficassem mais diretas ao ponto e fáceis de entender. Juntei conhecimentos de várias pesquisas e opiniões para criar uma lista de padrões que melhorassem a produtividade da equipe com mensagens de commits mais claras.

**A seguir, apresento uma lista com cinco padrões efetivos para commits.**

1. Mensagem clara e concisa: a mensagem de commit deve ser clara e descrever a mudança feita de maneira concisa. Ela deve ser informativa o suficiente para que outros desenvolvedores possam entender a mudança sem precisar revisar o código.

2. Prefixos de commit: muitos projetos usam prefixos em suas mensagens de commit para indicar o tipo de mudança realizada. Alguns exemplos de prefixos comuns incluem "feat" para novas funcionalidades, "fix" para correções de bugs e "docs" para atualizações de documentação.

3. Linha de assunto e corpo: algumas equipes preferem separar a mensagem de commit em uma linha de assunto curta e um corpo mais detalhado que explica a mudança em mais detalhes. Isso pode ajudar a tornar as mensagens de commit mais fáceis de ler e entender.

4. Mensagens em inglês: como o inglês é uma linguagem comum no desenvolvimento de software, muitas equipes optam por usar o inglês em suas mensagens de commit para garantir que elas possam ser entendidas por desenvolvedores em todo o mundo.

5. Consistência: independentemente do padrão específico que você escolher para suas mensagens de commit, é importante ser consistente e seguir esse padrão em todos os commits. Isso tornará mais fácil para outras pessoas entenderem as mudanças que você fez ao longo do tempo.
Find occurrences of a word in a Pdf file with c# and PdfPig
Tags: csharp, dotnet, pdf, backend
Published: 2023-05-07 17:11:59

---
title: Find occurrences of a word in a Pdf file with c# and PdfPig
published: true
description: 
tags: csharp, dotnet, pdf, backend
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-05-07 17:10 +0000
---


## Introducing PdfPig

**PdfPig** is an **open source C # library** that allows us to **extract text** and other content from **pdfs**. Its a port of the java pdfbox library. You can find more here: [https://github.com/UglyToad/PdfPig](https://github.com/UglyToad/PdfPig)

## The Word Counter

The project will be a simple console application and will have the following structure:

![](https://cdn-images-1.medium.com/max/2000/1*Q0XI5ZdQaFMc3gUALdP9bw.png)

## Creating The Project

With Visual Studio 2022, follow the steps below:

 1. Open Visual Studio 2022

 2. Create New Project

 3. Select Console Application in C#

 4. Set Name and Path

 5. Choose .NET 5.0 Framework

Now you have the basic structure of a console application. Create a folder and call it pdf. Add a pdf inside this folder. In this tutorial i used a pdf created from this page: [https://en.wikipedia.org/wiki/Cr%C3%AApe](https://en.wikipedia.org/wiki/Cr%C3%AApe)

To get PdfPig:

 1. On the search bar print Manage NuGet Packages

 2. Click on Browse

 3. Search PdfPig

 4. Install It

## The Code

Thanks to PdfPig extracting text from the pdf and calculating the occurrences of a word is trivial, here the full code:

    using System;
    using UglyToad.PdfPig;
    using UglyToad.PdfPig.Content;

    namespace pdf_pig_word_counter
    {
        internal class Program
        {
            static void Main(string[] args)
            {
                string wordToFind = "pancake";
                int numberOfOccurrences = 0;

    using (PdfDocument document = PdfDocument.Open(@"YOUR PATH\pdf\test.pdf"))
                {
                    foreach (Page page in document.GetPages())
                    {
                        string pageText = page.Text;

    foreach (Word word in page.GetWords())
                        {
                            if (word.Text.ToLower().Contains(wordToFind.ToLower()))
                                numberOfOccurrences++;
                        }
                    }
                    Console.WriteLine("Total Occurrences: " + numberOfOccurrences);
                }
            }

    }
    }

This program will tell us how many times the word pancake is present in the pdf.

You can find the project here: [https://github.com/CertosinoLab/mediumarticles/tree/pdf_pig_word_counter](https://github.com/CertosinoLab/mediumarticles/tree/pdf_pig_word_counter)

Thank you!
Multiple Airflow deployment in Single DB
Tags: devops, airflow, backend, database
Published: 2023-05-07 17:10:04


## Problem Statement:
 Airflow deployments can use only one DB at the time. This is because, at the time of deployment, Airflow will create initial tables in `public` schema as show in the figure



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

So we can't create, another Airflow deployment in same DB. 

## Solution:

Create a new schema with an unique user credential, grant all the privileges on the user credential to access the newly created schema. Then alter the search path of new user set to new schema. Finally add the schema name with DB user credentials in Airflow YAML deployment file.

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


Steps to achieve this:

#### Create a new schema and user credentials 
```
CREATE SCHEMA airflow_ciapi;

CREATE USER nishok_ciapi WITH PASSWORD '***************';
```
#### Grant privileges queries
```
GRANT ALL PRIVILEGES ON DATABASE postgres to nishok_ciapi;

GRANT SELECT ON ALL SEQUENCES IN SCHEMA airflow_ciapi TO nishok_ciapi;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA airflow_ciapi TO nishok_ciapi;

GRANT ALL ON ALL TABLES IN SCHEMA airflow_ciapi TO nishok_ciapi;
GRANT ALL ON ALL SEQUENCES IN SCHEMA  airflow_ciapi TO nishok_ciapi;
GRANT ALL ON ALL FUNCTIONS IN SCHEMA airflow_ciapi TO s_ciapi;
nishok
GRANT CREATE ON SCHEMA airflow_ciapi TO nishok_ciapi;
```
#### Alter search path query
```

ALTER USER nishok_ciapi SET search_path = airflow_ciapi;
```
Both the Schema in same DB

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

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



#### Sample YAML file for Airflow deployment 
```
airflow:
  service:
    type: NodePort
  image: ********.dkr.ecr.us-east-1.amazonaws.com/***********
  tag: GIT_SHA
  nodeselector: airflow
  config:
    dags_folder: /root/airflow/dags
    s3_url: s3://airflow
    base_url: airflow.xyz.com
    schema: airflow_ciapi
```
Enabling IPV6 on an Amazon EC2 instance
Tags: aws, awsnetworking, awscommunitybuilder
Published: 2023-05-07 17:08:33

By default, AWS EC2 instances are not connected to IPV6. Due to IPV6's benefits, we will want our EC2 instance to have it in a number of situations, including the following:

1. No more NAT (Network Address Translation)
2. Auto-configuration
3. No more private address collisions
4. Better multicast routing
5. Simpler header format
6. Simplified, more efficient routing
7. True quality of service (QoS), also called "flow labeling"
8. Built-in authentication and privacy support
9. Flexible options and extensions
10. Easier administration (no more DHCP)

I'll walk you through setting up your EC2 instance with an IPV6 address in no time today.

## TOPOLOGY


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

**STEP1 .**

GO TO YOUR VPC AND EDIT CIDR 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/khjrtkslbjuzzcwlvs5l.png)
STEP2.  
Edit CIDR , there is no associated  IPV6 by default 

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

STEP 3 
Add new IPV6 CIDR 

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

STEP 4
IPv6 will now associate itself  with the VPC , the same way ipv4 was associated by default 

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fc7jvinbr76p7bq75i5f.png)
STEP 5
Go to the subnet and enable IPV6 on us-east-1a subnet 

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

STEP 6
Add subnet CIDR block 

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

STEP 7
Edit  ROUTE TABLES and point default ipv6 routes to INTERNET GATEWAY

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqh6nomossab1nn6e0ow.png)
STEP 8
Go ahead and launch your EC2 instance using the VPC edited 

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

 STEP 9
EC2 has been launched successfully with associated IPV6 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcvd8ccciv6c15xdt8qz.png)
STEP 10
Check your ipv6 configuration and  ping to IPV6  google public DNS (2001:4860:4860::8888)


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmb6t7pec7vmktoxl2bl.png)
Moving an EC2 instance from one AWS account to another.
Tags: aws, tips
Published: 2023-05-07 17:04:19

Moving an EC2 instance from one AWS account to another can be done by following these steps. Please note that you will need access to both the source and destination AWS accounts to complete this process.


Create an Amazon Machine Image (AMI) of the EC2 instance:

a. In the source AWS account, go to the EC2 Management Console.
b. Select the instance you want to move.
c. Click on 'Actions', then select 'Create Image'.
d. Provide a unique name and description for the image and click 'Create Image'.
e. Wait for the AMI creation process to complete.


Share the AMI with the destination AWS account:

a. In the source AWS account, go to the 'AMIs' section of the EC2 Management Console.
b. Select the newly created AMI.
c. Click on 'Actions', then select 'Modify Image Permissions'.
d. Enter the destination AWS account ID and click 'Add Permission'.
e. Save the changes.


Launch a new EC2 instance in the destination AWS account:

a. In the destination AWS account, go to the EC2 Management Console.
b. Click on 'Launch Instance'.
c. Select 'My AMIs' from the left-hand menu.
d. Choose the shared AMI from the source account and click 'Select'.
e. Follow the standard process to configure and launch the new EC2 instance.


a. After verifying that the new EC2 instance is working correctly, terminate the old instance in the source account to avoid incurring unnecessary charges.
9 Tips for Stand Out Resume
Tags: resume, cv, linkedin
Published: 2023-05-07 16:58:05

## **[Writing a unique profile](https://crispresume.com) **

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

1. Describe yourself and identify specific talents and skills that you have acquired through previous work experience and co-curricular activities.

2. Before writing your [resume](https://www.crispresume.com/resume-templates), identify the objective of writing that resume. 

3. Crisp and concise language, without cliches grab the reader's attention.

4. Write a Qualification Summary. Direct your statement to the prospective employer.

5. Use effective action verbs. They are effective, if used as the first word in an accomplishment statement.

6. Use Headlines to Hook Employer. Headline should have some keywords, which can be identified a hiring software/internet. The headline is telling a potential employer, what you have to offer the company. This is the most important part of a resume.

7. Use numerals in accomplishments, when you are citing monetary amounts. Otherwise numerals should be avoided.

8. Avoid topics that screen you out.
 
9. Choose the right format of resume. Resumes are divided into three categories: chronological, functional and combination resumes.[Resume Tutorials](https://www.crispresume.com/guides-tutorials)
SSH Keys make me SMH
Published: 2023-05-07 16:57:48

So I'm a tiny baby coder and today while trying to set up SSH Key for GitHub for my bootcamp that begins in 2 weeks I struggled with getting basic things like getting my public key to copy and how to create a SSH key. Turns out you need to...you know...check your OS to make sure you don't need a simple extra step to get it to work correctly. ::Face Palm:: Onward..
Recycling used toner cartridges
Tags: toner, recycling
Published: 2023-05-07 16:38:32



Laser printers equipped with toner cartridges have conquered the world very quickly. No wonder! Laser printing is very fast, easy and economical from the point of view of each user. However, the printing process is not without its drawbacks. Waste is generated during operation – empty toner cartridges. So the question arises – what to do with used cartridges?

Why shouldn't used toner cartridges be thrown away?
Empty toners that have been consumed in the printing process are not suitable for disposal. First, they may contain residual toner powder, which is hazardous to the environment. Second, empty toner is treated by regulations as waste electrical and electronic equipment. Thus, old cartridges require proper transport and recycling using specialized machines, and if you purchase new cartridges from  [Sert IT Network](https://www.sertit.ro/) , you will benefit from Bonus ECO, a program that includes recycling used cartridges.

Used toner, although no longer printing, may still contain residues of hazardous substances. This means that they require special recycling procedures that are regulated by legal standards.

What to do with used toner cartridges?
If you have used toner cartridges, there are certain things you can do to recycle them.

First, used toners that are already empty should be returned to the store where you buy new toners for your printer. The store where you buy the printer toners must accept the old ones for free. This is the best option for people who use toner cartridges. The same is true for those who choose to buy from  Sert IT Network

Secondly, the collection of empty toners is also carried out by the places set up for collection at the Selective Collection Points of Municipal Waste, which are located in each city. To find such a place, you just need to enter the appropriate phrase in the search engine and find the point closest to you.

Thirdly, no one has to collect the used toners from you, you can return them yourself in special containers that are intended for this purpose and can be found in certain specialized stores.

Used toner cartridges - what to remember?
Never dispose of used and empty toner cartridges  in the regular trash. It is dangerous for the environment and people. In addition, a large financial penalty may be imposed on you or your company.

Return the used toners to the place of purchase, to a special collection point, or order the collection of the empty toners at a special company that recycles them.

Do not store used toner cartridges at home. They can be damaged and the dust that comes out of them can be poisonous to you and your family.

Unfortunately, every year thousands of used toner cartridges end up in landfills instead of designated collection points. This is a big mistake! Correct disposal of toners can not only help protect the environment, but can also be a source of additional funds.
CSS Glowing Button Hover Animation
Tags: css, design, animation, webdev
Published: 2023-05-07 16:36:00

 CSS Glowing Button Hover Animation

---

 
![CSS Glowing Button Hover Animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91qe086dw7vcwz8jj2v2.gif)

---

### HTML Code 

```html
<button> Button
</button>
```

### CSS Code 

```css
button {
 --glow-color: rgb(217, 176, 255);
 --glow-spread-color: rgba(191, 123, 255, 0.781);
 --enhanced-glow-color: rgb(231, 206, 255);
 --btn-color: rgb(100, 61, 136);
 border: .25em solid var(--glow-color);
 padding: 1em 3em;
 color: var(--glow-color);
 font-size: 15px;
 font-weight: bold;
 background-color: var(--btn-color);
 border-radius: 1em;
 outline: none;
 box-shadow: 0 0 1em .25em var(--glow-color),
        0 0 4em 1em var(--glow-spread-color),
        inset 0 0 .75em .25em var(--glow-color);
 text-shadow: 0 0 .5em var(--glow-color);
 position: relative;
 transition: all 0.3s;
}

button::after {
 pointer-events: none;
 content: "";
 position: absolute;
 top: 120%;
 left: 0;
 height: 100%;
 width: 100%;
 background-color: var(--glow-spread-color);
 filter: blur(2em);
 opacity: .7;
 transform: perspective(1.5em) rotateX(35deg) scale(1, .6);
}
/* Visit https://democoding.in/ for more free css animation */

button:hover {
 color: var(--btn-color);
 background-color: var(--glow-color);
 box-shadow: 0 0 1em .25em var(--glow-color),
        0 0 4em 2em var(--glow-spread-color),
        inset 0 0 .75em .25em var(--glow-color);
}

button:active {
 box-shadow: 0 0 0.6em .25em var(--glow-color),
        0 0 2.5em 2em var(--glow-spread-color),
        inset 0 0 .5em .25em var(--glow-color);
}
```
---

Thanks for Reading ❤️! Check my website [Demo coding](https://democoding.in/) for updates about my latest CSS Animation, CSS Tools, and some cool web dev tips. Let's be friends!

Don't forget to subscribe our channel : [Demo code](https://www.youtube.com/@democode)