teleren/devto huggingface dataset:
Live Reloading in Rust with Cargo Watch and Docker
Tags: rust, programming, tutorial, development
Published: 2022-10-18 16:19:46

Helo everyone 👋🏻
Today I want to share with you how we can observe changes in Rust using Docker Containers. This is a continuation of the article [Hot Reload in Rust with Cargo Watch](https://dev.to/devjorgecastro/hot-reload-in-rust-with-cargo-watch-5bon)

1 - First and foremost, we must create a DockerFile in the project's root directory and include the code below.

```Dockerfile
# Using official rust base image
FROM rust:alpine3.16

# Set the application directory
WORKDIR /app

# Install musl-tools to make many crates compile successfully
RUN apk add --no-cache musl-dev

# Install cargo-watch
RUN cargo install cargo-watch

# Copy the files to the Docker image
COPY ./ ./

```

Dockerfile is a plain text file that contains instructions that Docker will use to build an image. [see more](https://medium.com/r/?url=https%3A%2F%2Fdocs.docker.com%2Fengine%2Freference%2Fbuilder%2F)



<br />
2 - ~~The following step is to create the image using the command below~~.
```docker
docker build -t rust-observable-image .
```

You should then see on your terminal the response confirming that the image has been successfully built.
`[+] Building 430.0s (10/10) FINISHED`

![Building result of Docker Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duknbkowoszswfhwm8c1.png)


We can verify that the image is created.
```docker
docker images
```

![List Docker images command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2305jmy072ojxtbevbe9.png)


3 - The next step would be to run the container and run the "cargo watch" command inside the container, but we're going to do something more automated using Docker Compose. So we don't need to run step 2 because when we start the container with Docker Compose it will run automatically.

<br >
So we need to create a docker-compose.yml file inside the root directory of the project and add the following instructions:
```yaml
version: "3.9"
services:
    app:
        build: .
        container_name: "cargo-watch-example"
        volumes:
            - .:/app
        command: sh -c "cargo watch -x run"
```

4 - The final step is run the container with Docker Compose

```docker
docker compose up
```

![docker compose up](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8690zq5kk3m3k4zkxmeg.png)


From now on you will be able to make changes to your project and observe the changes from your container.
<br />



If you like my content and want to support my work, you can give me a cup of coffee ☕️ 🥰

[![Ko-fi](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j18vjijbegi1dhp83ozv.png)](https://ko-fi.com/devjorgecastro)

[![Buy me a coffee](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdz714gpdbxv6ve001hf.png)](https://www.buymeacoffee.com/jorgecastro)


### Follow me in
Twitter: [@devjcastro](https://twitter.com/devjcastro)
<br />
Buy VPS with Crypto at Cloudzy 🪙
Tags: cloud, bitcoin, aws
Published: 2022-10-18 16:16:49

**Cloudzy**, a company that provides Premium VPS Hosting and allows customers to purchase their services using Cryptocurrency.
United States - October 11, 2022 —

**Cloudzy** is a company that has provided Premium **Virtual Private Server Hosting** since 2008. The high-performance Premium VPS servers are available at more than 15 locations worldwide. Interested users can get them for as low as $7.95 a month. Besides, the company also offers various services to clients and more can be found here: https://cloudzy.com/

With the company supporting crypto payment, customers can buy **VPS with bitcoin**. Paying with cryptocurrencies such as Bitcoin, Ethereum, Litecoin, and other altcoins helps buyers stay anonymous. Buyers can also purchase the VPS by paying with PayPal or Perfect Money at the most reasonable price from Cloudzy. All of the VPS machines run on the latest top-tier hardware and feature ultra-high bandwidth and low latency, located in **15 reliable data centers worldwide**.

Amongst other services, Cloudzy also allows clients to effortlessly create perfect **websites**, game-changing **web apps**, and successful trading bots by using their KVM-powered VPS Hosting Solutions. The company will provide clients free operating systems and top-tier control panels, allowing them to run and configure their ideal VPS at an affordable price. Cloudzy offers free installation of **Linux** distro or **Windows** of the client’s choice at no extra charge. 

**Remote desktop** solutions are also part of the services that Cloudzy provides. The team will help clients launch their Windows-powered remote desktop at a location of their choice. By choosing Cloudzy, clients are granted full root access to secure, stable and easy-to-use **RDP** servers and free Windows installation.

“By buying the service with us, clients are guaranteed 24/7 uptime with the most reliable hardware and network connections,” said a spokesperson for Cloudzy. “The customer care team is ready 24/7 to provide customers with support on all their problems. If customers are unsatisfied with Cloudzy service, the company offers a 7-day money-back guarantee.”

## About Cloudzy

Cloudzy rebranded from RouterHosting in late 2021. The company was started by a young entrepreneur and developer that looked into starting a business to match his talents. This turned out to be **Virtual Machine** technology and it got him to think about Virtual Private Servers which slowly became popular in 2008 and saw the company grow to greater heights by aiming to make VPS hosting and Remote Desktop connections easy and affordable to everyone.

This press release was originally published at APnews. For original copy please go to:
[https://apnews.com/press-release/marketersmedia/cryptocurrency-technology-business-5c12b69176af054e00df58157174bee3](https://apnews.com/press-release/marketersmedia/cryptocurrency-technology-business-5c12b69176af054e00df58157174bee3)

**Contact Info:**
Name: Allen
Organization: Cloudzy VPS Hosting
Website: https://cloudzy.com/
Stellar Quests Level 1: Create Account
Tags: stellar, xlm, programming, tutorial
Published: 2022-10-18 16:04:34


## What are Stellar accounts?

Accounts on the Stellar blockchain are the "central data structure which hold balances, sign transactions, and issue assets". Each account needs a keypair and the required minimum balance of Lumens ($XLM) in order to exist.

## How are Accounts created?

Before an account can be created, a keypair needs to be generated. A keypair itself does **NOT** instantiate an account. The Stellar blockchain implements this rule so that there isn't an abundance of unused accounts. In order for an account to be instantiated, one must first send at least 1 Lumen ($XLM) to the public key address.

This gets done by building a transaction of operation type "Create Account". This operation asks for three inputs: destination, starting balance, and source account. The *Destination* would be the public key from the keypair that was generated. The *Starting Balance* is the amount one wishes to fund the new account with; which must be greater than 1 Lumen ($XLM). The *Source Account* is the public key of the account that will be sending the funds; plus, this input is optional because if the funds will not be sent by the account which has built the transaction, then the public key entered here will refer to the account that is. NOTE: All transactions **MUST** be signed off by all source accounts mentioned; in this case, the account which built the transaction and the account which is funding the new account.

## Accounts and their balances

Accounts may hold different balances of different types of assets. There are two types of assets. There's the native asset "Lumen ($XLM)", and then there are "custom assets". In future blog posts, I'll be covering custom assets and how they're established.

> I plan on writing corresponding blog posts with relevant code examples. For now, I am simply learning the basics of the Stellar blockchain and utilizing the Stellar Laboratory in order to interact with the test net. If you wish to learn about the Stellar blockchain, and earn while doing it, then please visit: https://quest.stellar.org/
Analyzing and cleaning data using pandas
Published: 2022-10-18 16:03:39

## Analyzing data using pandas

It is advisable to first make a quick overview of  your dataset once you load your data into dataframes, a dataset can be in a csv format therefore to load it into dataframe we use the following,

```
import pandas as pd
dx=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\RECORD2.csv")
print(dx)
```
we can view our data in various ways which includes,

- head() function 

it is a function that returns the headers and specified number of rows from top.

```
import pandas as pd
dt=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\datas.csv")
print(dt.head(10))
```


- tail() function 

it returns the headers and specified number of row from bottom.

```
import pandas as pd
dt=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\RECORD2.csv")
print(dt.tail())
```

- info () function
 
it is a function that gives more information about your dataset that is it show datatypes, non-null cells,memory among others.

```
dt=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\RECORD2.csv")
print(dt.info())
```

- describe() function

the function gives the description of your data that is the function shows the mean,median,standard deviation,maximum among others.

```
dt=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\RECORD2.csv")
print(dt.describe())
```

## Cleaning data using pandas

cleaning data is simply removing bad  data  in dataset,this may involve removing empty cells,removing duplicates,checking data with wrong format.

- removing of duplicates

duplicates are rows that have been registered more than once.
to remove duplicates we use the duplicated() function which returns a boolean value that is True if duplicates exist else returns False.

```
dt.duplicated().sum()
```

- removing empty cells 

we remove the empty cells using dropna() function,this is a method that returns  new dataset and will not change the original dataset.

```
dt = pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\datas.csv")
data1=dt.dropna()
print(data1)
```

- cleaning wrong data

we fix wrong data  in two ways  that is by replacing the wrong values or removing those wrong values.

1. _removing wrong data_
```
dx=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\RECORD2.csv")
dx.dropna(subset=['fname'],inplace=True)
print(dx)
```

2._replacing wrong data_


```
dx=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\RECORD2.csv")
for line in dx.index:
    if dx.loc[line,'ASSIGN 2']>90:
        dx.loc[line,'ASSIGN 2']=10
print(dx)
```

- cleaning wrong format

it may difficult  and impossible to analyze data with some columns or rows having wrong format.wrong format can be a row having multiple datatypes , to fix this one can convert the entire row into one datatype or remove the entire row from dataset.
removing entire row

```
dx=pd.read_csv(r"C:\Users\ADMIN\Desktop\EXCEL\RECORD2.csv")
dx.dropna(subset=['row 3'])
print(dx)
```
Building a local Kubernetes cluster using k3d
Tags: kubernetes, docker, k3d, beginners
Published: 2022-10-18 15:56:36

k3d is a lightweight wrapper to run k3s (minimal Kubernetes distribution from Rancher Labs) in Docker.

By using k3d, we can create single and multi node k3s clusters in Docker for local development purpose.

In this blog, we are going to use Ubuntu 20.04 LTS for setting up k3d.

---

Install Docker using the convenience script

```
$ curl -fsSL https://get.docker.com -o get-docker.sh

$ sudo sh get-docker.sh
```

Add your user to the docker group to execute commands as non-root user and log out from the current session

```
$ sudo usermod -aG docker $USER
```

Log back in and verify the Docker commands as non-root user

```
$ docker info

$ docker container run hello-world
```

Download and install k3d

```
$ curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash

$ k3d version
```

Download and install kubectl

```
$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

$ sudo install kubectl /usr/local/bin/kubectl

$ kubectl version --client
```

Create the cluster using the below configuration file

```
$ cat config.yml
```

```
apiVersion: k3d.io/v1alpha4
kind: Simple
metadata:
  name: dev
servers: 1
agents: 2
image: rancher/k3s:v1.25.2-k3s1
ports:
- port: 30000-30100:30000-30100
  nodeFilters:
  - server:*
registries:
  create:
    name: dev
    host: 0.0.0.0
    hostPort: "5000"
options:
  k3s:
    extraArgs:
    - arg: --disable=traefik
      nodeFilters:
      - server:*
```

```
$ k3d cluster create --config config.yml
```

Check the cluster details and nodes

```
$ kubectl cluster-info

$ kubectl get nodes
```

---

Create a sample index.html file

```
$ echo "Hello from Pod!" > index.html
```

Build a custom Docker image using the below Dockerfile

```
$ cat Dockerfile
```

```
FROM nginx:1.23
COPY index.html /usr/local/nginx/html
```

```
$ docker image build -t app:v1 .
```

Tag the custom built image and push to the container registry created by k3d

```
$ docker image tag app:v1 localhost:5000/app:v1

$ docker image push localhost:5000/app:v1
```

Deploy a pod using the custom built image

```
$ cat app-pod.yml
```

```
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: app
  name: app
spec:
  containers:
  - image: dev:5000/app:v1
    name: app
    ports:
    - containerPort: 80
```

```
$ kubectl create -f app-pod.yml
```

```
$ kubectl get pods
```

Expose the pod to a node port service

```
$ cat app-nodeport.yml
```

```
apiVersion: v1
kind: Service
metadata:
  labels:
    run: app
  name: app-nodeport
spec:
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30000
  selector:
    run: app
  type: NodePort
```

```
$ kubectl create -f app-nodeport.yml
```

```
$ kubectl get svc
```

Verify the webpage using browser or curl

```
$ curl http://localhost:30000
```
How to push env variable to React in runtime?
Tags: react, docker
Published: 2022-10-18 15:54:43

Hi,

I am using web-pack to my react application. Requirement is we have to deploy same React container in different env (dev, test, QA, Prod), now the variables are env specific. I want to create the container image once and deploy the same image to all the env with env variables. Issue is web-pack not accepting run-time variables. 

can any one help how to achieve build once and deploy many for React apps?

Br,
Tanmoy
ANGULAR COMPONENT LIFECYCLE HOOK METHODS YOU SHOULD KNOW
Tags: javascript, angular, webdev, programming
Published: 2022-10-18 15:52:17

First, let’s break down the two major words here which are “Lifecycle” and “Hook”.
•	Lifecycle encompasses the stages that the component 
        undergoes from its creation to its destruction which would 
        mean death when we talk about a living organism.
•	Hook categorizes the different breakpoints that the 
        component passes through from when it was created.
*

## *WHAT IS THE ANGULAR LIFECYCLE HOOK**
A component instance has a lifecycle hook that starts when Angular instantiates a component class the minute you create an application and renders the component view along with its child views.
A lifecycle continues with change detection, that is a change occurs that is also part of the lifecycle of a component.
It updates both views and the component instances as needed as it checks to see what data-bound properties change.
The lifecycle ends when Angular destroys the component instance and it removes the rendered templates from the DOM. 
You can check more on the DOM  https://medium.com/@ojigbareoyinemi2/dynamics-of-a-basic-counter-javascript-project-5690426a86da
NB: Directives can also have lifecycle hooks.
This is a list of lifecycle hooks in Angular:
•	**ngOnChange()**
•	**ngOnInit()**
•	**ngDocheck()**
•	**ngAfterContentInit()**
•	**ngAfterContentChecked()**
•	**ngAfterViewInit()**
•	**ngAfterViewChecked()**
•	**ngOnDestroy()**

You need to know these three life cycle methods out of the eight:
•	**ngOnChange() **: This occurs whenever anything on a 
        component changes this lifecycle method is called or used.
•	**ngOnInit()**: This is the most commonly used lifecycle 
        method it is present immediately after you create the 
        application on angular CLI.
Whenever we load any component the constructor is called next then the ngOnInit() is called.
Constructor: A constructor is basically a part of a class.
What happens when you create a component using Angular is it initiates a class, then when a class is initiated then the constructor is called after those properties are added then the constructor is called after the properties are added then the view is loaded. Then when this process is completed and the constructor is ready to mount, then the ngOnInit lifecycle is created. This ngOnInit means when the component is ready to be mounted on the HTML of the DOM. That’s why it’s called after the constructor.
•	**ngOnDestroy()**: This helps repeated instances or loops 
        in the component lifecycle to be ended easily. When this 
        component lifecycle is called or used.

## **Conclusion**
You may not necessarily use all of this Angular component lifecycle hook  but the three explained will be essential for your daily usage as you build applications using angular framework.
Happy Coding.
Where to start when developing from scratch with Python?
Tags: beginners, python
Published: 2022-10-18 15:50:42

Hello lovely dev.to community!
I am studying Software Engineering and for an assessment in the future I need to either solve a small problem or code a small software. The assessment takes 20 minutes. An example of a past exam questions is: Code me the game Tic Tac Toe.

Where would I start with a task like this? My programming language of choice is Python and I finished the basic chapters of the book "Python Crash Course".

Thank you very much in advance and happy coding! <3
Store in Svelte
Tags: svelte
Published: 2022-10-18 15:44:14

A store is simply an object with a subscribe method that allows interested parties to be notified whenever the store value changes:
```
<script>
  let countValue;
  const unsubscribe = count.subscribe(value => {
    count_value = value;
  });
  onDestroy(unsubscribe);
</script>

<h1>The count is {count_value}</h1>
```
Update the stored value:

```
<script>
  function increment() {
    count.update(n => n + 1)
  }
</script>
```
Set a value:

```
<script>
  function reset() {
    count.set(0);
  }
</script>
```
Usage
Use auto-subscription to get rid of subscribe and onDestroy methods:

```
<script>
  import { storeValue } from './AnotherComponent'
  // ...other imports come after
</script>

<h1>The count is {$storeValue}</h1>
```
Readable store

```
<script>
  export const time = readable(new Date(), function start(set) {
    // Implementation
    set()

    return function stop() {
      // Implementation
    }
  })
</script>
```
Writable store

```
<script>
  import { writable } from 'svelte/store';

  const count = writable(0, () => {
    console.log('got a subscriber');
    return () => console.log('no more subscribers');
  });
</script>
```
Derived store

```
…from another store.

<script>
  import { derived } from 'svelte/store';

  const delayed = derived(time, ($a, set) => {
    setTimeout(() => set($a), 1000);
  }, 'one moment...');

  // or (read-only derived):

  const elapsed = derived(time, $time =>
    Math.round(($time - start) / 1000)
  );

</script>
```
Custom store

```
// store.js

import { writable } from 'svelte/store';
function createCount() {
  const { subscribe, set, update } = writable(0);

  return {
    subscribe,
    increment: () => update(n => n + 1),
    decrement: () => update(n => n - 1),
    reset: () => set(0)
  };
}
export const count = createCount();
```
In the component:

```
<script>
  import { count } from './store.js';
</script>

<h1>The count is {$count}</h1>

<button on:click={count.increment}>+</button>
<button on:click={count.decrement}>-</button>
<button on:click={count.reset}>reset</button>
```
ESP32 Now Supports Open Source Embedded Microservices Architecture
Tags: opensource, microservices, mcu, luos
Published: 2022-10-18 15:43:07

Brandon Lewis from Embedded Computing Design presented Luos in an article and his new integration with ESP32.

https://embeddedcomputing.com/technology/processing/interface-io/esp32-now-supports-open-source-embedded-microservices-architecture

💬 ”Espressif Systems’ ESP32 MCU is now supported by the open-source Luos containerization platform, which enables lightweight microservices to run on embedded systems.”
Handle Events in Svelte
Tags: svelte
Published: 2022-10-18 15:39:45

```
<button on:click={handleClick}>
  Press me
</button>

<button on:click={() => console.log('I was pressed')}>
  Press me
</button>

<button on:click|once={handleClick}>
  Press me
</button>

<button on:submit|preventDefault={handleClick}>
  Press me
</button>
```
[Svelte Cheat Sheet](https://simplecheatsheet.com/tag/svelte-cheat-sheet/#svelte-forwarding-events-cheat-sheet)
Forwarding Events in Svelte
Tags: svelte
Published: 2022-10-18 15:36:00

```
// Widget.svelte
<script>
  import { createEventDispatcher } from "svelte";
  const dispatch = createEventDispatcher();
</script>
<button on:click={() => dispatch('message', { text: 'Hello!' })} />
<button on:click>Press me</button>

// App.svelte
<script>
import Widget from '.Widget.svelte'
</script>

<Widget 
  on:click={() => alert('I was clicked')} 
  on:message={e => alert(e.detail.text)}>
```
Routing Information Protocol
Published: 2022-10-18 15:22:27

Routing Information Protocol (RIP) adalah protokol routing yang menggunakan algoritma routing distance vector. RIP tidak memiliki peta yang lengkap tentang jaringan yang ada.  RIP menggunakan hop count sebagai metric dan link dengan hop count terkecil yang akan menjadi link terbaik (best path).

Berikut langkah langkah untuk menkonfigurasi RIP pada jaringan:

1. Buat topologi jaringannya 

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

saya menggunakan topologi yang sama dengan praktikum sebelumnya.

2. Konfigurasi IP

Karena memang topologi sama, maka saya juga tidak merubah konfigurasi dari IP nya.

|  Devices 	| Interface 	|      IP     	|
|:--------:	|:---------:	|:-----------:	|
| Router 0 	|   Fa0/0   	| 192.168.2.2 	|
|          	|   Fa1/0   	| 192.168.1.2 	|
| Router 1 	|   Fa0/0   	| 192.168.1.1 	|
|          	|   Fa1/0   	| 192.168.3.2 	|
|           |   Fa2/0   	| 192.168.5.1   |
| Router 2 	|   Fa0/0   	| 192.168.2.1 	|
|          	|   Fa1/0   	| 192.168.3.1 	|
|           |   Fa2/0   	| 192.168.4.1   |


3. Atur RIP
Untuk mengkonfigurasi, yang dimasukan hanya jaringan yang direct langsung ke router yang dikonfigurasi.

* Route 0
![Route0](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yshevm353kfjuc0nn2r7.png)

* Route 1
![Route1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kc0jsjk1kfmk9dzwxfh.png)


* Route 2
![Route2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gev0pweq2ntgpspf86e1.png)
Dplyr Make New Variables
Tags: dplyr
Published: 2022-10-18 15:18:17

- Compute and append one or more new columns: `dplyr::mutate(iris, sepal = Sepal.Length + Sepal. Width)`
- Apply window function to each column: `dplyr::mutate_each(iris, funs(min_rank))`
- Compute one or more new columns. Drop original columns: `dplyr::transmute(iris, sepal = Sepal.Length + Sepal. Width)`
- Copy with values shifed by 1: `dplyr::lead`
- Copy with values lagged by 1: `dplyr::lag`
- Ranks with no gaps: `dplyr::dense_rank`
- Ranks. Ties get min rank: `dplyr::min_rank`
- Ranks rescaled to [0, 1]: `dplyr::percent_rank`
- Ranks. Ties got to first value: `dplyr::row_number`
- Bin vector into n buckets: `dplyr::ntile`
- Are values between a and b?: `dplyr::between`
- Cumulative distribution: `dplyr::cume_dist`
- Cumulative all: `dplyr::cumall`
- Cumulative any: `dplyr::cumany`
- Cumulative mean: `dplyr::cummean`
- Cumulative sum: `cumsum`
- Cumulative max: `cummax`
- Cumulative min: `cummin`
- Cumulative prod: `cumprod`
- Element-wise max: `pmax`
- Element-wise min: `pmin`

> [Dplyr Cheat Sheet](https://simplecheatsheet.com/tag/dplyr-cheat-sheet/)