teleren/devto huggingface dataset:
Getting React.js Certified in TEN MINUTES! (Beginners Guide)
Tags: react, redux, javascript, beginners
Published: 2021-06-28 03:35:28

Welcome! This tutorial is considered to be **an order of magnitude easier** than other React tutorials, because we focus on a *slightly different* version of React that is **much** easier than the normal version. But the knowledge is completely transferable (and way more fun)!

Instead of using the normal version of React we're using a version called "Vue". But don't worry! You're not getting a watered down version by using it. It's actually *more* powerful, faster, smaller, and is beloved by React's creators and the React community. And most of all **10 times easier!** Wow! Why isn't everyone using it? They are! Most people are moving from React to this newer, better version. So let's learn it, have some fun, and get certified as "A Real React Developer™", by the governing body of this tutorial. You can even put that on your résumé!

The first step for learning React is to install Vue.js. Normally React can only make WebApps, but the Vue version can also be used for websites.

So you need to pick your starting point!


## I want to create a Website!

1. Add a CDN link to Vue to your page:
  * `<script src="https://unpkg.com/vue"></script>`

## I want to create a Webapp!

1. Install Node.js & npm
  * https://nodejs.org
1. In your command prompt or terminal, run:
  * `git clone https://github.com/TheJaredWilcurt/vite-vue3-pinia-options-api.git && cd vite-vue3-pinia-options-api && npm install && npm start`


## Learning to code React

Follow this official "Getting started guide" for the Vue.js version of React:

* https://v3.vuejs.org/guide/introduction.html#getting-started

As you learn, check off these important concepts:

☐ `{{ doubleCurlies }}` and `data` values
☐ `v-bind:href` (or `:href`) attribute binding
☐ `v-model` for two-way data-binding
☐ `v-if`, `v-else`, and `v-else-if` conditionals
☐ `v-for` loops
☐ `v-on:click` or `@click`
☐ `methods`
☐ `computed` properties
☐ `props` on a component
☐ `created` and other life-cycle hooks


## CERTIFICATION!

That's it! You've done it, by the powers vested in me, from the global state of the React Higher Order Council (React HoC), you are now certified as "A Real React Developer™".

Print off your certificate here:

* https://TheJaredWilcurt.com/certificates/react

Share this with your friends, so they can be certified too!

Take a picture with your certification and share on Twitter! Be sure to mention [@TheJaredWilcurt](https://twitter.com/TheJaredWilcurt) so I see it.


* * *


\* Not officially endorsed by Facebook in any way
\** Certificate not available to those in TN, HI, CR or LF
\*** I believe in you, nothing can stop you, you are a champion
Go Programming - Fiber Web Framework
Tags: go
Published: 2021-06-28 03:20:35

Fiber is a Go web framework built on top of Fasthttp, the fastest HTTP engine for Go. It's designed to ease things up for fast development with zero memory allocation and performance in mind. https://gofiber.io

Source Code: https://github.com/codebangkok/golang

####ติดตามผลงานได้ที่
* **Page:** [https://fb.com/CodeBangkok​](https://fb.com/CodeBangkok​)
* **Group:** [https://fb.com/groups/msdevth​](https://fb.com/groups/msdevth​)
* **Blog:** [https://dev.to/codebangkok](https://dev.to/codebangkok)
* **YouTube:** [https://youtube.com/CodeBangkok](https://youtube.com/CodeBangkok)
เขียน unit test ใน Rust
Tags: rust
Published: 2021-06-28 03:17:28

การเขียน unit test ในภาษา Rust โดยปกติแล้วจะเขียนลงไปใน file เดียวกันกับ code ที่ใช้งานจริงเลย แต่ถ้าเป็น integration test จะแยกไปเขียนใน /tests ที่วางไว้ระดับเดียวกับ /src

วิธีเขียน unit test ทำแบบนี้

```rust
fn add(a:i32, b:i32) -> i32 {a+b}

fn main() {
    println!("{}",add(1,2));
}

#[cfg(test)]
mod tests {
    #[test]
    fn add_correct() {
        assert_eq!(3, super::add(1,2));
    }
}

```

จากตัวอย่าง อธิบายได้ว่า เรามี function add ไว้บวกเลขธรรมดา ทีนี้เวลาเราเขียน unit test ลงไปใน code ตรงๆ เวลา compile มันก็จะติดส่วนที่เป็น unit test เข้าไปด้วย และเพื่อป้องกันเหตุนั้น เราจึงใส่

`#[cfg(test)]` ไว้บน mod tests เพื่อบอก compiler ว่าส่วนต่อไปนี้เป็น unit test ไม่ต้องเอาไป compile

จากนั้นก็สร้าง module ชื่อ tests ลงไปเลย และในทุกๆ function ที่เป็น unit test ให้ใส่ `#[test]` ไว้

จากนั้นเวลาจะไปเรียก function จริงๆ จะต้องเรียกผ่าน `super::` และถ้าขี้เกียจ ก็อาจจะใช้ `use super::*;` ช่วยได้ เช่น

```rust
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn add_correct() {
        assert_eq!(3, add(1,2));
    }
}
```

เวลารันเทส ใช้คำสั่ง

> cargo test

เพียงเท่านี้ก็เริ่มเขียน unit test ใน Rust กันได้แล้ว
Hmm, that was weird - part 2
Tags: qa, logs, testing, troubleshooting
Published: 2021-06-28 03:16:07

*This is continuation from [part 1](https://dev.to/alexandlazaris/hmm-that-was-weird-a09), where I present my thought process (rather, my internal dialogue) when troubleshooting a web issue.*

Here we are, part 2 of digging into an issue discovered in a web browser. Using browser logs to analyze the API request & response behaviour, I can gain a better understanding of the issue. 

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

Bonus: Something else I discovered during this exercise was that [Safari](https://webkit.org/) allows you to provide a static response file to override an incoming API response. 

I've been using Charles for years now and was pleasantly surprise by this native browser-based alternative. Read more [here](https://webkit.org/web-inspector/local-overrides/).
Shopping cart project
Published: 2021-06-28 02:20:06

What is React JS ?

React is an open-source front-end JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications. 

Shopping cart ?

 shopping cart takes customers through the checkout process from the moment they click on the cart icon all the way to payment. But it's also the engine behind pretty much every part of the customer experience. 

How I build a shopping cart using React js ?
This application let us to add some fruits and vegetables to the cart and set the quantity for each Item in the bottom I add a checkout.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npz6uwy7ncl0h3y3ywea.jpg)

I started by creating a json-server database having a list of fruits and vegetables using #Visual Studio. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h357nt57b8wzcy0k9cfe.png)
in another window I created a react application by running the command npx create-react-app.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7xckq73rxbtoxh3hyadd.png)
Then I create list of components and link them together using the <Link> component. But, This is a wrapper around our old friend the HTML anchor, but has the added benefit that it automatically knows where your components are and can adjust the style of a link to make it look active when it's the page the user is currently browsing.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/om3j4fdbhhnb4a7paeqs.png)

I used Fetch API  which provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set.

To test our app locally we start running our server using the command "npm run dev". 
and for our react app we the command  "npm start".

To view my full code, here is my Github link : https://github.com/mezianefraga00/finalshoppingcart
Borrowing in Rust
Tags: rust
Published: 2021-06-28 02:15:25

เรื่องการยืมหรือ Borrow ใน Rust ที่จริงไม่มีอะไรซับซ้อน หลักๆแล้วเป็นการป้องกันเรื่อง data-race โดยจะให้มีความเป็นเจ้าของ ในช่วงเวลาใดเวลาหนึ่งนั้น มีได้เพียงตัวแปรเดียว ยกตัวอย่างง่ายๆ

```rust
fn main() {
    let mut section = 111;
    let law = &mut section;
    
    println!("value is {}",section);
    println!("references is {}",law);
}
```

เราประกาศตัวแปร section มีค่าเป็น 111 โดยเป็นตัวแปรแบบที่เปลี่ยนค่าได้ เพราะใส่ `mut` ไว้ด้วย และประกาศตัวแปร law ให้ชี้ไปที่ address ของตัวแปร section อีกที โดยให้ชี้แบบเปลี่ยนค่าได้ด้วย
เขียนง่ายๆแบบนี้ แต่จะ compile ไม่ผ่าน เพราะว่า

law ได้ทำการยืมความเป็นเจ้าของ มาจาก section และ law ยังคงอยู่ พอเราสั่ง println ง่ายๆเลย มันจะ error

ทีนี้ทดลอง สลับบรรทัดเป็นแบบนี้ดู

```rust
fn main() {
    let section = 111;
    let law = section;
    
    println!("references is {}",law);
    println!("value is {}",section);
}
```

แค่นี้ก็รันผ่านแล้ว เพราะว่าเราใช้ law ก่อน พอจบบรรทัดนั้น law ก็จะโดน drop ไป และความเป็นเจ้าของจะกลับมาเป็นของ section

อันนี้ยกตัวอย่างง่ายๆให้ดู ส่วนที่ยากไปอ่านต่อที่ https://tourofrust.com/chapter_5_th.html
How To Configure and Run Nexus OSS on a Remote Server
Tags: devops, docker
Published: 2021-06-28 02:07:35

In this tutorial, I will teach you the two ways to configure/run the Nexus Repository Manager on a remote server.

For the remote servers, I will be using Digital Ocean. 

Let's get started!

### Running Nexus Directly on Server

1) First, we want to create our remote server on Digital Ocean. 

2) Configure the Firewall Rules as such: 

![Firewall Rules](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2uewlk2uxmwhfjduofxa.png)

Do not forget to add the droplet to the firewall as well. 

3) SSH into your remote server through the terminal.

    ssh root@<ipv4_address>

4) Update the package manager

    apt update

5) Change directories into opt

    cd /opt

6) Get the Nexus OSS tar file

    wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

7) Untar the file

    tar -zxvf latest-unix.tar.gz

8) Create a new user because we do not want to run a service as root.

    adduser nexus

9) Grant ownership of Nexus folders/files to the new user

    chown -R nexus:nexus nexus-3.28.1-01
    chown -R nexus:nexus sonatype-work

10) Open nexus.rc and add the new user you created

    vim nexus-3.28.1-01/bin/nexus.rc

11) Uncomment and add the user inside the quotes and exit.

12) Switch to new user

    su - nexus (or whatever you named the new user)

13) Start Nexus

    /opt/nexus-3.28.1-01/bin/nexus start

14) Enter the IPv4 address of the remote server you created and add the port in the URL search bar.

     <ipv4_address>:<port>

**Congratulations! You have successfully configured Nexus on your remote server!**

<hr/>

### Running Nexus Repository Manager via Docker

1) Pull the image from DockerHub

    docker pull sonatype/nexus3

2) Create a volume
 
    docker volume create --name nexus-data

3) Run the image in a container

    docker run -d -p 8081:8081 --name nexus-data -v nexus-data:/nexus-data sonatype/nexus3

4) Enter the IPv4 address of the remote server you created and add the port in the URL search bar.

    <ipv4_address>:<port>

**Congratulations! You have successfully started Nexus on your remote server using Docker!**
Rust - Control Flow (Condition)
Tags: rust, beginners, programming, codenewbie
Published: 2021-06-28 01:49:10

Seperti namanya, fungsinya adalah mengatur arus/jalan dari program kita.
Apakah kita harus belok kanan, ataukah kiri, 
ataukah putar balik,
itulah bahasa sederhana dari _Control Flow_


> Semua materi merupakan rangkuman belajar.
>
> Untuk bacaan yang lebih langkap & update, dipersilahkan akses pada
> [The Book](https://doc.rust-lang.org/stable/book/ch03-05-control-flow.html)


Adapun _control flow_ di Rust meliputi
- condition
	- `if` & `else`
	- `match`
- iteration/repetition
	- `loop`
	- `while`
	- `for in`
- control flow keyword
	- `break`
	- `continue`
	- juga support _control flow_ label dengan `'label: `


### `if` & `else`

```rust
fn main() {
    let umur = 21;

    if umur < 18 {
        println!("kemudaan");
    } else if umur > 60 {
        println!("kayaknya waktunya pensiun");
    } else {
        println!("boleh lah");
    }

    // Karena if else 
    // merupakan expression 
    // ( dapat mengembalikan nilai )
    // kita dapat menggunakannya ke dalam variable
    let umur = if umur < 18 {
        "kemudaan"
    } else if umur > 60 {
        "kayaknya waktunya pensiun"
    } else {
        "boleh lah"
    };
    // pada contoh di atas 
    // kita menggunakan 
    // shadowing pada variable umur
    // & expression untuk mengembalikan nilai

    println!("{}", umur);
}
```
- Kita tidak perlu menuliskan kurung sebagai bungkus dari kondisi
- Body kondisi dibungkus dengan kurung kurawal `{ }`
- Karena merupakan expression, kita dapat menggunakannya ke dalam variable. 
- Kita juga dapat menggunakan expression sebagai return
di dalam body kondisinya
- Bila menggunakannya sebagai expression, 
__pastikan nilai return bertipe data sama__.
- `if` & `else` __hanya menerima nilai boolean ke dalam kondisinya__, 
tidak seperti JavaScrip yang dapat menerima nilai _truly/falsy_


### `match`

Pada Dasarnya `match` seperti `switch` pada beberapa bahasa pemrograman lain.
Nah, bedanya di Rust kita harus menangani segala kemungkinan yang terjadi.

```rust
fn main() {
    let nilai = 90;

    match nilai {
        0 => println!("Wah ini sih parah"),
        1 | 2 | 3 => println!("Niat ngga sih?"),
        4..=35 => println!("F"),
        31..=50 => {
            println!("Hmmm");
            println!("E");
        },
        51..=65 => println!("D"),
        66..=75 => println!("C"),
        76..=85 => println!("B"),
        86..=98 => println!("A"),
        99..=100 => println!("A+"),
        _ => println!("???"),
    }

    let boolean = true;

    let boolean = match boolean {
        false => 0,
        true => 1,
    };

    println!("{}", boolean);

}
```
- Nilai yang akan diperiksa,
 tidak perlu tanda kurung
- Kurung kurawa sebagai body pengecekan
& kondisi (apabila lebih dari 1 baris).
- `=>` dan `,` sebagai batas tiap kondisi
- `_` digunakan sebagai `else` atau `default`, 
kemungkinan yang lain akan masuk ke dalam kondisi ini
- Kita juga dapat menggunakannya sebagai expression.
	
	__pastikan nilai return bertipe data sama__

Untuk _control flow_ yang lain akan dibahas secara terpisah.

Terima kasih.
Are You Stuck on Sticky?
Tags: css, frontend, sticky, navbar
Published: 2021-06-28 01:48:51

So lately, a few people have been asking me about the sticky navbar on the website I built for a small crafting business called [Adrian's Dream](https://adriansdream.com/). If you're not really sure what that means, it looks a little something like this:
![A GIF of the Adrian's Dream website with its sticky navbar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpr8vgjb26e0jbbrw1vn.gif)

Take a look at the navbar in that GIF. See how it *isn't* scrolling with the page? *That's* a sticky navbar.

Now, since it has come up enough, I figured I'd write a quick post about how to do it and I promise accomplishing it is *way* easier than you might think.
*(Spoiler Alert: We're doing it with CSS!)*

So first off, I want to briefly review the `position` CSS property. According to the [Mozilla Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/position):
> The position CSS property sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final location of positioned elements.

Now, not to go all here's-my-life-story-before-the-recipe on you, but before I tell you how to do it, I want to mention that the default value of the `position` property is `position: static`. What that means is that the element with a `static` property will be positioned in a set place in the document, so if you scroll, the element will scroll along with everything else on the page.

So how do we create a sticky navbar? Simple! We use `position: sticky`!

Let's say we have a navbar with a className of "navbar" (`<nav className="navbar">`). If we (amongst the rest of our CSS) add our `position` and `top` as follows:
```
.navbar {
    position: sticky;
    top: 0;
}
```

Now we have a navbar that is positioned at the very top of the document and, if we scroll down, it will be stuck to that position (not scrolling along with everything else). Boom. Easy, right?

Now go forth and code!
My phase 2 project
Published: 2021-06-28 01:47:51

Hi all, this phase 2 project mode blogspot. Time passes so fast.This project made me confused so much. It has two parts differently, back-end and front-end. Back-end is a small app, and front-end too. Back-end supplies the database, and the front-end is the main part that shows that information. The problem is that I think I have to make an app that supplies API, things I don't know how to do. It makes me waste a lot of time.I've searched, asked, read, viewed anything I know. When everything seems impossible, I just follow my instructor's instructions step by step. Lastly,  I know that the thing called back-end is very simple. I made an app containing JSON-SERVER, and deployed it to the host.My back-end finish. It is a database. It contains my app information.After that, I had to construct  my database to fit my app. My app is a CREAT-REACT-APP. It means that I had to build an app with REACT inside. Then, following my app planning, I built my app struction, after I made Parent-child components, I coded my app fully. After all, although I had wasted my time on the first stage of app building, I had finished it on time.I have to follow my instructor more and more, the luck never comes twice.
Phase 2 Portfolio Project
Tags: reactnative, java, leadership, aws
Published: 2021-06-28 01:41:49



<h1>Description of what my To Do react App does...</h1>
<p>I wanted to create this app that will help me get more organized. In the "What needs to be done?" bar I can add any task that I want to get completed. 
All the new tasks I add will show when the All tab is selected, in the bottom of the list. I can check mark any of the tasks that I have completed. In order to filter only the tasks that are still active, then will click Active and to filter only the completed task, then will need to click Completed.</p>
<p>In addition to the above features, in my app I can also remove tasks in order to not have them as part of my To Do list anymore.</p>
<img src="https://images.unsplash.com/photo-1544367567-0f2fcb009e0b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1394&q=80">
Template Syntax
Tags: vue, javascript
Published: 2021-06-28 01:35:41

Vue uses an HTML-based template syntax which binds the instance's(component's) data to the DOM.

####What Are Interpolations?
###### What does Interpolation even mean? 
According to the Oxford dictionary interpolation is *the insertion of something of a different nature into something else*. So, I would assume that we are inserting something into the HTML using Vue.

######Interpolation Using Text
Vue uses the "Mustache" syntax (double curly braces) to bind and *interpolate* data in the HTML. We are using the word binding here because it is bound with the value you assigned in the data property of the component. 
```HTML
<span>Message: {{ msg }} </span>
Message: hi
```
```javascript
const RenderHtmlApp = {
  data() {
    return {
      msg: 'hi'
    }
  }
}
```
Once again, 'msg' in the example above would be 'interpolated' into the HTML with whatever value you gave it in the data section(property) of the corresponding Vue component.

######Interpolation Using Raw HTML
You can also *interpolate* raw HTML instead of just text like the example above. But, you have to use the v-html directive!
```HTML
<p>Using v-html directive: <span v-html="msg"></span>
</p>
Using v-html directive: Hello.
```
```javascript
const RenderHtmlApp = {
  data() {
    return {
      msg: '<span>Hello.</span>'
    }
  }
}
```
######Interpolation Using JS Expressions
You can use the following JS expressions to output data in the HTML as well using Vue.
```javascript
{{ number + 1 }}

{{ ok ? 'YES' : 'NO' }} // ternary expression

{{ message.split('').reverse().join('') }}

<div v-bind:id="'list-' + id"></div>
```

But, you can only use one expression at a time. So, the following won't work.
```javascript
//this is a statement, not an expression:
{{ var a = 1 }}
//What is an expression? something that produces a value
//What is a statement? something that generates some behavior. var a = 1 is a statement. The 1 is an expression because it is a value.

//flow control wont work either, use ternary expressions
{{ if (ok) { return message } }}
```
A ternary expression is when you use "?" and ":" for if statements which you can see in the example above.

####What Are Directives?
###### What does directive mean? 
According to the Oxford dictionary, a directive is *an official authoritative instruction*. So, I'm gonna assume that Vue uses directives to command or instruct the HTML to do something. 

Vue uses the prefix *v-* as attributes in HTML to use directives. If you see *v-* in some HTML then you can assume that Vue is instructing that HTML tag to do something. 

A directive's job is to reactively apply effects to the DOM when the value of its expression changes. Reactively here means that it is updated automatically.

####What Are Shorthands?
####Shorthands or Shortcuts:
```javascript
v-bind:href="url" // shortcut for v-bind: is :
:href="url"

v-on:click="doSomething" // shortcut for v-on: is @
@click="doSomething"
```
Flask folder structure and __init__.py file
Tags: help, python, flask
Published: 2021-06-28 00:36:40

Hello everybody! 

Last week I started studying about how to develop a REST API with Flask. I know very little about Python, basically just syntax and how to run a script, but I'm completely blank when it comes to folder structure and special files (such as the `__init__.py` file). I have strong knowledge of JavaScript and TypeScript and about backends with Node (Express and Nest). 

My first question is about the folder structure, I would like to know what is the best practice for structuring my project. Right now, my project is looking like this (trying to replicate how I do it with Node):

```
my_project/
-src/
--__init__.py
--blueprints/
---books/
----__init__.py
-tests/
--__init__.py
--test_books.py
-run.py
```
(Your answers don't necessarily need to be for a Flask project, if you tell how you structure your random Python projects that would help too!)

My second question is about the `__init__.py` file. I've read that by adding that file you are making the folder a `package` or `module`. I had it inside my `blueprints` folder, but I removed it just to see what would happen and my project was unaffected. 

So, my questions would be:
* When should I add this file to my folders and when should I not?
* When should I leave that file blank and when should I write code to it?

Thanks in advance for your time and your answers ✨
Feedback Emotes
Tags: codepen
Published: 2021-06-28 00:32:28

<p>Based on this shot - <a href="https://dribbble.com/shots/2790473-Feedback" target="_blank">https://dribbble.com/shots/2790473-Feedback</a></p>

<p>*** Cool story incoming tomorrow ***</p>

{% codepen https://codepen.io/suez/pen/rLQVYX %}