teleren/devto huggingface dataset:
Transactions
Tags: distributedsystems, architecture, beginners, tutorial
Published: 2023-03-17 05:52:12

Transactions are a series of database operations. Each transaction is a single unit of the main task. The data integrity is intact in these transactions since all the operations either fail together or succeed together.

Generally, some databases choose to leave out [ACID](https://dev.to/pragyasapkota/relational-database-43l4) transactions because of the other required optimizations and theoretically impossible implementations. As we have already discussed before, ACID transactions are supported by a [relational database](https://dev.to/pragyasapkota/relational-database-43l4) while [BASE transactions](https://dev.to/pragyasapkota/non-relational-database-387p) are supported by a [non-relational](https://dev.to/pragyasapkota/non-relational-database-387p). However, there are exceptions where the [relational database](https://dev.to/pragyasapkota/relational-database-43l4) doesn’t support ACID transactions but some of the [non-relational](https://dev.to/pragyasapkota/non-relational-database-387p) ones do.

## States on the transactions

![Transaction States](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zpg3kxtf04yo1a0g2je.jpg)

Any transaction that happens in the database can be in either of the following states: -

1. **Active** — Initial State of every transaction where they are being executed.

2. **Partially Committed** — When a transaction executes its very last operation.

3. **Committed** — When a transaction finishes all the operations successfully. The effects establish themselves in the database system afterward.

4. **Failed** — When the checks on the database recovery system fail and cannot go further.

5. **Aborted** — When the transaction reaches the failed state, the recovery manager stops all the write operations which bring the database to the original position before the execution started. The henceforth state is now called aborted and moving forward, the transactions can either restart or kill themselves.

6. **Terminated** — When there are no abortions and the transactions come through successfully, the database system becomes consistent, and the transaction is terminated while the new one will soon start.

**_I hope this article was helpful to you._**

**_Please don’t forget to follow me!!!_**

**_Any kind of feedback or comment is welcome!!!_**

**_Thank you for your time and support!!!!_**

**_Keep Reading!! Keep Learning!!!_**
Merge Array Interval
Tags: javascript, leetcode
Published: 2023-03-17 05:40:59

Approach to solve these types of question:

let say suppose we have two data
let A = [1,3]
let B = [2,4]

Now if we have to check if these two overlaps or not we can do the following

1) lets say MaxValue =  take the Max of A[0] & B[0] i.e Max of [1] [2] is 2
2) lets say MinValue = take the Min of A[1] & B[1] i.e Min of [3] [4] is 3

Now compare MaxValue & MinValue

```js

  if (MaxValue <= MinValue) {
    // overlaps
    return true;
  } else {
    // no overlaps
    return false;
  }

```

Suppose you have array of intervals example

```js
let intervals =[
    [1, 3],
    [2, 6],
    [8, 10],
    [15, 18],
  ];
```

we can sort interval first & then can do the merging

```js
 `intervals.sort((a, b) => a[0] - b[0]);`
```




[Insert Interval](https://leetcode.com/problems/insert-interval/)

```js
/**
 * @param {number[][]} intervals
 * @param {number[]} newInterval
 * @return {number[][]}
 */
/**
 * @param {number[][]} intervals
 * @param {number[]} newInterval
 * @return {number[][]}
 */
var insert = function(intervals, newInterval) {
    const result = [];
    
    for (let i = 0; i < intervals.length; i++) {
        let interval = intervals[i];
        
        // If overlaps
        if (Math.max(interval[0], newInterval[0]) <= Math.min(interval[1], newInterval[1])) {
            newInterval = [Math.min(interval[0], newInterval[0]), Math.max(interval[1], newInterval[1])];
            continue;
        }
        
        // If lower
        if (interval[0] > newInterval[1]) {
            result.push(newInterval, ...intervals.slice(i));
            return result;
        }
        
        result.push(interval);
    }
    
    result.push(newInterval);
    return result;
};
```

[Merge Intervals](https://leetcode.com/problems/merge-intervals/description/)

```js
/**
 * @param {number[][]} intervals
 * @return {number[][]}
 */
var merge = function (intervals) {
  let next = [];
  let j = 0;
  intervals.sort((a, b) => a[0] - b[0]);
  next.push(intervals.shift());

  for (let i = 0; i < intervals.length; i++) {
    let currentInterval = intervals[i];
    if (next[j][1] >= currentInterval[0]) {
      next[j] = [next[j][0], Math.max(next[j][1], currentInterval[1])];
    } else {
      next.push(currentInterval);
      j++;
    }
  }
  return next;
};

```
[Remove Covered Intervals] (https://leetcode.com/problems/remove-covered-intervals/description/)
```js
/**
 * @param {number[][]} intervals
 * @return {number}
 */
var removeCoveredIntervals = function(intervals) {
    let next = [];
  let j = 0;
  intervals.sort((a, b) => a[0] - b[0]);
  next.push(intervals.shift());

  for (let i = 0; i < intervals.length; i++) {
    let currentInterval = intervals[i];
    if (next[j][0] <= currentInterval[0] && currentInterval[1] <= next[j][1]) {
      next[j] = [next[j][0], next[j][1]];
    } else if (
      next[j][0] >= currentInterval[0] &&
      currentInterval[1] >= next[j][1]
    ) {
      next[j] = [currentInterval[0], currentInterval[1]];
    } else {
      next.push(currentInterval);
      j++;
    }
  }
  return next.length;
};
```
Shell Scripting CheatSheet
Published: 2023-03-17 05:33:45

`echo hello` : to print anything.
`echo $PATH`: to show all the paths in my machine.
`which echo`:
`pwd`: present working directory. it will show my current directory.
`ls -l` : will print folder structure with additional info.
`mv test new_test` : rename test folder to new_test
`cp test.csv new_test` : it will copy test.csv to new_test directory cp ${selected file or directory}` ${directory name where file will be moved}`
`rm full_doc_test.csv` : to remove a file
`rmdir test `: to remove empty directory
`man ls` : it will show the manual about ls.
`ctrl+l `: to clear terminal
`echo hello > hello.txt` : it will create a txt file and write hello on it .
`cat hello.txt `: it will print the content of file .
`cat < hello.txt `: it will open hello.txt, and takes its content as input of cat. and cat will show it's output.
`cat < hello.txt > hello2.txt` : it will open hello.txt, and takes its content as input of cat and then wrtie input to hello2.txt
`ls -l / | tail -n1`: tail-n1 print last line . | this name is pipe . pipe takes the outpur of the program to the left and make it input to program is in right . `ls-l `show folder structure and pipe takes it's output and make it as input of `tail -n1` . pipe wires left side program to right side program .
`curl` : a command line tool that enables data exchange between a device and a server through a terminal
`curl - head - silent google.com`

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

`cd /sys` showing kernal parameter

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

`cd /class `-> it will show devices directory that machine can interact with from where I can modify device like pc brightness etc .

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0jmtkuojmows591gbvn.png)
How to setup Google Tag Manager in Magento 2 store
Tags: webdev, tutorial, wordpress
Published: 2023-03-17 05:17:16

In this blog entry, you can find a point-by-point instructional exercise on **_How to setup Google Tag Manager in Magento 2 store_**. GTM is an integral asset that empowers vendors to follow client conduct on their internet-based store, assisting them with distinguishing the specific pages where clients forsake their trucks and increment deals. The aide gives a bit-by-bit approach for designing GTM in a Magento 2 store, which incorporates making a GTM record and holder, recovering the GTM Record ID and Compartment ID, getting the Google Examination 4 Estimation ID, and adding GTM code and IDs to the Magento store. It is featured that involving a GTM expansion for Magento can improve on the joining system for Magento Open Source stores. The aide likewise incorporates directions for introducing the "Google Label Chief and Facebook Pixel for Magento 2" augmentation. Generally speaking, this post can be an important asset for dealers who need to follow guest conduct on their Magento 2 store utilizing GTM.

For more information , Please visit this :- [https://webguru.dev/how-to-setup-google-tag-manager-in-magento-2-store/](https://webguru.dev/how-to-setup-google-tag-manager-in-magento-2-store/)
Zerando HackerRank ( 16 )
Published: 2023-03-17 05:07:59

E no décimo sexto episodio desta serie que queima os miolos, vamos abordar um problema que envolvendo um prisioneiro.
Neste problema temos uma cadeia, com uma mesa redonda para entregar doces para os presos, porem o último a receber o doce recebera o mesmo podre.
Neste desafio devemos descobrir quem será o último coitado a receber o doce podre.

Vamos receber 3 parâmetros:

**n** = prisioneiros.
**m** = quantidade de doces.
**s** = ponto inicial da mesa.

Para resolver essa questão vamos criar a função "saveThePrisioner".
E apenas com uma única linha podemos resolver tal problema:
Nossa função vai ficar assim:

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

A primeira parte da fórmula "(m - 1 + s) % n" calcula o número do último prisioneiro a receber um doce, considerando que a distribuição começa no prisioneiro s e que os doces são distribuídos um a um até que não haja mais doces.

A segunda parte da fórmula "|| n" garante que, se o resultado da primeira parte for zero, o último doce será entregue ao último prisioneiro, ou seja, o número total de prisioneiros.

E assim resolvemos mais um desafio.
Backend example tutorial
Tags: tutorial, python, vietnameseblogs
Published: 2023-03-17 02:06:50

## I.	Python tutorial example:

1.	Tạo môi trường ảo (virtual environment)

Step 1: CMD: pip install virtualenv
Step 2: Truy cập vào folder project, CMD: python -m venv env
Step 3: Kích hoạt môi trường ảo, CMD: env\Scripts\activate (Đối với Win), source env/bin/activate (Đối với linux)
Step 4: Cài đặt các thư viện cần thiết cho project <2>
Step 5: Để out môi trường ảo sử dụng CMD: Deactivate

2.	Cài đặt các thư viện cần thiết cho project

Step 1: Tạo tệp txt chứa tên các thư viện cần thiết cho project (thường tên file là requirements.txt)
Step 2: pip install –r requirements.txt
Một số câu lệnh cần thiết: 
-	pip freeze: liệt kê tất cả thư viện đã được cài đặt tại môi trường ảo
-	pip uninstall –r requirements.txt: xóa tất cả thư viện đã cài được viết trong txt.

## II.	Flask tutorial example:

Flask là framework chứa nhiều thư viện để triển khai project website hoàn chỉnh. 
Sử dụng thư viện flask_restful để tạo ra các apis xử lý và tương tác CRUD dưới DB.
Input các API: Query parameters, Path parameters, Request Body, HTTP methods
Notes: HTTP methods có 4 loại chính GET(lấy dữ liệu), POST(tạo dữ liệu), PUT(sửa dữ liệu), DELETE(xóa dữ liệu). Với method GET thì không nên có Request Body
Ví dụ về Path và Query parameters:
-	GET/users?limit=5 (trả về 5 giá trị đầu khi query select user)
-	GET/users/{id} => GET/users/3 (trả về kết quả query select user where id =3)
Output các API: JSON, XML, CSV, HTML, text

## III.	Common Python ORM (SQLalchemy)
ORM là object relational mapping dùng để dễ dàng kết nối giữa đối tượng class map với bảng trong database. Thông qua ORM sẽ hỗ trợ các hàm tương ứng với các câu lệnh query dưới DB.
Đọc thêm tại: ORM Mapped Class Overview — SQLAlchemy 2.0 Documentation

## IV.	Redis – Cache (Flask queue)

1.	Redis – cache dùng để lưu các dữ liệu tạm thời trong bộ nhớ đệm, ngoài ra còn dùng để xử lý các logic làm tăng hiệu suất và khả năng mở rộng.

2.	Flask queue
Đọc thêm tại: Asynchronous Tasks with Flask and Redis Queue | TestDriven.io

## V.	APIs Gateway, Service Discovery (Library Kong)
APIs Gateway, service Discovery dùng cho các kiến trúc phần mềm Microservice. Một hệ thống có nhiều servers nên để có thể kết nối truyền dẫn input và output giữa các server nên phải dùng Service Discovery. APIs Gateway dùng để khi apps gọi API sẽ được điều hướng đúng đến API của server chứa API đó thông qua prefix url. Ngoài ra APIs Gateway dùng để authen xác thực khi gọi các APIs. 
Đọc thêm tại: Building a geocoding plugin for the Kong Gateway using Python | Kong Inc. (konghq.com)

## VI.	Docker
Đọc thêm tại: DevOps with Docker | DevOps with Docker
Thinking in React (Visualized)
Tags: javascript, typescript, beginners, webdev
Published: 2023-03-17 04:44:28

---
title: Thinking in React (Visualized)
published: true
description: How to think in React ?
tags: javascript, typescript, beginners, webdev
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-16 05:26 +0000
---

When working with React.js, one of the most important thing you need to do is to shift your thinking.

It introduces a new mental model for developers to think and approach developing User interfaces (UI) in an easy and understandable way.

You declare how your HTML should look and act without worrying about the details.

React.js handles all the details of the HTML like rendering, updating and removing elements from the HTML DOM for you.

The documentation describes this as “Thinking in React”.

Yeah... but what does that actually mean ?

Let’s dive into the process with an example!

### 1. Isolate the User Interface into independent components

When we look at an User Interface (UI), we need to think about the “components” or the parts that make up the whole.

![Image Isolate the User Interface into independent components](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l2n3ynft5z5rx45gyrv5.png)

In this example, this LinkedIn Page Card will likely be composed of:

- `Card`
- `Button`
- `Image`

All of the individual components add up to the whole of the User Interface (UI). 

### 2. Create an hierarchical data relationship

Now that we have our individual components, we now need to think about how they relate to each other.

In addition, how will the “data flow” through out these components.

In this example, `Card` will be the parent, and the data will flow downwards (pass via props) to the children (`Button`, `Image`).

![Image Create an hierarchical data relationship](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eh7p64gx37jj7i17cdtl.png)


### 3. Think about where the state should live

Within React.js, each components can have their own state (using `useState`).

The question comes down to: **Where should we put the state ?**

Looking at the “Follow” button, we may need an external API which means we may need some loading state while that gets processed.

So, in this case, the state is better kept within the `Card` component.

![Image Think about where the state should live](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzy7shjfeo4sa0gwl85n.png)

### 4. Write the Code

Once you are finished with designing the components, state and data flow.

It’s time to actually code it out!

**Here is what the scaffold may look like:**

![Image Write the react code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mthtutuj5x1g6j9pvg6a.png)

And... That’s it!

Did you learned something new ?

Be sure to give it a reaction then share it with someone who think will enjoy this post! ❤️

----


Hey, I am also on LinkedIn - https://www.linkedin.com/in/ijerrychang/.

I am always looking to connect with like minded techies 🤓 - just send me an invite!
How I Became a Developer
Tags: wecoded, beginners
Published: 2023-03-17 04:43:08


As an Asian man living in Taiwan, I always knew that computer science was the field for me. However, it wasn't until recently that I decided to pursue a career in development.

I majored in computer science at university, but I found it difficult to fully grasp the concepts and apply them in real-life scenarios. I struggled to keep up with the pace of the courses and often found myself feeling frustrated and overwhelmed.

After graduation, I decided to take some time off to reassess my interests and goals. During this period, I stumbled upon some online courses that taught me the basics of programming. I was fascinated by how I could write a few lines of code and create something that could solve a real-world problem.

I started out as a complete beginner, but with the help of some online courses and a lot of practice, I began to gain a better understanding of programming languages like Java and Python. Despite the challenges, I never gave up and continued to push myself to learn more.

As I delved deeper into the world of development, I realized that open source projects were a great way to not only contribute to the community, but also to enhance my own skills. However, as a beginner, I found it difficult to navigate the complexities of these projects.

It was a slow process, but I soon found myself gaining more and more confidence in my abilities. I even started attending developer meetups and hackathons in Taiwan, where I got to meet other developers and learn from their experiences.

Although I am still a beginner, I am excited to continue learning and growing as a developer. I know that the road ahead will be tough, but with hard work and dedication, I am confident that I can make meaningful contributions to the field of computer science.

I hope that my story can serve as a source of inspiration for other beginners out there who are struggling to break into the world of development. With patience, perseverance, and a willingness to learn, anyone can become a successful developer.
10 Tools and Technologies Every Developer Should Know About in 2023⚒️.
Tags: webdev, programming, tools, productivity
Published: 2023-03-17 04:15:34

**Introduction**: In the ever-evolving world of technology, it's important for developers to stay up-to-date with the latest tools and technologies to remain competitive and produce top-notch work. In this post, we'll explore 10 tools and technologies every developer should know about in 2023.

1. **Kubernetes** 🐳- a popular container orchestration tool that helps developers deploy, scale, and manage containerized applications.

2. **GraphQL** 🕸️- a query language for APIs that offers a more efficient, powerful, and flexible alternative to REST APIs.

3. **Flutter** 📱- a UI toolkit for building natively compiled applications for mobile, web, and desktop from a single codebase.

4. **Next.js** 🌎- a React-based framework for building server-side rendered (SSR) and static websites that offers improved performance, SEO, and developer experience.

5. **Deno** 🦕- a secure runtime for JavaScript and TypeScript that offers better security, performance, and developer experience compared to Node.js.

6. **Apache Kafka** 📊- a distributed streaming platform that helps developers build real-time data pipelines and streaming applications.

7. **Rust** 🔧- a systems programming language that offers high performance, memory safety, and concurrency without sacrificing developer productivity.

8. **DevOps** 🛠️- a set of practices and tools that help developers and operations teams collaborate more effectively to deliver software faster and with better quality.

9. **Artificial Intelligence and Machine Learning** 🤖- technologies that enable developers to build intelligent applications that can learn and adapt to user behavior and data.

10. **Blockchain** 🔗- a distributed ledger technology that offers secure, transparent, and decentralized solutions for various use cases, including finance, healthcare, supply chain, and more.

**Conclusion**: As a developer, it's important to keep learning and exploring new tools and technologies to stay ahead of the curve. These 10 tools and technologies can help you build better software, improve your productivity, and advance your career in 2023 and beyond.
5 Myths Causing Cloud Waste
Tags: aws, architecture, beginners, finops
Published: 2023-03-17 04:10:47

I (actually) tried this with my 15+ clients so far.

More often than not, I was right about these myths.

Want to become a (much) better FinOps specialist or a cloud designer?

Here are my top 5 myths you should understand first:

+ Stable Cost ≠ Optimum Cost
+ Reservations are not limited to compute services
+ Orphan's are sleeper cells, don't take it light.
+ Prefer sustainable and cost effective approach than quick wins
+ Storage costs can surpass your imagination, keep a watch.

Hope you find the next few seconds useful! 🚀


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


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


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


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


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


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


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


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


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


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


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


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

Feel freel to follow me here: https://www.linkedin.com/in/govardhana-miriyala-kannaiah/

for more cool content related to cloud and devsecops !
Pick cost effective compute choice in 2 mins
Tags: aws, beginners, finops, devops
Published: 2023-03-17 04:04:11

Selecting a cost-effective instance in AWS may be complex for many, hence we see a lot of unnecessary on-demand instances usage.

I tried to simplify this exercise so that one can pick in 2 minutes.

Here I am sharing this with you all 👇


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

Feel freel to follow me here: https://www.linkedin.com/in/govardhana-miriyala-kannaiah/

for more cool content related to Cloud and DevOps!