teleren/devto huggingface dataset:
[WIP] Rust - NOTES
Published: 2023-09-11 23:23:23

---
title: [WIP] Rust  - NOTES
published: true
date: 2023-09-11 23:19:24 UTC
tags: 
canonical_url: https://mauriciord.dev/wip-rust-notes
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuz12zxhy8d8qvgf8iat.jpeg
---
### Tuple

```
let numbers: (i32, i32, f64) = (1, 2, 3.5);

// destructuring
let (a, b, c) = numbers;

// mutable
let mut mau = (10, 11, 12)
mau.0 = 90 // (90, 11, 12)

mau = (90, 91, 92) // pattern matching

```

> need to respect the type to avoid `mismatched types`

### Array

```
let neo: [i32;3] = [1, 2, 3]
neo[1] // 2

let mut morpheu = [1.1, 2.2, 3.3]
morpheu[2] = 10.15

// slice
&neo[1..] // [2, 3]
&neo[..2] // [1, 2]
&neo[1..2] // [2]

```

> arrays should have only one type

#### Out-of-bound error

- Trying to get an element out of the limits: **index out of bounds**

### Memory Awareness

- STATIC memory needs fixed-size

```
static _Y: u32 = 13

```

- STACK are local variables,

```
static _Y: u32 = 13

fn main() {
    let x = 5;
    let z = true;
    let numbers = [1, 2, 3];
}

```

- HEAP memory

```
static _Y: u32 = 13

fn main() {
    let x = 5;
    let z = true;
    let numbers = [1, 2, 3];

    let users = get_users();
}

```

### Memory Cleanup

- **drop** method to clean up it
My Journey at the Polkadot Blockchain Academy's UC Berkeley edition
Tags: rust, web3, blockchain, ethereum
Published: 2023-09-11 23:18:44

In the dynamic realm of blockchain and Web3 technologies, education is the cornerstone of progress. One transformative experience that stands out for me is the Polkadot Blockchain Academy, hosted at **UC Berkeley**. Having recently graduated from its 3rd edition, I'm eager to share my thoughts on this invaluable program.

The **Polkadot Blockchain Academy** is an intensive educational program designed to equip participants with comprehensive knowledge and skills in the field of blockchain technology and Web3 ecosystems. Led by prominent figures in the Polkadot/Kusama community, the academy covers a wide range of topics including cryptography, economics, blockchain architecture, smart contracts, and more. Graduates of this program emerge with the tools and understanding needed to actively contribute to the thriving Web3 ecosystem. The academy's immersive curriculum and access to industry experts make it a pivotal opportunity for anyone seeking to dive deep into the world of blockchain technology.

In this blog post, I'll be reflecting on my journey through the Polkadot Blockchain Academy at UC Berkeley. From the intensive curriculum to the unparalleled networking opportunities, this program has equipped me with insights that continue to shape my understanding of Web3.

Join me in this brief exploration of the Polkadot Blockchain Academy and the impact it's had on my journey. 

[**Click here to read the full article!**
](https://nicolasbiondini.com/blog/polkadot-blockchain-academy-my-experience)

Completing the academy's 3rd edition was not only a personal milestone, but also a testament to the quality of education provided. The program's blend of academic rigor and real-world applicability sets it apart in the ever-evolving blockchain space.
Protecting My Email and Phone from Bots on My Website: A Simple HTML Approach
Published: 2023-09-11 22:33:32

In today's digital age, maintaining online privacy has become increasingly important. As a website owner, one of my top priorities is safeguarding personal information from malicious bots that can scrape email addresses and phone numbers. In this blog post, I'll walk you through a simple HTML approach I've taken to obfuscate my email and phone numbers on my website.

## The Challenge
Bots and web crawlers are constantly scouring the internet for email addresses and phone numbers to send spam or use for other malicious purposes. To combat this, I needed a way to display my contact information on my website while making it difficult for bots to extract that information.

## The Solution
To address this issue, I turned to HTML and CSS for a straightforward and effective solution. Let's take a look at how I obfuscated my email and phone numbers using simple HTML tags and CSS classes.

```html
<div class="about-info">
    <p><span class="title-s">Name</span> <span>Amine Online</span></p>
    <p><span class="title-s">Profile:</span> <span>Multifaceted</span></p>
    <p>
        <span class="title-s">Email<span class="at-symbol">&#64;</span>hotmail.com</span> is -&gt;
        <span class="email">amine-ghandi</span>
    </p>
    <p>
        <span class="title-s">Phone: +212</span>
        <span class="phone">6-33<span class="hash-symbol">#</span>49-42<span class="hash-symbol">#</span>75</span>
    </p>
</div>
```

## Obfuscating Email
To obfuscate the email address, I broke it into two parts: the username (amine-ghandi) and the domain (hotmail.com). I used the arrow -> as -&gt to point at the username and the `<span class="at-symbol">&#64;</span>` to draw the  @ symbol.

## Obfuscating Phone Number
Similarly, I obfuscated the phone number by splitting it into segments using the phone class and added a CSS class (hash-symbol) to display "#" symbols between the segments. This makes it challenging for bots to recognize it as a phone number.

## Benefits of This Approach
By using simple HTML and CSS, I've made it more difficult for bots to harvest my email address and phone number. While this method may not provide foolproof protection, it adds an extra layer of security to my online presence without the need for complex coding or images.

## Conclusion
Protecting your email and phone number from bots on your website is essential to maintaining online privacy. This HTML approach provides a practical and user-friendly way to obfuscate your contact information, helping you stay one step ahead of malicious web crawlers. Consider implementing this technique on your website to enhance your online security effortlessly.
pseudocoding
Published: 2023-09-11 22:21:21

I'm recently starting the University of Miami coding bootcamp, prior to this I have 2 years of computer science experience from college.As i'm scrolling through the pre-work I come across this term i'm unfamiliar with, after further research I find out that pseudocode means "fake code". It is a description of what the computer program should do, maybe this is a basic term in the computer world but it's a first for me so thought i'd share.
What Are the Biggest Misconceptions about Your Work?
Tags: discuss, beginners, codenewbie
Published: 2023-09-11 22:17:48

_Get a glimpse into the daily experiences, work routines, and unique perspectives of tech professionals, both novice and experienced alike, in "A Day in the Life."_

> What are the common misconceptions about your job? Or about tech work, in general?


Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
[Digest] Java, Kotlin, Spring, Cloud, and More - Episode 10 & 11
Tags: digest, java, spring, cloud
Published: 2023-09-11 22:06:07

_Hey folks, with a lot of stuff happening around in both work and personal life, I sometimes forget to actually post articles even when they are (almost) ready. So here are two missed ones from two previous weeks. Hope you'll find it useful._

🌱 [Spring Boot Annotations: Behind the Scenes and the Self-Invocation Problem](https://dzone.com/articles/spring-beans-self-invocation-problem): a nice post on the proxy in Spring and what you should remember when using different annotations.

💾 [A beginner’s guide to Hibernate Statistics](https://vladmihalcea.com/hibernate-statistics/): what is Hibernate statistics for and how to turn it on.

🐘 [Gradle 8.3 Release Notes](https://docs.gradle.org/8.3/release-notes.html): Gradle 8.3 is released. It promises faster compilation and less memory consumption which may be important for large projects, such as Android.

🌏 [OpenTF Announces Fork of Terraform](https://opentf.org/announcement): HashiCorp changed the license for Terraform, and here is the community's response.

✉️ [Kafka is dead, long live Kafka](https://www.warpstream.com/blog/kafka-is-dead-long-live-kafka): WarpStream is a Kafka alternative built on top of S3. It is in developer preview and not ready for production yet, but still interesting to follow.

⚙️ [Should That Be a Microservice? Keep These Six Factors in Mind](https://tanzu.vmware.com/content/blog/should-that-be-a-microservice-keep-these-six-factors-in-mind): the author suggests 6 criteria to find out if some functionality should be extracted into a microservice on its own.

🌱 [This is the Beginning of the End of the N+1 Problem: Introducing Single Query Loading](https://spring.io/blog/2023/08/31/this-is-the-beginning-of-the-end-of-the-n-1-problem-introducing-single-query): Spring Data JDBC will provide an ability to load arbitrary aggregates with nested collections with a single select statement.

🌱 [What's New in Spring Framework 6.x](https://github.com/spring-projects/spring-framework/wiki/What%27s-New-in-Spring-Framework-6.x): Spring 6.1 has a full support of Virtual Threads and JDK 21.

🧭 [Resize CPU Limit To Speed Up Java Startup on Kubernetes](https://piotrminkowski.com/2023/08/22/resize-cpu-limit-to-speed-up-java-startup-on-kubernetes/): how to make Java application start faster in Kubernetes using vertical CPU scaling on start.

☕️ [How Tiered Compilation works in OpenJDK](https://devblogs.microsoft.com/java/how-tiered-compilation-works-in-openjdk/): if you always wanted to know what is HotSpot, JIT compiler, and Tiered Compilation in JDK (but were afraid to ask), then this post is for you.

---

*Dream your code, code your dream.*
Despite being accessible through the private network, why is it not possible to access an EC2 server via the public network?
Published: 2023-09-11 22:05:20

Have you ever encountered a situation with an AWS EC2 instance where the server is running and accessible through a private network, but not accessible through the public network? If you are unable to access your EC2 server using its public IP address, there could be several reasons for this.

The reason why you cannot access an EC2 server via the public network, even though it is accessible through the private network, is due to the default security settings in Amazon Web Services (AWS).

By default, EC2 instances in AWS are launched within a Virtual Private Cloud (VPC), which acts as a private network isolated from the public internet. These instances are assigned private IP addresses that can only be reached within the VPC.

To make an EC2 instance accessible from the public internet, you need to configure the appropriate networking settings. This includes assigning a public IP address to the instance and configuring security groups and network access control lists (ACLs) to allow inbound traffic from the internet.

## Check your firewall settings to ensure that the specified ports, such as 80 or 443, are allowed.

The first possible reason is that your server's firewall configuration may not be allowing traffic on these ports. By allowing this traffic, you may be able to access the server.

## Allocate and associate an Elastic IP address with your EC2 instance. 

This will provide a static public IP address that can be used to access the instance.

## Check the security groups to ensure that they allow traffic on the specified ports.

One possible reason for this issue is that your security group settings may not be properly configured. By allowing traffic on these ports in the security group settings, you can access the EC2 server via the internet's public network.

## Ensure that the Network ACL associated with the subnet of your VPC allows the necessary inbound and outbound traffic to and from the EC2 instance. 

By default, all inbound and outbound traffic is allowed in the Network ACL, but you may have customized rules that need to be adjusted.
What is OG (open graph )? And what will we use it for!
Tags: og, webdev, metatag
Published: 2023-09-11 22:02:48

OG (Open Graph) tags are used as meta tags. The purpose of using OG is when we share a website's link on social platforms, it helps display a beautiful preview of our website. For example, when sharing a link on Facebook, it can show a nice title and the Facebook logo, as shown in the screenshot below.

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

OG tags are primarily used for this purpose.To use these meta tags on your website, you can include them in the HTML head section like this:

```
<head>
  <meta property="og:title" content="Your Page Title" />
  <meta property="og:description" content="Description of your page." />
  <meta property="og:image" content="URL of your featured image or logo." />
  <meta property="og:url" content="URL of your webpage." />
</head>
```

This helps improve the appearance and information presented when your website links are shared on social media.
Netbeans Configure Tomcat service
Published: 2023-09-11 21:41:42

**Environment versions:**
Java JDK 17
Netbeans 19
Ubuntu 22.04
Tomcat 9

1. In Netbeans, go to menu **Services**.
In the panel Services, open node **Servers**.

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

2. Right Click and select **Add Server**.

3. Choose **Tomcat EE**

4. Choose **directory** when Tomcat is installed.

5. Write credentials: user and password to  tomcat's **manager** user.

6. Click Finish

7. After server is added. Click in server, and choose Start.

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



---

Related posts:
[Install Tomcat in Linux/Ubuntu](https://dev.to/gabidesa/using-java-vaadin-with-tomcat-1a3l
)
Filing issues in open-source
Tags: opensource, github, testing
Published: 2023-09-11 21:34:32

## Finding a Team

To find a partner to work with on my first open-source project, I was able to find and collaborate with 3 other students through our Slack channel. we decided to read each others code, then each of us would review issues for one person, and that person reviews the code for the next person as in a funky code review circle!

## My Experience

As I read through my peers code, I realized a lot of differences in coding style as well as structural style. I wasn't surprised to see the code that I saw, however, I was surprised by the structural differences. Many structural considerations aren't generally taken at the beginning of a project, however, reading code that looks much more like a single use script than an actual program has always intrigued my curiosity as to why wouldn't you write your code as if you would reuse it tomorrow? After my code has been reviewed and issues submitted, I realized that I often make programs that have a plethora of features but with little to no documentation. Having my code reviewed helped me notice these shortcomings and address them properly, which gives me a better method to approach my problems as I code more in the future.

## Issues I Found

One of the issues I documented was an issue that could rarely happen, but could cause a lot of annoyance later on down the line https://github.com/mnajibi/tml/issues/2 was the issue that I raised and was fixed promptly by my classmate! 
This issue rarely happens but some text editors on windows insert a carriage return with a newline character to create a newline. This could cause the utility to miss the correct file splitting and output all the data within one \<p\> tag.
My recommendation was to use the `Python re` Regular Expression module with the following code.

```python
 body_paragraphs = re.split(r"\r?\n\r?\n", "\n".join(lines[3:]))
```

## Issues I Fixed

One of the issues I had to resolve was an interesting case of asynchronous function causing havoc in JavaScript/TypeScript. The issue that was raised was about a directory not being recreated after deletion, but only if the supplied input was a file. After checking the code, I realized I has missed placing an `await` statement before creating the directory, which caused the index generator function to fail when attempting to read the output directory recursively. 

```javascript
await processFile(input, title, ...);
```

After fixing all issues that were raised, It felt a lot better knowing that my software had been hardened and felt a lot more robust simply by allowing people to use it and report issues back to me about it. This taught me the value of open-source contributions and how much progress can be made by adding more eyes and fingers to the coding and testing army!
Install Tomcat on Ubuntu (version 22.04)
Published: 2023-09-11 21:16:03

Environment
**Ubuntu 22.04**

To Install Tomcat I use this article:**
https://tecadmin.net/how-to-install-tomcat-on-ubuntu-22-04/

I follow all steps, except theses ones:

*tomcat version: I used version 9 (before migration to Eclipse Foundation)

*sudo chown -R tomcat: /opt/tomcat 


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



Just must use this chwon command, if you want to expose tomcat service.
Ruby: 3 formas de printar na tela "Olá Mundo!"
Tags: ruby, coding, beginners, tutorial
Published: 2023-09-11 21:11:26

A linguagem Ruby, busca ser bem expressiva, havendo diversos métodos para que se possa escrever diretamente o que se precisa. E no simples printar de um texto na tela, não é diferente.

Veja aqui 3 maneiras de fazer isso:
<br>

### Maneira 1

O método "puts" adiciona uma nova linha após a saída, tornando-o útil para imprimir mensagens de texto formatadas ou resultados de cálculos.

```Ruby

puts "Ola Mundo!"
puts "Ola Mundo!"

```
#### Saída:
Ola Mundo!
Ola Mundo!
<br>

### Maneira 2

O método "p" é usado para depuração, pois exibe o valor de uma expressão, incluindo detalhes internos, como aspas em strings e novas linhas.

```Ruby

p "Ola Mundo!"
p "Ola Mundo!"

```
#### Saída:
"Ola Mundo!"
"Ola Mundo!"
<br>

### Maneira 3

O método "print" não adiciona uma nova linha, permitindo que a saída seja impressa na mesma linha ou para formatar saídas sem quebras de linha.

```Ruby

print "Ola Mundo!"
print "Ola Mundo!"

```
#### Saída:
Ola Mundo!Ola Mundo!
<br>
Use bunx for running npm packages with lightning fast speed.
Tags: webdev, javascript, npm, bunjs
Published: 2023-09-11 20:34:38


- [Introduction](#Introduction)
- [Use Case for the package](#use-case-for-the-package)
- [Comparing with npx](#comparing-with-npx)
- [Conclusion](#conclusion)

## Introduction

`bun` is the latest and greatest runtime for Javascript  which ships with many features like built in Typescript support and testing support and etc. etc.. bunx, alias for `bun x`, is a package manger for bun which can be used for auto installing and running npm packages. We can you `bunx` just similarly like we use `npx` or `yarn dlx`.

According to [this](https://twitter.com/jarredsumner/status/1606163655527059458) twitter post, bunx is 100x faster than npx, which means we can use bunx and run our npm cli with lightning fast speed.

Today we will discuss an use case of running a npm package with bunx and compare the result with running it with npx.

You can view the package from [here](https://www.npmjs.com/package/phil-s-osophy), it is a simple package that I wrote which generates a random quote of Phil Dunphy from Mordern Family. You can also view a [post](https://dev.to/mitrakumar/journey-of-creating-and-publishing-a-nodejs-package-with-typescript-eslint-support-3gh7) that I have written with my learnings and take aways from creating this package.

## Use case for the package

As the package `phil-s-osophy` just spits out basic string output we can pipe that to any program, like I have used to pipe the value in `cowsay` and added the whole thing at the bottom of my zshrc file to show text at every shell creation.

```shell
bunx phil-s-osophy | bunx cowsay
```

## Comparing with npx

To compare my changes with the npx, I have created a function which will run the shell few times and time it.

```shell
timezsh() {
	for i in $(seq 1 10); do /usr/bin/time $SHELL -i -c exit; done
}
```

So after running both my program with bunx and npx I timed it to aroud `0.3 to 0.4s` when running with bunx but when running with npx the program took around `2s` to ran.
> Note: there are many more things happening in my zshrc file, but I am ignoring this as they are running in bot scenarios.


Left running - `bunx phil-s-osophy | bunx cowsay`
Right running - `npx phil-s-osophy | npx cowsay`

![comapare bunx v npx - screengrab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sg6ixcxkihkrdy0rjjvl.jpeg)

## Conclusion

So, in conclusion we have seen how bunx is so much faster than npx and how we can use this lightning fast speed to install and use packages for that great developer experience.

For more information about the bun, you can visit [bun.sh](https://bun.sh/docs).
Understanding Docker: part 43 – Init & Dockerize an app
Tags: docker, devops, beginners, cloud
Published: 2023-09-11 20:20:06

---
title: Understanding Docker: part 43 – Init & Dockerize an app
published: true
description: Serie of sketchnotes about Docker. Explaining in a visual way Docker principles.
tags: Docker, DevOps, beginners, Cloud
series: Understanding Docker in sketchnotes
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rl5iak3gce0jsqbzgapn.jpg
---

Understanding Docker can be difficult or time-consuming. In order to spread knowledge about Cloud technologies I started to create sketchnotes about Docker. I think it could be a good way, more visual, to explain Docker (and other technologies like Kubernetes and Istio).

We continue the series of Docker sketchnotes with a focus a useful CLI command: `docker init`.

![Docker Init](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rl5iak3gce0jsqbzgapn.jpg)
![Docker Init](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iexvzvva22q4escofq6t.jpg)
![Docker Init](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dokh2l375v1e8x3tumu0.jpg)
![Docker Init](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qfked1gvqmnor5jcoapm.jpg)

If you want to see in action `docker init` command, read [Let's discover: docker init command](https://dev.to/aurelievache/lets-discover-docker-init-command-3cef).

As usual, if you like theses sketchnotes, you can follow me, and tell me what do you think. I will publish others sketchs shortly :-).

If you are interested, I published the book in a paperbook version on Amazon: [Understanding Docker in a visual way](https://www.amazon.fr/Understanding-Docker-visual-way-sketchnotes/dp/B0BT6ZXR1W/ref=sr_1_1) and also in a PDF/ebook version on [GumRoad](https://gumroad.com/aurelievache#YTLzM).

![Understanding Docker in a visual way](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xs45orcsh2og8rnbi2b.jpg)

If you are also interested in Kubernetes, the book [Understanding Kubernetes in a visual way](https://www.amazon.fr/dp/B0BB619188/ref=cm_cr_arp_d_product_top?ie=UTF8) is available also.