teleren/devto huggingface dataset:
Taking a Look at Conditional Statements
Tags: javascript, beginners, programming
Published: 2022-08-03 23:56:00

## `if`, `else`, and `else if`

When you're writing code and you want to perform different actions based on different decisions.  This is where `if` statements come in handy!

## `if` Statements

- Use an `if` statement to run a specified block of code _if_ a certain condition is true.

**Example Structure of an `if` statement**

```
if (condition) {
   // insert code here to be executed if the condition is true
}
```

## `else` Statements

- Use an `else` statement to run a specified block of code if the condition is false.

**Example Structure of an `else` statement**

```
if (condition) {
   // insert code here to be executed if the condition is true
}else{
   // insert code here to be executed if the condition is false
}
```

## `else if` Statements

- Use an `else if` statement to add a second condition if the first condition is false.

**Example Structure of an `else` statement**

```
if (1st condition) {
   // insert code here to be executed if the condition is true
} else if (2nd condition) {
   // insert code here to be executed if the first condition is false and the second condition is true
} else {
   // insert code here to be executed if the first condition is false and the second condition is false
}
```

_Pro Tip: Use console.log through out the process to figure out what is happening in your program and where!_
Is it time to replace Hello World?
Tags: humor, discuss
Published: 2022-08-03 23:51:43

It's a common practice to code the phrase "Hello World!", to the screen the first time you use a new language or program. I wrote about this in an early blog post. But am updating not with syntax highlighting.

Here's how "Hello World!" is created in a few languages. 

HTML
```html
<title>Hello World</title>
```
```HTML
<H2>Hello World!</h2>
```
JavaScript
```javascript
console.log("Hello World!")
```


C#
```C#
Console.WriteLine("Hello World"!)
```
Python


```python
print ("Hello World!")


def hello_function():
    print("Hello World!")
hello_function()
```

Well time and frameworks change, is it time to replace Hello World? What would be a suitable replacement? 

What would make a dev smile to see on screen?

## My Suggestion 
.
.
.

The classic greeting from an old mentor.

Hello There!

![Obi wan Hello There](https://media.giphy.com/media/xTiIzJSKB4l7xTouE8/giphy.gif)

HTML
```html
<title>Hello There</title>
```
```HTML
<H2>Hello There!</h2>
```
JavaScript
```javascript
console.log("Hello There!")
```

Python

```python
print("Hello There!")

def hello_function():
    print("Hello there!")
hello_function()
```

See it looks good.


-$JarvisScript git push
Code Smell 155 - Multiple Promises
Tags: javascript, webdev, beginners, programming
Published: 2022-08-03 23:24:00

*You have promises. You need to wait. Wait for them all*

> TL;DR: Don't block yourself in a sorted way.

# Problems

- Indeterminism

- Performance bottleneck

# Solutions

1. Wait for all promises at once.

# Context

We heard about semaphores while studying Operating Systems.

We should wait until all conditions are met no matter the ordering.

# Sample Code

## Wrong 

[Gist Url]: # (https://gist.github.com/mcsee/08e94e3b7dbf0fd20cc1d9c296d6fdbc)
```javascript
async fetchOne() { /* long task */ }
async fetchTwo() { /* another long task */ }

async fetchAll() {
  let res1 = await this.fetchOne(); 
  let res2 = await this.fetchTwo();
  // they can run in parallel !!  
}
                                 
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/b1f4721f8b8db8da67435c499fcec83d)
```javascript
async fetchOne() { /* long task */ }
async fetchTwo() { /* another long task */ }

async fetchAll() {
  let [res3, res4] = await Promise.all([this.fetchOne(), this.fetchTwo()]);
  //We wait until ALL are done
}
```

# Detection

[X] Semi-Automatic 

This is a semantic smell. 

We can tell our linters to find some patterns related to promises waiting.

# Tags

- Performance

# Conclusion

We need to be as close as possible to [real-world]((https://dev.to/mcsee/what-is-wrong-with-software-5pa) business rules.

If the rule states we need to wait for ALL operations, we should not force a particular order.

# Credits

Thanks for the idea

{% twitter 1542249552480174081 %}

Photo by [Alvin Mahmudov](https://unsplash.com/es/@alvinmahmudov) on [Unsplash](https://unsplash.com/s/photos/flowers-boyfriend)
  
* * *

> JavaScript is the only language that I'm aware of that people feel they don't need to learn before they start using it.

_Douglas Crockford_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Create SQS + DLQ with aws-cdk v2 on typescript
Tags: typescript, aws, cdk
Published: 2022-08-03 22:29:17

Let's suppose you want to create an asynchronous messaging application on aws, then you need to create a SQS and a DLQ to store your processing errors.
> Queues can be great in scenarios where your application needs
> something done but doesn’t need it done now, or doesn’t even care
> about the result. Instead of calling a web service and waiting for it
> to complete, you can write the message to a queue and let the same
> business logic happen later.

## It's show time
![](https://media4.giphy.com/media/ToMjGpys6SYsvUSE0JW/giphy.gif?cid=ecf05e47ibb2jj8ckpd704juf7vyxrlxmv5m9pjyh98t5k8c&rid=giphy.gif&ct=g)

**Our stack is:** 
- aws-cdk v2
- typescript
### Instalations
```bash
npm i -D @aws-cdk/assert ts-node ts-node-dev typescript aws-cdk
npm i aws-cdk-lib constructs
```
Before of all we need to bootstrap our project with the command bellow:
```bash
npx cdk bootstrap aws://ACCOUNT-NUMBER/REGION
```
> Bootstrapping is the deployment of a AWS CloudFormation template to a specific AWS environment (account and region). The bootstrapping template accepts parameters that customize some aspects of the bootstrapped resources (see  [Customizing bootstrapping](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html#bootstrapping-customizing)).

Now you can create your Queue and DLQ following the example bellow:
![code print](https://i.imgur.com/K2cWouM.png)


Create SQS is a piece of cake xD

If you want to see a real world project structure example, please take a look at the bottom of this post, is a link to my cdk repository with some examples

{% github https://github.com/wakeupmh/cdk/ %}
Data Analysis With Microsoft Excel: Analysis Of The MonkeyPox Disease.
Tags: programming, datascience, database, analytics
Published: 2022-08-03 22:19:00

**INTRODUCTION**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9aqpk3iwxhbftjqnaz1.jpeg)
MonkeyPox is a viral zoonosis (a virus transmitted to humans from animals). Animal host include rodents and non human pirates. The MonkeyPox virus was first discovered in 1970 in  Democratic Republic of Congo. 
In May 2022, multiple cases of the virus was identified in several countries across the world.

 In this project, I carried out data analysis on the viral disease, using Microsoft Excel.

Data cleaning, analysis, exploration and visualization was done using just Microsoft Excel.
This analysis shows trends and patterns of the disease in 2022 , it also provides answers to some very important questions.



**Data Structure And Preparation.**

The dataset for this project was gotten from kaggle.com
The dataset contains thirty six columns and over twenty-five thousand rows. Records in the dataset include; Date of confirmation, status, city, country, gender, age, symptoms, and so many more.
Here is what the dataset looks like:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4m75t93hx1uv8d5wftql.png)

**Data Cleaning And Preparation.**

The dataset had no outliers, errors, duplicate, missing rows and columns, so the data cleaning process was a walk through.

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

**Analysis And Insights.**

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

An overview of the dashboard shows the most important information gotten from the dataset, which include; total number of confirmed cases, countries with the most confirmed cases and the pattern of the spread of the disease in 2022.

1.***Number of incidents:***

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/um8u7l56vpd2pg6jqido.jpeg)Suspected, discarded and confirmed cases were recorded in the dataset. Analysis carried out on the dataset shows 23, 273 confirmed cases of monkey pox disease have been recorded from January 1st, 2022 to 1st August, 2022.


2.***Countries with Most Confirmed Cases.***

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3zwe37qnxzgdgmacxn6.jpeg)
Much to my surprise, The United States of America and Central European countries have had the most confirmed cases of MonkeyPox in 2022.


3.***Cases Per Month.***

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u2w9779e4ydouzo09k86.jpeg)
The disease caught the media attention in May 2022, and has garnered lot of publicity since then.
Analysis done on this dataset shows the gradual trend of the disease since January 2022 till August.
           *****

Dashboard:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9mzqaqvjzwxeys6xrrag.jpeg)

Thanks for reading!

Comments and suggestions, please do send me a mail: heyfunmi@gmail.com

__Ciao__!
Why are Software bugs named bugs?
Tags: software, bugs, errors, history
Published: 2022-08-03 22:07:23


The use of the term "bug" to describe problems with software is now common and is used in both technical and non-technical contexts. What are the origins of the term?, Does it refer to a real insect?, Let's check some historical facts.

Thomas Edison
=============

The term "bug" in software is derived from the term "bug" in insects. The first recorded use of the term "bug" to describe a problem with a machine was in 1878, when Thomas Edison used it to describe a problem with one of his phonographs.

Radio Engineering
=================

The term "bug" was also used to describe problems with mechanical devices in the early days of radio. In an article in the Proceedings of the Institute of Radio Engineers in June of 1920, E. J. Stone described a problem with a receiver caused by a "*bug"* in the wiring.

Grace Hopper
================

In 1946, when Hopper was working on the electromechanical computer **`Harvard Mark II`**, operators traced an error to a moth rapped in a relay, coining the term "*bug".* This bug was carefully removed and taped to the log book. This log book, complete with attached moth, is part of the collection of the Smithsonian National Museum of American History (See image below).


![Original page of the Mark II log book.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpgarrslizzcrrog9air.jpg)


**John McCarthy**
=================

In an article in the Harvard University Computing Center Newsletter in October of 1947, John McCarthy, the father of artificial intelligence, described a problem with a computer program as a "bug."

* * * * *

Hopefully, these historical facts remind you that software terminology is interesting because it is ever-changing and constantly evolving. As new software is created, new terminology is born.

Check out this post in the Art Of Code: <https://artofcode.tech/why-are-software-bugs-named-bugs/>
Creating java client application with spring boot
Tags: springboot
Published: 2022-08-03 22:02:00

I have a requirement for creating a client application in java (means a spring boot application with some front end using Thymeleaf). This frontend application should communicate with REST api to backend (which is another java application using spring rest) .

My question is what technology or tools can I use to create frontend in java. I mean some tools or framework names would be helpful. I am new to frontend development.

Thank you
Day 607 : Lovin' It
Tags: hiphop, code, coding, lifelongdev
Published: 2022-08-03 21:50:59

_liner notes_:
- Professional : Had a meeting. It was good to see everyone. Then started working on converting an old demo application to use a new SDK. Ran into an issue and sent a message to a the person working on it. Also spent some time putting together this Asia trip and reaching out to some folks on Meetup. Not a bad day.

- Personal : Studied some Kanji and did a review. Did pretty well. I think some of it is sticking. Wani Kani has a different way of studying than what I was doing before. I'm lovin' it. Also went through a bunch of tracks for the radio show.

![Trees with orange leaves coming up out of a lake in Sukko Lake, Russia.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i29n57ia780udqqqzehw.jpg)

Going to go through some more tracks probably from Bandcamp. Got some reviews coming up on Wani Kani. I'll probably also go through the documentation for the trip to Asia. Really want to get this stuff out this week.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube 3ZG_AOmqPSQ %}
Rescript React Error boundary usage
Tags: rescript, react
Published: 2022-08-03 21:09:56

Hi

I was trying to capture the react errors. I had to write the bindings for the ErrorBoundary and its usage is shown below.

The actual ErrorBoundary component is below
```
// ErrorBoundary.js
import React from "react";

class ErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false };
  }

  static getDerivedStateFromError(error) {
    // Update state so the next render will show the fallback UI.
    return { hasError: true };
  }

  componentDidCatch(error, errorInfo) {
    // You can also log the error to an error reporting service
    //logErrorToMyService(error, errorInfo);
    console.log({ error, errorInfo });
  }

  render() {
    if (this.state.hasError) {
      // You can render any custom fallback UI
      return <h1>Something went wrong.</h1>;
    }

    return this.props.children;
  }
}

export default ErrorBoundary;

```

Bindings to the ErrorBoundary for Rescript.
```
// ReactErrorBoundary.res
@react.component @module("./ErrorBoundary.js")
external make: (
  ~children: React.element,
  ~onError: ('e, 'i) => unit=?,
  ~renderFallback: ('e, 'i) => React.element=?,
) => React.element = "ErrorBoundary"

```

Error component to show the react error
```
// Error.res
module Error = {
  @react.component
  let make = (~error) => {
    <div> {React.string(error)} </div>
  }
}

```

How to use ReactErrorBoundary in rescript
```
// ReactErrorBoundary usage
<ReactErrorBoundary fallback={params => <Error 
  error=params.error />}>
  <ComponentThrowingException />
</ReactErrorBoundary>
```
Welcome Thread - v185
Tags: welcome
Published: 2022-08-03 21:03:05

---
title: Welcome Thread - v185
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---

![Corny retro guy waving onstage](https://media.giphy.com/media/JSqsZp9e4sIsE/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Secure Open Source Code in minutes for free with CodeSec
Tags: java, javascript, opensource, python
Published: 2022-08-03 20:53:00

Contrast Security is expanding its free developer tool, CodeSec, to include Open Source Security (OSS) and Software Bill of Material (SBOM) creation with its new SCA capability. Empowering developers to Identify vulnerable libraries in OSS and receive actionable remediation guidance, allowing them to ship code faster. The new feature will also enable users to manage software supply chain risk by allowing them to create SBOMs with ease.

**What is CodeSec?**
Contrast’s new free developer tool brings the fastest and most accurate scanner on the market right to developers for free. By packaging the same scanning engine used in our Contrast Security platform into a simple command-line interface (CLI), CodeSec empowers developers to scan, secure, and ship their code in minutes. 

**Getting Started with CodeSec - SCA in just 3 steps** 

**1.** Open a command-prompt or terminal, then install with NPM, Homebrew or by downloading binaries from Artifactory:

For this example will be using NPM. For other install options [click here](https://www.contrastsecurity.com/developer/codesec/).

```
npm install -g @contrast/contrast
```

**2.** Authenticate using your existing GitHub or Google account.

```
contrast auth
```

**3.** Time to Scan your Open Source!

Navigate to your chosen directory.
Then run a SCA scan on your Java, Javascript, Python, Ruby, GO, PHP, .NET code with the following command.

```
contrast audit
```

![CodeSec SCA Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08k4o3ybbhn02355uqko.png)

In minutes CodeSec by Contrast will report all vulnerabilities found with actionable remediation guidance.

**Happy Scanning!**
EasySSH - GUI host manager for Linux
Tags: ssh, gui, cloud, vps
Published: 2022-08-03 20:43:00

If you like to have your virtual servers catalogued and available quickly with SSH, a decent GUI for host manager may come in handy.

On macOS I absolutely love using [Core Shell](https://codinn.com/shell/), but I struggled a bit to find a decent Linux (Ubuntu) alternative for that. Until I came across [this post and review](https://www.linux.com/topic/networking/three-ssh-guis-linux/) by [Jack Wallen](https://www.linux.com/author/jlwallen/) at linux.com, and I finally found out about [EasySSH](https://github.com/muriloventuroso/easyssh)!

EasySSH is a decent piece of software, and it has all functionalities I have been looking for.

Configuring a host:

![Configuring a host](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tjvi72cymj7qahi7bkjw.png)

Connecting:

![Connecting with EasySSH](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/legdxhohmpodmx8rb5jc.png)

For the review and more screenshots please see the [post I linked above](https://www.linux.com/topic/networking/three-ssh-guis-linux/).

## Installing

The best part is that EasySSH that it is available via `apt`, so installing it is as simple as:

```
sudo apt-get -y install easyssh
```

Give it a try and let me know what you think in the comments!

---

Source of the graphics in the cover: Photo by <a href="https://unsplash.com/@erol?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Erol Ahmed</a> on <a href="https://unsplash.com/s/photos/library-catalogue?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Configure Gitlab Server for HTTPS
Published: 2022-08-03 20:39:00

Minimal configuration steps for Gitlab Server after you install it to create TSL certificates and run over https.

Step one is to actually make the TSL certs.

```sh
IP=`hostname -I | sed 's/ //g'`
mkdir -p /etc/gitlab/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/gitlab/ssl/${IP}.key -out /etc/gitlab/ssl/${IP}.crt
```

Get IP:

```sh
hostname -I
```

Now edit /etc/gitlab/gitlab.rb. Replace SERVER with the output of IP.

```ruby
external_url 'https://SERVER'
nginx['redirect_http_to_https'] = true

nginx['enable'] = true
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/SERVER.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/SERVER.key"
```
Even if the early bird tickets are out, you can still join us at DevoxxMa!
Tags: javascript, webdev, java, techtalks
Published: 2022-08-03 20:22:57

Who is joining us for #DevoxxMA 2022?
Don't have a ticket yet? Register today: https://register.devoxx.ma
📅 October 4th to 6th
3️⃣ Days of incredible developers content
🎤 +150 expert speakers
🤯 +120 sessions
🔬 Hands-on labs and deep dives
💃🏽 PARTYYY
Secure your ticket NOW!!!!
Day 116: This week is weird 😀
Published: 2022-08-03 20:18:10

Hi!
We are almost Thursday now and I can't believe I haven't done anything as weekly tasks goes I wonder how that is even possible but this week I feel so lazy and I don't feel bad about it like I intentionally choose to be lazy (weird? I know) Today I was going through flutter and Figma tutorials for Flutter I'm still going through the basics and setup actually I managed to successfully run my app in a simulator today and for Figma I was looking into Organizing and presenting a figma Project. 
I don't have any plan setup for tomorrow I will go with the flow.

Signing off...
Have you ever accidentally delete all the table data with Prisma?
Tags: prisma, middleware, updatemany, deletemany
Published: 2022-08-03 19:30:02

---
title: Have you ever accidentally delete all the table data with Prisma? 
published: true
description: It's not difficult to have a heart attack when you can delete a whole data of a table only because you missed ONE undefined. 
tags: Prisma, Middleware, updateMany, deleteMany
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
canonical_url: https://www.farmin.dev/posts/35ad668d-29ae-4d86-8b4a-126b6d561aaa
---

This not a story about a bug but rather a feature!

Have you ever used `table.updateMany` or `table.deleteMany` in your code? we have and it was something like this:

```
const deleteChildrenOfThatParent = await prisma.children.deleteMany({
  where: {
    parentEmail: {
      equal: parent.email,
    },
  },
})
```

It was working great for a long time and you know what, we had TS checking the types too but somehow someday we lost all of our children data in the table. 
We checked the database (Postgres) and we found out that at a certain time, all of the data has been wiped out! We blamed DevOps, hackers, AWS, ... but it was us not anyone else.

Finally, we figured out that we might had a situation that `parent.email` was `undefined`. But still we couldn't believe that `deleteMany` with a condition executed that. After some testing we were shocked but that was true and actually it made sense... our "where" clause made the code in a way that we deleted all the children only because of that `undefined`. we basically ran:
```
const deleteChildrenOfThatParent = await prisma.children.deleteMany({
  where: {},
  },
})
```

**What could have saved us though?**
## Retro

So we had a retro around it and there were some angry stakeholders there! We promised them that this would never happen again! first thing first we just found every `updateMany` and `deleteMany` functions and we bookmarked them. We could just put a condition before each one to check for undefined but this wasn't a permanent solution neither scalable one.
After some investigation, we found a great solution, yeah Prisma itself came to help :p

## Prisma Middleware
So what we needed to implement was something in the lower layer on the prisma which could check all the mutations to make sure we're not removing data that we don't want to delete. [Prisma Middleware](https://www.prisma.io/docs/concepts/components/prisma-client/middleware) is that thing YES!

we just implemented the middleware in a way that we check every query (mutations) and filter out the `updateMany` and `deleteMany` ones and make sure that there is a condition on them!

```JS
async function main() {
  prisma.$use(async (params, next) => {
    // Check incoming query type
    if (params.model === 'Post') {
      if (params.action === 'deleteMany' || params.action === 'updateMany') {
        //Check the Where clause in params.arg.where, if it's empty just return
      }
    }
    return next(params)
  })
```