teleren/devto huggingface dataset:
FREE AWS Cloud Project Bootcamp Week 4 Part 5
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-03-19 23:14:22

[78/100] #100DaysOfCloud Today, I completed the Week 4 of the FREE AWS Cloud Project Bootcamp by Andrew Brown.

The rest of Week 4 was to create a new activities with a database insert. Basically, when we log in to ou cruddur account, we get to post our own cruds in our homepage. I implemented it but got an error and couldn't figure out why so will be asking the discord group for help and updating it in my repo.

Checkout what I did for Week 2: [GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/078/Readme.md)

You can watch the Bootcamp through this YouTube playlist : [FREE AWS Cloud Project Bootcamp playlist](https://youtube.com/playlist?list=PLBfufR7vyJJ7k25byhRXJldB5AiwgNnWv)
[Off-Topic] Living Outside the Algorithm
Tags: watercooler
Published: 2023-03-19 22:05:51

The buzzword in everyone's mouth is AI. Related to that, are the “algorithms” each platform prides itself in.

I stay out of most social media, but while you can’t run from all algorithms, you can minimize their impact.

But why would you do that?

Most platforms want you on their platform for the most time possible, regardless if you want it or not, and they can do good work at that.

I will share here how I use Youtube and to one extent or another, you can probably apply to any other platform.

## My Youtube routine

I subscribe mostly to programming stuff and music channels, and then to some other subjects and a few guilty pleasures. 

When I started my “routine” I just unsubscribed from a bunch of things that I had subscribed to because of one thing or another that I don’t even like anymore or because of a “one of” video. 

- Go to [Subscriptions](https://www.youtube.com/feed/subscriptions)
- Add to [Watch Later](https://www.youtube.com/playlist?list=WL) or to “Queue” the videos you’re interested
- What it
- ???
- Go do something else!

Personally put everything in my Watch Later and only use that (with the exception of music mixes).

A lot of things I code while listening to some late/daily news shows or random stuff in the playlist.

### How about finding new channels?

Recommendations are the way to go. The creator you follow mentions something (or does a collab)? Check it out and if you like it, then subscribe to it. When you find yourself never clicking it again, then just unsub it.

## Why do that

Ever wondered what happened to pagination?

Infinite scrolling means that you just keep going. But when you know there’s a beginning and end to your feed, you get more time in your day… I know I did.

---

If you think this is worth it, share it with someone who might need this.

---

Cover Photo by [Dominik Scythe](https://unsplash.com/@drscythe?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/photos/Sot0f3hQQ4Y?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)
Buffer Pool in Innodb
Published: 2023-03-19 21:59:34

Buffer pool like in every storage engine plays an important and pivotal role in Innodb engine. Buffer pool stands out as one of the most important component in storage engine's architecture.

Buffer pool is an area where frequently accessed data from tables and indexes is kept. When data is read from disk, it's loaded into the buffer pool, and subsequent reads can be served from memory instead of from disk which is the whole concept of creating a buffer pool. This can greatly improve performance because memory accesses are much faster than disk accesses.

The buffer pool is configurable, and its size is determined by the innodb_buffer_pool_size configuration option. The default value for this option is 128MB, but it's often recommended to increase it to several gigabytes for high-performance workloads. Out of many configurations the user can do according to its requirements are resizing the buffer pool, splitting the buffer pool into multiple parts to minimize memory contention, when and how to perform read-ahead requests to prefetch pages and when to perform flushing.

Buffer pool metrics can be monitored via Innodb standard monitor from which user can analyze the performance of buffer pool.

<u>WORKING OF BUFFER POOL</u>

When InnoDB needs to read data from a table or index, it first checks if the data is already in the buffer pool. If it is, the data can be read directly from memory. If not, InnoDB reads the data from disk and loads it into the buffer pool. If the buffer pool is full, InnoDB will evict some data to make room for the new data.

LRU (Least Recently Used) Algorithm is the backbone of eviction process through which data is stored in buffer pool.InnoDB keeps track of which pages in the buffer pool were accessed most recently and least recently, and when it needs to evict data, it chooses the least recently used pages to evict.

InnoDB also uses a technique called "adaptive flushing" to manage the buffer pool. When the buffer pool is full and new data needs to be loaded, InnoDB will first try to flush some dirty pages to disk. Dirty pages are pages that have been modified in memory but haven't yet been written to disk. By flushing these pages to disk, InnoDB can free up space in the buffer pool for new data.

<u>Conclusion</u>

The buffer pool is a critical component of InnoDB's architecture, and it's designed to improve performance by caching frequently accessed data in memory. By keeping data in memory, InnoDB can avoid disk accesses and serve requests much faster. The buffer pool is configurable, and its size should be set based on the workload and available memory. With a properly sized buffer pool, InnoDB can deliver excellent performance for transactional processing workloads.
useModal: a React.js custom hook to handle modals with ease.
Tags: react, typescript, opensource, github
Published: 2023-03-19 21:24:26

I just published my first NPM package 🎉⚛!

A simple React.js custom hook to handle from one to multiple modals in your react application with ease.
Dynamically update modal content and avoid writing verbose jsx for earch modal and relative states.

[https://github.com/dennib/react-use-modal](https://github.com/dennib/react-use-modal)

[NPM package page](https://www.npmjs.com/package/@dinneb/react-use-modal)
Sobre mim
Published: 2023-03-19 20:32:47

Oi, me chamo Letícia, mas podem me chamar de lê ou let. Tenho 25 anos sou desenvolvedora back-end, atuo como agilista em um projeto voluntário chamado PetJournal, sou idealizadora e community mannager da comunidade Minas In Tech, onde o intuito é incentivar mulheres iniciantes na área de tecnologia e acredito que a educação pode nos levar a lugares inimagináveis. Hoje em dia tenho 
intensificado meus estudos em busca da primeira vaga como jr e com isso, pensei em compartilhar o que tenho estudado.
Do you know what is abstraction in programming?
Tags: programming, webdev, abstraction, code
Published: 2023-03-19 20:29:56

Tips for making effective use of abstraction in programming:

1. identify the essential functionality of the system

2. Choose the appropriate level of abstraction to achieve the goal of those involved in the project

3. Keep the abstraction consistent

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

![2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3z50zcu6eo7cdlkw8o06.png)


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


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


![5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrfvtp74f9uvqt4jwgw0.png)
Creating Axios Interceptor in React and NextJs
Published: 2023-03-19 20:18:39

Hello and welcome to this article on creating an Axios interceptor in React and Next.js. In this article, we'll cover how to set up and use Axios, as well as how to create an interceptor that can automatically refresh tokens.

Step 1: Initializing the Project
First, we need to initialize the project with the following command: `yarn create react-app <app-name>` or `npx create-react-app <app-name>`. This command will create a new React app with the name of your choice.

Step 2: Creating the Axios Configuration File
Now that we have a new React app, we can create the directory service and create a file named axiosConfig.ts inside it. Here's the code you need to put in that file:

```
import axios from 'axios';
import { getToken, setToken } from '../../../utils/localStorage';
import { redirect } from "react-router-dom";
import { getRefreshToken } from '../login';

const statusCode = [401,402,403]
const HttpAuthInstance = axios.create({
    baseURL: process.env.REACT_APP_BASE_URL,
    headers: {
        "Authorization": "Bearer" + " " + getToken("token").accessToken
    }
})

HttpAuthInstance.interceptors.response.use((response) => {
    return response;
}, (error) => {
    if (statusCode.indexOf(error?.response?.status) !== -1) {
        getRefreshToken(getToken("token")?.refreshToken).then(res=>setToken("token",res?.data))
    }
})

export default HttpAuthInstance;
```
This code sets up an Axios instance that includes a base URL and headers with an authorization token. It also sets up an interceptor that checks for certain error status codes and refreshes the token if necessary.

Step 3: Using the Axios Configuration File
To use this Axios instance in your application, simply import it into the file where you need to make API calls. Here's an example of how to do that:

```
import HttpAuthInstance from './service/axiosConfig';

HttpAuthInstance.get('/api/users').then(response => {
    console.log(response.data);
});
```
In this example, we're making a GET request to the /api/users endpoint and logging the response data to the console.

That's it! With this Axios interceptor, your application will automatically refresh tokens when necessary, making it more secure and efficient. I hope you found this article helpful and informative. Happy coding!
OSDC-2023-second-assignment
Tags: osdc, github, git, yaml
Published: 2023-03-19 20:16:51

In second lesson course [osdc] (https://osdc.code-maven.com/) we go over the PRs that we opened and fix issues in PR instead of opening new ones. we saw how to follow interesting projects on GitHub to get notifications. We got a better understanding of the structure of a Github URL, and how to find a git repo of a project. we saw how use in [yaml] (https://github.com/OSDC-Code-Maven/open-source-by-organizations/tree/main/github)  files
and I do assigment in Yaml,I very like it and I think that:
"A small step for man, a giant step for humanity".

I have selected each person and interesting projects to follow in [github] (https://github.com/) and [devto] (https://dev.to/) :
[TD] (https://dev.to/tdaw/osd700-working-with-bullmq-workerqueues-contd-14j9)
[Arseny Zinchenko] (https://dev.to/setevoy/kubernetes-part-1-architecture-and-main-components-overview-22g6)
[Gabor Szabo] (https://github.com/szabgab)
[Freddy Adiv] (https://github.com/FredAdiv)
[DataSciencePython](https://github.com/ujjwalkarn/DataSciencePython)
[yaml_tutorial](https://github.com/vubiostat/r-yaml)
Unlocking New Possibilities: Applications of Apache AGE Extension Part 1
Published: 2023-03-19 17:43:34

**Explanation of what Apache AGE is and its importance in the world of data analytics.**
Apache AGE is an extension of Apache Gremlin, a popular open-source graph traversal language for Apache TinkerPop, which is a graph computing framework that provides a way to store and manipulate graph data. The Apache AGE extension enables the use of SQL-like syntax to query and analyze graph data, making it more accessible and easier to work with for data analysts and developers.

In the world of data analytics, Apache AGE is important because it provides a powerful and efficient way to analyze complex, interconnected data. Graph databases are becoming increasingly popular for storing and analyzing data, particularly in fields like social networking, fraud detection, recommendation engines, and machine learning. Apache AGE simplifies the process of working with graph data, making it easier for data analysts to extract insights and develop solutions.

Apache AGE offers several benefits for data analytics, including:

**Ease of use:** Apache AGE allows developers and data analysts to use SQL-like syntax, which is a familiar and widely used language for querying and analyzing data.
Performance: Apache AGE can efficiently process large volumes of graph data, making it ideal for use cases where data volumes are high.
Scalability: Apache AGE is designed to work with distributed graph databases, making it scalable and able to handle large-scale data analysis.
Flexibility: Apache AGE can be used with a wide variety of graph databases, allowing organizations to choose the database that best fits their needs.
Overall, Apache AGE is an important tool for data analytics because it simplifies the process of working with complex graph data, making it more accessible and easier to analyze. By enabling developers and data analysts to work with graph data more efficiently, Apache AGE is helping organizations to unlock new insights and develop innovative solutions.


[Apache-Age:-https://age.apache.org/](https://age.apache.org/)
[GitHub:-https://github.com/apache/age](https://github.com/apache/age)
YugabyteDB column-level locking for UPDATE
Tags: yugabytedb, distributed, sql, lock
Published: 2023-03-19 19:19:38

In a [previous blog post] (https://dev.to/yugabyte/retype-a-column-in-yugabytedb-and-postgresql-36oj) showing how to change the datatype of a column without stopping the application, there is a phase where we need to update the new column from the old one. At the same time, the application may run some DML. This is why the update should be done in small transactions.

I mentioned that the DML that may be blocked are DELETE and UPDATE of the column that is retyped. 

The reason why DELETE conflicts with concurrent updates is obvious: the whole row is locked. 

The reason why INSERT doesn't conflict, even if the new column is updated by the trigger, is because of READ COMMITTED isolation level which can ignore new rows.

The reason why I mentioned only the update of the re-typed column is that **in YugabyteDB only the updated columns are locked**. In PostgreSQL, any update, even on other columns, would have been in conflict.

Here is what you can run to reproduce, taken from the blog post on re-typing a column:

```sql
drop table if exists demo;
create table demo ( k bigserial primary key, a int, v int default 0);
insert into demo(a) select generate_series(1,100);
alter table demo add column a_new bigint;
create or replace function a_new() returns trigger as $$
 begin new.a_new := new.a; return new; end; $$ language plpgsql;
create trigger a_new_trigger
before insert or update of a on demo for each row
 execute function a_new();
begin transaction;
insert into demo values(0,42);
update demo set v=v+1 where k=2;

\! psql -ec 'set statement_timeout to 3000' -c 'update demo set a_new=a where a_new is null'

commit;
```

I use `\! psql -ec`  to run the concurrent UPDATE from another session.

In PostgreSQL, this UPDATE fails with `ERROR:  canceling statement due to statement timeout CONTEXT:  while locking tuple (0,2) in relation "demo"
` because the UPDATE of the column `v` has locked the row:

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

Running the same in YugabyteDB doesn't block and doesn't fail:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu6qrgioo6spr0jmea2y.png)

The reason is that the UPDATE of column `v` has locked only this column within the row. And then it doesn't conflict with the update of column `a_new` (through the trigger).

The level of locking improves with database technology. The oldest databases were escalating locks to the table level. Some can still wait on a whole block like Oracle when not having enough free space for the lock information. PostgreSQL locks at row level. YugabyteDB, thanks to the key-value storage with rows and column values as documents, store lock information at the lowest level.
How To Prevent HPP and XSS Attacks In Nodejs
Tags: xss, hpp, security, node
Published: 2023-03-19 19:07:21

In today's world, cyber attacks are becoming more and more sophisticated. Two common types of attacks that websites and applications face are: 

1. HPP (HTTP Parameter Pollution) 
2. XSS (Cross-Site Scripting). 

## HPP
HPP attacks occur when the HTTP parameters are polluted with duplicate or malicious values. 

## XSS
While XSS attacks occur when attackers inject malicious scripts into a website or application. It occurs the most when we users are able to make queries using the URL. 

Fortunately, there are modules available in Node.js that can help prevent these types of attacks. The `"hpp"` module can prevent HPP attacks, while the `"xss-clean"` module can prevent XSS attacks.


## Prevent HPP
The "hpp" module works by preventing the duplication of HTTP parameters. It does this by checking each parameter and removing duplicates before passing the request to the next middleware. This ensures that the server receives only one instance of each parameter, preventing any HPP attacks that may be attempted.

1. To use the "hpp" module, simply install it using NPM 

```
npm install hpp
const hpp = require('hpp');
```

2. Require it in your code:

```
const hpp = require('hpp');
```

3. Then add the middleware to your application:

```
app.use(hpp());
```


## Prevent XSS
The "xss-clean" module, on the other hand, prevents XSS attacks by sanitizing user input. It does this by escaping characters that could be used to execute scripts, such as "<" and ">". This ensures that any user input is safe to use and cannot be used to execute malicious scripts.

1. To use the "xss-clean" module, install it using NPM

```
npm install xss-clean
```

2. Require it in your code:

```
const xss = require('xss-clean');
```

3. const xss = require('xss-clean');

```
app.use(xss());
```

In conclusion, HPP and XSS attacks are two common types of attacks that websites and applications face. Fortunately, modules such as "hpp" and "xss-clean" are available in Node.js to prevent these attacks. By using these modules in your Node.js application, you can help ensure that your application is secure and protected from these types of attacks.

I post stuff around DevOps and Backend Engineering, you can follow me if you found this helpful.
Javascript useful one liners and their explanation.
Published: 2023-03-19 18:35:24

## Introduction

JavaScript is a powerful and versatile programming language, and it's possible to write useful and concise code in just one line. Here are some examples of useful one-liners in JavaScript along with a detailed explanation:

### 1:Reverse a string:


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

This function takes a string as input and returns the same string in reverse order. It works by using the split() method to convert the string into an array of characters, then reverse() method to reverse the order of the array, and finally join() method to convert the array back into a string.

## 2.Check if a string is a palindrome:


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

This function takes a string as input and returns true if it's a palindrome (i.e. the same forwards and backwards), and false otherwise. It works by using the same approach as the previous example to reverse the string and then compare it to the original string.

## 3. Get the maximum value in an array:


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

This function takes an array of numbers as input and returns the maximum value in the array. It works by using the Math.max() method, which can accept any number of arguments. The spread operator (...) is used to spread the array into individual arguments.

## 4. Check if an array contains a specific value:


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

This function takes an array as input and shuffles its elements randomly. It works by using the sort() method, which sorts the array in place, and a comparison function that returns a random number between -0.5 and 0.5.

## 5.Get the sum of an array of numbers:


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

This function takes an array of numbers as input and returns the sum of all its elements. It works by using the reduce() method, which applies a function to each element of the array and accumulates the result. The acc parameter represents the accumulated value and curr represents the current element being processed. The initial value of the accumulator is set to 0.

## 6. Convert an object to an array of key-value pairs:


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

This function takes an object as input and returns an array of its key-value pairs. It works by using the Object.entries() method, which returns an array of arrays, where each inner array contains a key-value pair.

These are just a few examples of useful one-liners in JavaScript. With its expressive syntax and powerful built-in functions, there are countless ways to write concise and efficient code in JavaScript.
Why use Apache AGE?
Tags: apacheage, postgres, opensource
Published: 2023-03-19 18:25:23

Apache AGE is an extension currently based on powerful and robust relational database postreSQL. AGE can handle complex graph queries in an optimized manner while supporting rdbms features such as stored procedures, triggers, constraints, multi-version concurrency control, ACID transactions etc.  

The extension allows hybrid querying between SQL and cypher queries.

AGE's implementation is based on openCypher - _a graph query language originally used for querying graph database such as Neo4j_. The biggest advantage of using AGE is that users do not need to migrate data from the relational database in order to use the graph analytics and visualization. 

Moreover, AGE has the following features:
- Flexibility - users can query multiple graphs at the same time
- Fast Graph Processing - the relationships between the nodes/entities of the graph can be processed efficiently

**Applications**
- Real-time fraud detection in financial services
- Traceability and master data management in manufacturing
- Criminal and tax fraud investigation
- Recommendation Systems
- Social Network

**References**
- [GitHub](https://github.com/apache/age)
- [Installation Guide](https://dev.to/zainabsaad/install-postgresql-and-age-from-source-code-5dk7)