teleren/devto huggingface dataset:
Escape If-else hell in Javascript
Tags: javascript, tutorial, productivity, beginners
Published: 2021-10-31 06:52:01

###Backstory / Problem

Few months ago, there is a certain case where I need to calculate the percentage of input file in each form that user has filled (It was for a react native app that take user feedback by filling several form that represent different category such as personal information form, the user property information, etc.), the system flow look like this in a nutshell.

![System flow in nutshell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jaxjtqua09bslt0e1qq.jpg)

The first approach was using if/else statement to handle the conditional logic. Although it might be a good idea for one or two conditions here and there, using multiple if-else statements chained together will make your code look very ugly, and less readable, and for my case there is probably more than 30 if-else statements in scattered in 5 different forms. Not gonna lie, it look very simple and straight to the point, yet painful to read.

Also, when my peer reviewing the PR, he refers something humorous in reddit about [the code behind yandere simulator](https://www.reddit.com/r/ProgrammerHumor/comments/53uhsw/the_code_behind_yandere_simulator/)
![Yandere Simulator code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5m0oeqx4w8xcva3hf6x.png)

As you can see, it is a hell of if-else statements.

###The solution

The solution will be vary, depends on your case / need. But most likely the thing that you need is **object**. As for instance, let's say you need to return a string based on a key

```JavaScript
function checkStatus(status) {
    if (status.toLowerCase() === 'available') {
        return `The user is currently available`
    } else if (status.toLowerCase() === 'busy') {
        return `The user is currently busy`
    } else if (status.toLowerCase() === 'away') {
        return `The user is away from keyboard`
    } else if (status.toLowerCase() === 'breaktime') {
        return `The user is having a good lunch`
    }
}
```

Just imagine if you have other 20+ status type ? Will you be comfortable reading or writing that much line of if-else statements?

Instead we can use object or **Map object** to make a sort of table consist of paired key and value to look up to.

```javascript
function checkStatus(status){
const statusList = {
   available: 'The user is currently available',
   busy: 'The user is currently busy',
   away: 'The user is currently away from keyboard',
   breaktime: 'The user is currently having a good lunc'
}

return statusList[status]; //console.log(statusList[status])
}
```

This can be also applied in algorithm leetcode-type-of-question to save you up some time from writing repeated if-else statement over and over again.

Thanks for reading!!!
Have a good day, and remember that project you always think about won't code itself 🤪.
7 Nice API for your projects !
Tags: javascript, webdev, beginners, codenewbie
Published: 2021-10-30 14:41:31

**API** is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other!

Today I will share with you some nice API to use for your projects!!

### 🍿 Movie database (IMDB)

_https://developers.themoviedb.org/3/getting-started/introduction_

If you need informations about movies, series, etc... You can use IMDB API that is very easy to use!

### 🥄 Food Recipes (spoonacular)

_https://spoonacular.com/food-api/docs_

Are you looking for recipes? Soonacular is a great api that will provide you some recipes for your next project!! 

### 👽 Rick & Morty database

_https://rickandmortyapi.com/documentation/_

The Rick and Morty API is based on the television show Rick and Morty. You will have access to about hundreds of characters, images, locations and episodes !!

### 🩲 Random Advice

_https://api.adviceslip.com/#top_

Very fast api to use! It will provide you some random advice!

You can test it right now from this url _https://api.adviceslip.com/advice_


### 🥸 Fake User

_https://randomuser.me/?ref=undesign_

Do you need fake user for your website? This API will give you a list of fake user!

### 🤡 User icons (DiceBear)

_https://avatars.dicebear.com/docs/http-api#options_

DiceBear is an avatar library for designers and developers. You can test it fastly at this url for example: _https://avatars.dicebear.com/api/male/john.svg?background=%230000ff_

### 🐱 Cats fact

_https://alexwohlbruck.github.io/cat-facts/_

This app will combine APIs and Services from the web to do just one thing… send cat facts.


---

I hope you like this reading!

🎁 You can get my new book `Underrated skills in javascript, make the difference` for FREE if you follow me on [Twitter](https://twitter.com/code__oz) and send message to me 😁 and **SAVE 19$** 💵💵

Or get it [HERE](https://codeoz.gumroad.com/l/RXLYp) 

🇫🇷🥖 For french developper you can check my [YoutubeChannel](https://www.youtube.com/channel/UCC675U1ZUPFASsK9-FjawtA)

🎁 [MY NEWSLETTER](https://www.getrevue.co/profile/code__oz)

☕️ You can [SUPPORT MY WORKS](https://www.buymeacoffee.com/CodeoZ) 🙏

🏃‍♂️ You can follow me on 👇

🕊 Twitter : [https://twitter.com/code__oz](https://twitter.com/code__oz)

👨‍💻 Github: https://github.com/Code-Oz

And you can mark 🔖 this article!
1 line of code: How to get the index of the lowest numeric item of an Array
Tags: javascript, webdev, performance, codequality
Published: 2021-10-30 14:56:46

```javascript
const indexOfLowestNumber = arr => arr.indexOf(Math.min.apply(null,arr));
```
Returns the index of the first occurrence of the lowest numerical item of the array. 

---

## The repository & npm package

You can find the all the utility functions from this series at [github.com/martinkr/onelinecode](https://github.com/martinkr/onelinecode)
The library is also published to [npm as @onelinecode](https://www.npmjs.com/package/@onelinecode/onelinecode) for your convenience.

The code and the npm package will be updated every time I publish a new article.

---

Follow me on [Twitter: @martinkr](http://twitter.com/_martinkr) and consider to [buy me a coffee](https://www.buymeacoffee.com/martinkr)

Photo by [zoo_monkey](https://unsplash.com/@zoo_monkey) on [Unsplash](https://unsplash.com/s/photos/fuji)

---
tsParticles 1.37.1 Released
Tags: showdev, javascript, webdev, html
Published: 2021-10-30 23:41:00

# tsParticles 1.37.1 Changelog

## Bug Fixes

- Fixed issue with dynamic imports and async loading
- Added browserslist to fix some issues with older browsers (should fix #2428)

---

{% github matteobruni/tsparticles %}
airth06_01.java
Tags: java, beginners, programming, tutorial
Published: 2021-10-31 07:31:12

```java
// ~Airthmatic Operators
// problem:
	// airth06_01.java{wirte java program showing the waorking of all Airthmatic Operators.}
class airth06_01
{
	public static void main(String args[])
	{
		int x= 10 , y= 10;
		System.out.println("Value of x = "+x+" and value of y = "+y);
		System.out.println("SUM of "+x+" and "+y+" is "+(x+y));
		System.out.println("SUBSTRACTION of "+x+" and "+y+" is "+(x-y));
		System.out.println("MULTIPLICATION of "+x+" and "+y+" is "+(x*y));
		System.out.println("DIVIDE of "+x+" and "+y+" is "+(x/y));
		System.out.println("MODULAS of "+x+" and "+y+" is "+(x%y));
		System.out.println("SUM and EQUAL of "+x+" and "+y+" is "+(x += y));
		System.out.println("SUBSTRACTION and EQUAL of "+x+" and "+y+" is "+(x -= y));
		System.out.println("MULTIPLICATION and EQUAL of "+x+" and "+y+" is "+(x *= y));
		System.out.println("DIVIDE and EQUAL of "+x+" and "+y+" is "+(x /= y));
		System.out.println("MODULAS and EQUAL of "+x+" and "+y+" is "+(x %= y));
		System.out.println("ENDING THE PROGRAM...\n:-) THANK YOU (-:");
	}
}
```
Hacktoberfest 2021 Experience
Tags: hacktoberfest, opensource, github
Published: 2021-10-31 07:38:13

My first Hacktoberfest experience and it has been an interesting one so far. I got the opportunity to be involved with my local tech community during this period, working more with GIT and Github. I will be finishing this edition with 6 PRs .....😊. I'm hoping to participate in the upcoming Hacktoberfest editions.💪
CV's Absurd
Tags: recruitment, cv, career, news
Published: 2021-10-31 10:44:42

One of the responsibilities I have as an Engineering Manager in YouGov is being also a hiring manager for my team. I'm responsible for the process because I care to find a correct balance between skills & the need for more engineers ([Open Positions](https://jobs.yougov.com)).

{% twitter 1454293034179317764 %}
When I've read a Reddit [thread](https://www.reddit.com/r/recruitinghell/comments/qhg5jo/this_resume_got_me_an_interview/) about a software engineer who got tired of getting rejected by automated screeners and filled their CV with absurd information they got a 90% call back rate from companies like Reddit, AirTable, Dropbox, Bolt, Robinhood, and others I was like

![WTF](https://i.giphy.com/media/J34ARJKZmxZACE7DvJ/giphy.webp)
### &nbsp;
### Reality check
I've heard about these tools before, but I wasn't aware of how strict the rules are to get a good score.
I liked my CV because I got positive feedback about it from different recruiters which actually read it, so I've put my CV into the free evaluating tool available [online](https://resumeworded.com/), and my CV's initial score was 23/100 😱!

![score](https://www.rogowski.page/images/Screenshot%202021-10-31%20at%2010.43.48.png)

So I assume I wouldn't receive a call from any company that is using the screening tool - which sucks. After spending 15 minutes and making some quick fixes (mostly structure) I re-tested my CV and my score was 67.

![score](https://www.rogowski.page/images/Screenshot%202021-10-31%20at%2011.03.13.png)

Now I have to focus on the impact section and I can probably go much higher without lying -but I liked the CV before changes more.

### Transparency
We all want to reduce bias in our recruitment process - me too.
Automating stuff seems like a really good idea because algorithms are not biased, except the process still is. People which know about the ATS (Applicant Tracking System) vs people which don't and are not aware of how relevant it is.

What would be great is to be more transparent with candidates and if they were rejected because their CV didn't go through the automation we should just tell them that. We can even provide automated feedback to them, the same as some companies do with automated tasks & assignments. But transparency should be a Two-Way street, and if you plan to lie in your CV please don't, the company will find out anyway through assignment or interview but everyone will waste their time already.

So if you didn't hear back from the big company you would love to work for don't worry maybe just tweak your CV :).
Spooky Dev Stories
Tags: halloween, spooky
Published: 2021-10-31 13:38:49

---
published: true
title: Spooky Dev Stories
description: Halloween dev stories
tags: halloween, spooky
cover_image: https://raw.githubusercontent.com/crisarji/blogs-dev.to/master/blog-posts/2021-10-spooky-dev-stories/assets/spooky-dev-stories.png
series:
canonical_url:
---

Hello developer pal!, glad to see you here.

What about sharing one spooky story from your life as dev?, me first!

When I started to work, it was as a Jr BE dev, using `C#` and `Visual Source Safe`, there was this delivery we needed to accomplish in one week, so I started coding on Monday, Tuesday, I made a couple initial commits, the CI/CD we had that time took the changes, created an artifact minimized and optimized, deployed it to QA and that was all, everything was running smoothly.

Next 3 days, I was so focused in my work that I completely forgot to commit, 3 days in a row without committing, on Friday afternoon, I finally did, and guess what?, the panic.

Something happened that I lost all my changes, I tried to recover it in any possible way, unsuccessfully. After spending a couple hours, I went to my boss, sure that I was gonna get fired, explained the whole situation, and instead of asking me for a card box, he sat at my desk, helped me to track down the latest deploy(from 3 days ago), disassembled some minimized files(function names as `i`, return values as `x`, etc), stand up from my desk and just said `Good luck during the weekend`, then left.

After spending the whole weekend decoding and remembering what a function with signature `(a,b,c)` with a return `z` could be, and not sleeping at all, I was able to deliver by Monday.

Moral: always commit!

Thanks for reading!
What are the things that scare you as a Developer? 🎃
Tags: discuss, beginners, programming, career
Published: 2021-10-31 12:47:18

Happy Halloween, everyone!

I think the question fits the theme, so I'd like to ask everyone: 

**What are your fears as a developer?**

Here are the things I'm scared of (reasonable or not aside):
- not being able to find my next freelance client.
- production bugs.
- performance anxiety when showing interviewers and clients my work output.
- Imposter Syndrome (fear of being a fake or being too dumb)
- that my Imposter Syndrome isn't even real, and that I actually suck.


- running into a bug that has no StackOverflow, Github issues, and/or online solutions (which means I need to figure it out on my own).
- posting a question online (especially on SO) where others might judge me.
- the feeling of I'm not improving enough (lack of visible progress).

Almost forgot to add:
- not understanding what I'm reading 

I'd like to know what you all are afraid of as fellow developers!  

<hr />

**Note: I'm learning a lot from what everyone's sharing. Thank you, everyone!**
  
### Other Media

Feel free to reach out to me in other media!

<span><a target="_blank" href="https://www.rammina.com/"><img src="https://res.cloudinary.com/rammina/image/upload/v1638444046/rammina-button-128_x9ginu.png" alt="Rammina Logo" width="128" height="50"/></a></span>

<span><a target="_blank" href="https://twitter.com/RamminaR"><img src="https://res.cloudinary.com/rammina/image/upload/v1636792959/twitter-logo_laoyfu_pdbagm.png" alt="Twitter logo" width="128" height="50"/></a></span>

<span><a target="_blank" href="https://github.com/Rammina"><img src="https://res.cloudinary.com/rammina/image/upload/v1636795051/GitHub-Emblem2_epcp8r.png" alt="Github logo" width="128" height="50"/></a></span>
My First week in BootCamp(TaskForce 4.0)
Published: 2021-10-31 16:52:03

am very excited to share my first week experience in bootcamp which was prepared by awesomity in parteniship with Code of Africa. 
bootcamp started on 25th october and today is the end of first week in 6weeks we have to complete.

i don't know where i can start because i can't put it all in words it might take 100pages but lemme start.

we started on monday 25th october with good game of trying to lift egg and curry it with a ring and put it on bottle.(was hard) but we learnt how team works and we needed it. we had some more soft skills and as well as some coding challenges of codewars.

we learnt how to make user stories and their acceptance criteria and i liked it and helped me and we used it at the end of week where we had presentation of our new project(showApp) 

as conclusion , we really had good week and am so ready of more 5weeks to come. i will be back here next week to tell you how 2week treated me. Thank you
My Journey
Tags: python, programming, career, beginners
Published: 2021-10-31 17:51:07

This is my first post detailing my journey to a career in Software Development!

My most proficient language by far is Python.  I love doing everything in Python.  I don't know if I am interested in a data science career but I would like to do more with it.  I learned the Django framework to expand on my Python knowledge.

I hold two technical certificates in website development and  I am able to use HTML, CSS, and Javascript.  I am currently taking a class on Javascript to expand my knowledge and am considering learning either MERN or MEAN stacks.

When I start my junior year at Western Governor's University I will be learning C# and .Net development.  I've already taken a class on C#/Visual Basic so I'm somewhat aware of the basics.

I will try to do frequent updates as I learn new things.  I'm currently working on my portfolio website using HTML/CSS/Boostrap/Javascript/Python/Django/PostgreSQL and I'm really happy with how it's turning out.
Exemplo de Projeto Utilizando Sagemaker MultiModel
Tags: aws, python, sagemaker, datascience
Published: 2021-11-09 21:52:50

---
title: Exemplo de Projeto Utilizando Sagemaker MultiModel
published: true
date: 2021-04-30 00:00:00 UTC
tags: aws,python,sagemaker,datascience
canonical_url: http://gabubellon.me//blog/exemplo-de-projeto-utilizando-sagemaker-multimodel
---

Este é um post feito a muitas mãos de um projeto dentro da Conta Azul junto a AWS

Leia o artigo [aqui](https://aws.amazon.com/pt/blogs/aws-brasil/como-a-conta-azul-criou-um-sistema-de-gerenciamento-e-inferencia-de-modelos-utilizando-o-amazon-sagemaker-multi-model-endpoints/)
SPO600 - Update
Published: 2021-10-31 19:02:15

Where I'm standing currently with my SPO600 course (software portability and optimization) is quite behind. I've admittedly been slacking a bit which I know is not good and therefore the lab content is confusing to me.

I will hope to get these labs (3 and 4) done in the next blogging period so that I can keep up with further content and learn new things.

In the meantime, I will be going over the lectures that I have missed to prepare myself for these labs. I will be blogging about my reflection on those lectures shortly.
Hacktoberfest: Small changes make a big impact
Published: 2021-10-31 19:09:30

For my first issue to tackle for realease0.2 I decided to go with something I was more comfortable with, but in a different environment. 

I picked up an issue from Telescope that was front-end and a bug. This was perfect because it wasn't too much pressure for me, and something I can start without feeling overwhelmed. 

## The issue:
Essentially, the header for "what is telescope" had really bad wrapping. Another issue I noticed was that the headers in the readme were not consistent. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8h2to0zp8abla3pe0sg0.png)

 

The challenged I faced was that this was in the readme file, and would involve page responsiveness. I'm not too familiar with markdown, and a few months ago I would say I have no idea how to use it. After creating our SSGs I felt as if I should know more about markdown. 

## The solution
I realized that I could either do one of two approaches: 
1. Change the wrapping of the heading
2. Change the size of the image for the logo.

After playing around with both of these, I realized the wrapping would not give a consistent solution. I therefore went with the second option, to change the size of the logo. 

It was funny to me how a small change from the height and width made a significant difference to how the readme looked - and it was noticeable. 

## Reflection
After making my changes, and having my PR merged, I noticed that the changes were actually reverted in another PR. It's funny how  open source works. Sometimes the changes we make are significant in that point in time, and then have to be adjusted once more as new content is added. When I first saw the PR that reverted this, I was upset. I decided to read further as to why it was reverted, and realized it made sense. 

This is my [PR where it changes the height and width from 150 to 100](https://github.com/Seneca-CDOT/telescope/pull/2338/files) 


This is Diana's [PR where it changed the height and width from 100 to 130](https://github.com/Seneca-CDOT/telescope/pull/2356/files)

So in summary, although we make contributions and they work, it should go without saying, it won't always be the solution for every case, especially when adding new features.
Javascript and code documentation
Published: 2021-10-31 21:43:30

javaScript is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled and multi-paradigm. It has dynamic typing, prototype-based object-orientation and first-class functions.

#### Why code documentation?
If you wrote a couple of functions for making an HTML table with JavaScript. You could use those function right now, or pass them to another developer. Everything is clear in your mind the moment you write the code, yet a month later you don't remember how to use function A or function B anymore. How function A is supposed to be called? What parameters it takes? And what shape should the parameters have?
 Code documentation helps you and other developers understand how to use the software you wrote. There are many ways for documenting a piece of code. For example you can write:

* howtos guides for using your code
* a nice README for the repo
* code documentation in the source
But on top of how-to and READMEs, code documentation in the source holds most of the value. It sits right there with the code and helps avoiding mistakes as you write JavaScript in the editor.

 Consider the following function:

```javascript
function generateTableHead(table, data) {
  const thead = table.createTHead();
  const row = thead.insertRow();
  for (const i of data) {
    const th = document.createElement("th");
    const text = document.createTextNode(i);
    th.appendChild(text);
    row.appendChild(th);
  }
}
```

This function kind of speaks for itself, generateTableHead. The data parameter doesn't specify what it should execute or what data should be.
If we look at the function's body, it becomes evident that "data" must be an array. table on the other hand does not make it clear if it is to be a string or an actual html element.
We simply as add a comment before the function:

```javascript
/**
 * Generates a table head
 */
function generateTableHead(table, data) {
  const thead = table.createTHead();
  const row = thead.insertRow();
  for (const i of data) {
    const th = document.createElement("th");
    const text = document.createTextNode(i);
    th.appendChild(text);
    row.appendChild(th);
  }
}
```
This is the standard code documentation. The function generateTableHead" should take an HTMLTableElement and an array as parameters. We can add annotations for both like 

```javascript
/**
 * Generates a table head
 * @param {HTMLTableElement} table - The target HTML table
 * @param {Array} data - The array of cell header names
 */
function generateTableHead(table, data) {
  const thead = table.createTHead();
  const row = thead.insertRow();
  for (const i of data) {
    const th = document.createElement("th");
    const text = document.createTextNode(i);
    th.appendChild(text);
    row.appendChild(th);
  }
}
```

Code documentation is often overlooked and considered more or less a waste of time. Great code should speak for itself. And that's true to some extents. Code should be clear, understandable and plain. Writing documentation for code can help your future self and your colleagues.