teleren/devto huggingface dataset:
Instalasi Ubuntu Server di Virtual Box Manager
Tags: linux, ubuntu, devops, server
Published: 2023-02-15 09:12:48

## Untuk tugas mata kuliah sistem operasi

1. Unduh file ISO Ubuntu Server dari situs web resmi [Ubuntu](https://ubuntu.com/download/server)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnmcgb028n1sjsis794g.png)
2. Unduh aplikasi [Virtual Box Manager](https://www.virtualbox.org/wiki/Downloads)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0vb7xsbiu9edvzgtrxl.png)
3. Buka VirtualBox dan klik "New" untuk membuat mesin virtual baru.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jidqsbl0ezmbvp2ixycs.png)
4. Pada layar "Name and Operating System", masukkan nama untuk mesin virtual dan pilih "Linux" sebagai tipe sistem operasi, dan "Ubuntu (64-bit)" sebagai versinya.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkl48xl7eas8ysys9pb2.png)
5. Pada layar "Base Memory", alokasikan jumlah RAM yang ingin Anda berikan ke mesin virtual. Disarankan untuk mengalokasikan setidaknya 1 GB RAM. (pada gambar mengalokasikan sebesar 2 GB RAM)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuxgh4a5hbc3yo7lg5ax.png)

6. Pada layar "File location and size", masukkan nama untuk file hard disk virtual, pilih lokasi untuk menyimpannya, dan alokasikan jumlah ruang hard disk yang ingin Anda berikan ke mesin virtual. Disarankan untuk mengalokasikan setidaknya 10 GB ruang hard disk.(Pada gambar mengalokasikan sebesar 20 GB)  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26ffd7x2xmiigvy2wk7m.png)

7. Pada tampilan Summary klik "Finish" untuk membuat mesin virtual.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjdji8h2o8alkokfj4i7.png)
 
8. Di VirtualBox Manager, pilih mesin virtual yang baru saja Anda buat dan klik "Settings".
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8yaqxqpqdnpa0nunsfx.png)
 
9. Pada jendela "Settings", klik "Storage" dan kemudian "Empty" di bawah "Controller: IDE".
10. Klik pada ikon "CD/DVD" dan kemudian "Choose Virtual Optical Disk File".
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cx0hm8jy9edjbj1vifsk.png)
 
11. Telusuri file ISO Ubuntu Server yang Anda unduh pada langkah 1 dan pilih file tersebut.
12. Klik "OK" untuk menutup jendela "Settings".
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ons1j0nu36lbeqr65rmp.png)
 
13. Mulai mesin virtual dengan mengklik tombol "Start" di VirtualBox Manager.
14. Ikuti petunjuk instalasi Ubuntu Server untuk menyelesaikan instalasi.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/by19wog2hmoc9g1ucfhl.png)
 
15. Berikut tampilan akhir pada VirtualBox Manager setelah instalasi Ubuntu server telah selesai
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tlurlvjhnzksu06v73en.png)
Get the host address for WSL2
Published: 2023-03-03 08:54:27

---
title: Get the host address for WSL2
published: true
description: If you need to do something like accessing the services on the WSL2 host, you need to get the address by yourself.
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-01 09:43 +0000
---

For WSL2, the ip address of a running distro is not static, neither the subset WSL2 uses is fixed. If you need to do something like accessing the services on the WSL2 host, you need to get the address by yourself.

Get the ip address the current running distro:

```
ip -4 -br route get 8.8.8.8 | head -n 1|awk '{print $7}'
```

Get the ip address the host(the gateway):

```
ip -4 -br route get 8.8.8.8 | head -n 1|awk '{print $3}'
```

And get the netmask:

```
ifconfig eth0 |grep netmask|awk '{print $4}'
```
AWS Cloud Quest: Decoupling Applications Study Note
Tags: aws
Published: 2023-03-03 23:38:38

This is the DIY challenge of the Decoupling Applications in AWS Cloud Quest.


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


### DIY Steps:
1. Repeat step 6-15 to create another SQS queue and subscribe
9 Reasons you need Continuous Monitoring in your company
Tags: devops, continuousmonitoring, devjournal, programming
Published: 2023-03-06 02:31:00

Continuous monitoring is a step towards the end of the DevOps process. It informs all relevant teams about the errors encountered during the production deployment.

## 9 Reasons you need continuous monitoring in your company


1. It detects any network or server problems.

2. It determines the root cause of any issues.

3. It maintains the security and availability of the service.

4. It monitors and troubleshoots server performance issues.

5. It allows us to plan for infrastructure upgrades before outdated systems cause failures.

6. It can respond to issues at the first sign of a problem.

7. It can be used to automatically fix problems when they are detected.

8. It ensures IT infrastructure outages have a minimal effect on your organization’s bottom line.

9. It can monitor your entire infrastructure and business processes.


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



Thanks for reading this.

If you have an idea and want to build your product around it, schedule a call with [me](https://calendly.com/pragyanatvade).

If you want to learn more in DevOps and Backend space, [follow me](https://dev.to/pragyanatvade).

If you want to connect, reach out to me on [Twitter](https://twitter.com/pragyanatvade) and [LinkedIn](https://www.linkedin.com/in/pragyanatvade/).
[Flutter] Solved Android clashing when native back button pressed.
Tags: flutter, android, backbutton, pop
Published: 2023-03-04 08:23:25

You can solve by 👇

```onWillPop.dart
  Future<bool> _onWillPop() async {
    final isFirstRouteInCurre
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hklmjrm3euq5ofd084o.jpeg)ntTab =
        !await _navigatorKeys[_currentTab].currentState.maybePop();
    if (isFirstRouteInCurrentTab) {
      if (_currentTab != TabItem.home) {
        _onSelect(TabItem.home);
        return false;
      }
    }
    return isFirstRouteInCurrentTab;
  }
```

🥳
Database Replication
Tags: distributedsystems, architecture, systems, beginners
Published: 2023-03-04 11:48:15

The term database replication means sharing the data to make sure it stays consistent between redundant sources like multiple databases. This helps improve reliability, fault tolerance, and accessibility.

There are two kinds of replication for the database. Let’s look at them individually.

## Master-Slave Replication

In the master-slave replication, you can have a master that gives both read and write operations alongside one or more slaves that replicate write but only gives the read operations. To top it off, each slave can replicate its new slave in a tree-like manner. The system fails if the master fails but you can have the master offline and use the slaves for all the read operations until a new master among the slaves is selected.

### Advantages of master-slave replication

- The entire database has multiple backups.
- We don’t need to disturb the master for the read operation, but we can just use the slave.
- Slaves are flexible — can be made offline and synced back at any time.

### Disadvantages of master-slave replication

- More hardware is required.
- If the master fails, downtime is created, and the loss of data is possible.
- The complexity is increased.
- All the writes are required in the master.
- As the number of slaves increases, the times we must replicate also increases causing replication lag.

![Database Replication](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5deymw5ar3e731gnak5.jpg)

## Master-Master Replication

Moving on, there is master-master replication where both are the masters with the capacity of operating both read and write operations. In case either of the master fails, another one keeps the operation intact.

### Advantages of master-master replication

- Both masters are accessible.
- Simple and automatic to use.
- Quick Failover
- The write operations are synced along both nodes.

### Disadvantages of master-master replication

- Comparatively hard to configure and deploy.
- Synchronization increases the latency in the system and if it is spared, the consistency is loosed.
- Conflict resolution is required.

## Synchronous and Asynchronous replication

On synchronous replication, data is subsequently saved in the primary and replicated storage so that they are always synchronized. However, asynchronous replication just copies the data later when the primary storage has it. The update process is done in fixed schedules which saves cost as well.

**_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!!!_**
Check file size in Ubuntu
Tags: ubuntu
Published: 2023-03-04 13:02:19


# Introduction

Linux is one of the most popular operating systems in the world. It is Unix-like, and it is also open-source. Quite a big percentage of developers use Linux because it can be customized in so many ways.

What's cool about Linux is its command line. Every 'hackers' paradise. There are a ton of commands. 

There is probably a command for almost anything that you want to do. For example what if you wanted to get the size of a directory? Well luckily for you there is a command for that. In this post, we are going to talk about that command and see what it can offer.

Reference:  [3 ways to get the size of a file in Ubuntu](\https://www.howtouseubuntu.com/filesystem/how-to-check-file-size-in-ubuntu-command/)

# The  `du`  command

This command lets the user get a quick view of the  **disk usage**. The best way to use it is by giving it the directory you want to see the size of. It should look a little something like this:
```
du directory_name  
  
// output  
2314    directory_name
```
This will give you the size of all the files and at the very end, it will give you the size of the directory itself. You could point out the full path, or you could just give the name of the directory you want to see if you are already on the same path.

But we could make this even easier just b adding 2  **flags**. Flags help the command change its behavior. For the  `du`  command we could add the flags  `-s`  and  `-h`.

 - `-s`  stands for  **summarize**  and it will show you only the total  size of the directory, without all those files popping up on your screen.
 - `-h`  stands for  **human-readable**  and it will convert the size so that you can read it easier. Just by running the command without the  `-h`  flag doesn't specify you a unit of measurement.

So now to get the best of this command, you should run it like this with the  `-s`  and  `-h`  flags:
```
du -sh directory_name  
  
// output  
44.5M   directory_name
```

And if you wanted to see all of the directories sizes, you could just run this:
```
du -sh ./*  
  
// output  
12.2M   dir1  
 2.5M   dir2  
  55M   dir3
```
Another thing you can do is use pipe(`|`) and sort them by size, which will make it even easier for you to see their sizes. What  `|`  does is get the output from the command behind it and add it into the input of the command after it. So to sort the directories by size just run the following command:
```
du -sh ./* | sort -h  
  
// output 
  55M   dir3  
12.2M   dir1  
 2.5M   dir2
```
# Conclusion

This is a pretty useful command that I think everybody should know, just because of how short and easy it is. I hope that this post has helped you and I wish you happy coding.

[Follow us on howtouselinux website to get the latest Linux updates, expert insights, and practical guides.](https://www.howtouselinux.com/subscribe)
A Beginner's Guide to Curl: Part 2 - Options
Tags: zsh, bash, http
Published: 2023-03-04 16:00:31

If you want to teach yourself how to use curl, the best resource is the manual.

Type the following command in your terminal.

```bash
$ man curl
```

The `man` command is used to read the manual for other command line utilities (like curl).  To exit the manual, just type `q`.

You should see a brief synopsis of what curl is and what it does. As you can see, there are a lot more protocols than just `http`.  For this guide we will only be using `http` since that's what the internet is built off of.

If you scroll down in the manual, you'll see a section titled "OUTPUT".  By default, curl will print the response to your STDOUT (standard output or terminal screen).

For example, exit the manual by typing `q`, and type the following in your terminal.

```bash
$ curl http://www.example.com
```

You should see the HTML response printed below to your STDOUT.  That's the default response when using curl. Now let's change that by adding an `option`.

Our first option will be the `-o` flag or its longer full version `--output`.  Whenever you pass an option to curl, you can specify it with a short name (with one dash) or a full name (with two dashes).

The `-o` or `--output` option takes one argument, the name of the file you want to write to.  This can be an existing file, or one that you haven't created yet.

Let's try it out! Type the following command.  Notice we are changing our URL now.

```bash
$ curl --output three_sentences.txt http://metaphorpsum.com/sentences/3
```

Two things just happened.  First, curl created the file you specified in your current directory.  Second, curl wrote the response from the sever to that file.

If you edit the file, you'll see the response is there.  Another way to see the contents is to `cat` the file, you'll see the contents of the file printed to your STDOUT.

```bash
$ cat three_sentences.txt
```

If you were to type the same command without the `--output` option and file name, what do you think would happen?

In the next article, we'll learn how to see more details contained in the request and response. [A Beginner's Guide to Curl: Part 3](https://dev.to/jvon1904/a-beginners-guide-to-curl-part-3-1lbc)

By the way, here are some other URLs you can try.

* `http://metaphorpsum/com/sentences/10`
* `http://metaphorpsum/com/paragraphs/3`
* `http://metaphorpsum/com/paragraphs/3/2`
Planejamento[0] <04:05>/23
Tags: study, programming, organization, planning
Published: 2023-03-05 01:21:23

## Vamos Começar Definindo que tecnologias vou estudar

- Preciso estudar Python, mais especificamente o SKLearn, numpy e outras bibliotecas para utilizar e implementar no trabalho, assim como AWS Cloud e estudar um pouco sobre a área DevOps. {A+}
- Também preciso ver C# e .NET, há tutoriais excelentes da Microsoft sobre isso, necessito me organizar pra ver -> motivo: entrei em um projeto que usa muito C# e .NET.{A}
- Continuar estudando Java também, mas em menos intensidade, só pegar um projetinho a cada 1/2 semanas.{C}
- Outro tópico para estudar é Docker ,apesar de não ter muita utilização agora, é bom pegar noções.{C}
- Electron é uma linguagem que sempre quis aprender, então vou colocar na lista, mas não é uma prioridade, nem de longe {E}
- React é algo que preciso aprender, não _agora_ e nem tão rápido, mas preciso, em quase todos os projetos irão usar. {B+}

### Ordem de Prioridade
{A+} > {A} > {B+} > {B} > {C} > {D} > {E}

### Resumo das Tecnologias
Python IA => {A+}
C#|.NET => {A}
React => {B+}
Java => {C}
Docker => {C}
Electron => {E}

## Que Aplicativos ou IDE's pretendo aprender a usar ?

- Visual Studio -> De longe a maior prioridade, IDE Incrível de absurda potência para C# e tudo. {A+}
- Vim -> Sem prioridade, dá uma olhada de leve. {E}
- Notepad++ -> Seria legal aprender, é diferenciado. {B}
React - Preventing Event Propagation from Parent Elements, Event Bubbling, Capturing, and Propagation
Tags: react, javascript, beginners, webdev
Published: 2023-03-05 08:37:15

This topic is not directly related to React, but understanding Event Bubbling and Capturing in HTML and JS can be applied to React as well.

Suppose there is a component with a div tag as the parent and a button tag as the child rendered in the DOM, as shown below:

```jsx
const Example = () => (
  <div
    onClick={(event) => {
      console.log("div clicked");
    }}
  >
    <button
      onClick={(event) => {
        console.log("button clicked");
      }}
    ></button>
  </div>
);
```
### Event Capturing and Bubbling

When the button is clicked, JS handles event propagation as follows:


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



#### 1 Starting from the top-level `Document`, it looks for the target of the `onClick` event one step at a time.

This process of finding the `target` is called `Event Capturing`.

#### 2 After finding the `target`, it goes back up to the top-level `Document`.

* This process of going back up is called `Event Bubbling`.
* While going back up, if the event registered on the element (the target, which is either the `button`, `div`, `body`, or `html`) that triggered the `Event Capturing`, then it triggers all corresponding events in order.
* Since the `button` has an event corresponding to the `onClick` event, `"button clicked"` is outputted to the console.
* As it goes up, the parent of the `button`, which is the `div`, also has an event corresponding to the `onClick` event, so `"div clicked"` is outputted to the console.
* There is no more output because `body` and `html` do not have any registered event for onClick.

### How to Prevent Console Output from the Div? - `Event Propagation`

Events occur during the `Event Bubbling Phase`. If you stop this bubbling, you can prevent the event from being executed. This is called `Event Propagation`.

You can execute propagation by calling `event.stopPropagation()`.

```jsx
const Example = () => (
  <div
    onClick={(event) => {
      console.log("div clicked");
    }}
  >
    <button
      onClick={(event) => {
        event.stopPropagation();
        console.log("button clicked");
      }}
    ></button>
  </div>
);
```

If you propagate the `button`'s event like in the above example, the event will no longer bubble up, and the `div`'s onClick event will not be triggered.
Vanilla JS for selecting a local text file and reading its content
Tags: javascript, webdev
Published: 2023-03-05 09:28:20


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


Recently I am working a small side project that aims to build a mechanical 4-keys macropad with the lowest cost possible. To make it more user friendly, I need to develop a website that let user load their previous config file (JSON) and allow them to continue their "graphical programming". I search online for a Javascript only solution that do the trick but it took me some time to reach what I need. 

To save other's time (and make sure myself won't forget this in the future), here is how you allow user to select a text file, upload it using a File Selection Dialog and read its contents in Vanilla JS

```javascript
let input = document.createElement('input');
input.type = 'file';
input.multiple = true;
input.onchange = e => { 
    let files = e.target.files; 
    for (var i = 0; i < files.length; i++){
        let read = new FileReader();
        read.readAsBinaryString(files[i]);
        read.onloadend = function(){
            //Content of the file selected
            console.log(read.result);
        }
    }
}
input.click();
```

Cheers!
Some thoughts on Rust and Elm
Published: 2023-03-05 12:00:23

Last week, my friend Joe asked me what's the best way to learn a programming language. 

I replied: Go through the basics as quickly as possible. Then begin building things with it. This is how I learn Golang. 

I had been curious about Rust for a while. And a coworker talked about how Rust was his favorite language with a lot of exuberance. I thought to myself, maybe I could do the same with Rust.

I was intimidated by “[the Rust book](https://doc.rust-lang.org/book/)”. It's a huge book of I don't know how many pages. And I never got past hello world and the curious exclamation mark after `println`.

That's when I discovered [Tour of Rust](https://tourofrust.com/) after some random Googling. Tour of Rust is a pleasant introduction to the basic syntax and concepts of Rust. With a compiler on the right side of the page, it adds some nice interactivity to the tutorial. It makes it easier to understand when you can try and change things and see how it fails.

So far my feeling is a few concepts (borrowing and referencing) in Rust are quite clever. I don't understand under what circumstances lifetime needs to be managed manually. Then it feels like a few things are added as an afterthought, which leads to a certain degree of internal incongruity in its syntax.

Yet despite the tribal sentiment among Go developers and Rust developers, these languages feel more similar than different.

Curiously, after searching Rust on YouTube, the algorithm god recommended a million Elm talks with one of them promising [to give you happiness](https://www.youtube.com/watch?v=kuOCx0QeQ5c).

Incidentally, I read a blog post from the Warp team about [building a UI in Rust](https://www.warp.dev/blog/why-is-building-a-ui-in-rust-so-hard).

In a gist, it was difficult to build a UI in Rust if they followed the [widget tree](https://docs.flutter.dev/development/ui/widgets-intro) approach of Flutter. Because multilayers of object inheritance do not feel natural or intuitive in Rust.

Although they used a close but different approach, the Model-View-Update approach used in the [Elm architecture](https://guide.elm-lang.org/architecture/) was an inspiration for the Warp team.

To use an inaccurate analogy in React terms, `Model` is like `Redux`, it manages all the states in your entire app. `View` manages the virtual DOM that renders the page as the states change. `Update` makes changes to the state upon receiving messages (events) when the user interacts with your app. Pretty neat.

What's charming about Elm is it's easier, way easier, linting and debugging that works out of the box. You don't need to configure anything, it just works. This is so much better than React.

But you do need to learn a new language and get used to the functional programming way of thinking.

Bottom line: Rust and Elm are both fun. Don't know if or when they will be useful at work.