teleren/devto huggingface dataset:
The C in MVC: Controllers 
Tags: 100daysofcode, javascript, mongodb
Published: 2020-08-12 20:01:34

6 days ago, i thought i was done with the sales inventory API until i asked a friend to review my code and he was like, "🤔mmmmh... you need controllers". My immediate reaction was what are those? And why on earth do i need them? I did not ask though, lest I'd be hit with an article: shorthand for go figure it out yourself😅. A few days/articles/videos later, here are the answers to my questions.

#### What are controllers?
A controller is a component of MVC (model-view-controller) that processes the business logic of an application. MVC is a design or architectural pattern used to separate 'apllication concerns' that is: the data logic, business logic and UI logic. The M (model) handles the data logic while the V (view) handles the UI logic.

#### Why do we need controllers?
When using the MVC pattern the controller acts as the interface allowing communication between  the model and view. You may wonder: Is it mandatory to use MVC? No. You may choose to use other design patterns such and MVVM (Model View View Model) or better still choose not to use any design pattern.

#### A basic implementation
Initially i had the logic in the routes files.
```javascript
router.route('/users/login')
    .post((req, res) => {
      User.findOne({ email: req.body.email }, async (err, user) => {
        if (err) {
          return res.send(err);
        }
        if (await bcrypt.compare(req.body.password, user.password)) {
          return res.send(`Welcome back ${user.firstName}`)
        }
        return res.send('Wrong Password');
      })
    });
```
I'll be moving all the logic to controller files and passing a function call.

User route.js file:
```javascript
const express = require(`express`);
const userController = require('../controllers/userController');

const router = express.Router();

router.route('/users/login')
  .post(userController.userLogin);
```
User controller.js File:
```javascript
const User = require('../Models/userModel');
const bcrypt = require('bcrypt');

const userLogin = (req, res) => {
  User.findOne({ email: req.body.email }, async (err, user) => {
    if (err) {
      return res.send(err);
    }
    if (await bcrypt.compare(req.body.password, user.password)) {
      // return res.send('Login sucessful')
      return res.send(`Welcome back ${user.firstName}`)
    }
    return res.send('Wrong Password');
  })
}

module.exports = {
  userLogin
}
```
It's that simple! 

_Day 27_
HOW TO USE ON GENERATE ROUTE IN FLUTTER
Tags: dart, flutter, material, mobile
Published: 2020-08-12 19:44:36

When I started using routes in flutter I tried to use the simple routing code. When my application started having multiple pages/screens and passing data between screens, then I realized I need a better way. Most flutter try to hack their way just to avoid using on generate route. It seems complex at a glance but very easy grasp when you pay attention to it.

#####On Generate Route
What the flutter team is saying is, instead of extracting the arguments directly inside the widget, you can also extract the arguments inside an onGenerateRoute() function and pass them to a widget. 
######Say our app always passes data to LocationScreen
I always to put my route in one file(route_generator.dart) so that it doesn't get mixed up and its a class. So we get the data from final args = settings.arguments; and pass it inside LocationScreen constructor. Refer to the image below
![Route Class](https://dev-to-uploads.s3.amazonaws.com/i/janyb2c9l07dtr4n84yc.png)

#####Setting Your Routes
So in the main.dart file I will call my initial route and set to the home screen using the name route not the name widget. I will also set my onGenerateRoute to the route method we created in our route class.
![Main](https://dev-to-uploads.s3.amazonaws.com/i/7r05vu8uti1r9fzusgv1.png)

#####Using Your Route With Arguments
So now we can pass arguments to our target screen through our route. With the route below, the pushNamed takes two parameters: first, for our named route and second, for the data we want to pass to LocationScreen
![Usage](https://dev-to-uploads.s3.amazonaws.com/i/ucsn9dwmau3xni0k4qat.png)

#####Creating Constructor In LocationScreen
Create a constructor in the LocationScreen. Make it required if your screen/page is always going to get data which in this case it is.
![Create](https://dev-to-uploads.s3.amazonaws.com/i/29ag4t8qmqh4m4yb8zhk.png)

#####Accessing data in LocationScreen State
This is where you have to use the fundamental of flutter. Now we will call widget and tap inside to get our weatherData. eg: widget.weatherData.
The LocationScreen object and the LocationScreen state object are linked. The state object knows which statefull widget it belongs to. So the state object has a property call widget which points to its parent.
![Access](https://dev-to-uploads.s3.amazonaws.com/i/77xk9qh1zy6qtsiqx5t3.png)

###Take Away
So you could see, on generate route is not difficult after all. The best route approach flutter offers you. So don't be like me back then when I was try to avoid the hard way.
Scaling Relational Database
Tags: database, csharp
Published: 2020-08-12 19:44:21

Video link below  

[![Database Sharding - Scaling Relational Databases](https://i.ytimg.com/vi/gx_qGL6HE5w/mqdefault.jpg)](http://www.youtube.com/watch?v=gx_qGL6HE5w "Database Sharding - Scaling Relational Databases")

RDBMs can be scaled horizontally in a number of ways, however two most most common ways are Read scale out and Sharding. Sharding is a technique to distribute large amounts of identically structured data across a number of independent databases. It is especially popular with cloud developers creating Software as a Service (SAAS) offerings for end customers or businesses. These end customers are often referred to as "tenants". Sharding may be required for any number of reasons:
The total amount of data is too large to fit within the constraints of an individual database
The transaction throughput of the overall workload exceeds the capabilities of an individual database
Tenants may require physical isolation from each other, so separate databases are needed for each tenant
Different sections of a database may need to reside in different geographies for compliance, performance, or geopolitical reasons.

In this episode I introduce the various techniques but focus primarily on Sharding. Horizontal scaling refers to adding or removing databases in order to adjust capacity or overall performance, also called "scaling out". Sharding, in which data is partitioned across a collection of identically structured databases, is a common way to implement horizontal scaling.
My first week with Plausible
Tags: seo, analytics, frontend
Published: 2020-08-12 19:41:28

---
title: My first week with Plausible
published: true
description: I've detailed my expierence trying out a new analytics platform, plausible. Let me know what you think!
tags: SEO, analytics, frontend
cover_image: 
---

TL:DR;
Plausible is great. It provides highly actionable information front and center. The interfaces are simple. You can have multiple domains on the same account and switch between them easily. 100% recommend trying it out if you're curious.
The main thing plausible gets right is simplicity. To get going you can sign up with nothing but your email. Then to start submitting traffic from your site, there's a tiny 1kb script tag you add to the head of your index and your done.
Super easy to setup and it doesn't bog your site down with massive scripts. 🎉 This would be my favorite part, if it wasn't for the fact that you can repeat that process for as many domains as you'd like. All on the same account.
One login, one bill and all the domains you take care of all being in one place is fantastic.
With the simple process also comes simple data. It shows you important things like bounce rate, session durations, location and page views. What it cant show you are large scale things like ad conversion, repeat users or audience reports.
Which in my opinion is fine. Not everything you make needs to have corporate level support features. I don't thing that's Plausibles goal and I appreciate that a lot. However the best way to sum up the information they do give you is...
"Are people interested in this site?" In a very general sense. For early idea validation, that is fantastic. I don't need to be able to generate a detailed report of every user that's landed on my page for the last 60 days, to know if people like something. 10/10 would recommend.
At the end of the day, use the tool that's best suited for you. If you just need to validate an idea from a landing page, use plausible. If you're building a corporate project with ads and such, probably go with Google.
Plausible is growing fast, so we'll see if that holds true in the coming years, but for now that's my take. 👍

---
Find me on [Twitter](https://twitter.com/FastFlowZ) | [LinkedIn](https://www.linkedin.com/in/dakota-lewallen/) | [Twitch](https://twitch.tv/iamflowz)
Sponsor me on [Github](https://github.com/iamflowz)
Like the article? [Buy me a coffee!](https://www.buymeacoffee.com/iamflowz)
How to get a job as a back end web developer?
Tags: webdev, backend, jobs
Published: 2020-08-12 19:36:58

Hi!
I hope you're all OK ;)
I'm Khaled and I'm 16.
I want to get a job as a back end web developer so I learned until now: HTML5, CSS3, JS
my next step is to follow this path from coursera:
https://careers.coursera.org/back-end-developer/
and then I will start searching for a job.
So my question is: can I get a job after finishing this path? Or I must take other courses?
Join us for Filecoin Master Classes
Published: 2020-08-12 19:27:30

[Filecoin](filecoin.io) is a decentralized storage network, powered by cryptocurrency, designed to store humanity’s most important information. It aims to solve a fundamental problem with today’s web: how to safeguard huge troves of data, whether it’s scientific data sets, priceless works of art, essential historical records, and so much more. Filecoin is a project of Protocol Labs, an open-source research, development, and deployment laboratory.

Protocol Labs is just one of many parties devoting their energy, talent, and resources to making Filecoin an important building block of the internet’s evolving infrastructure. We can't wait to see what the larger Filecoin community builds on the network. 

The Filecoin team is hosting a series of free, virtual Master Classes for anyone interested in learning more about how to build on the Filecoin network. Join us and become a master building on Filecoin.

Our first session, Monday, August 17, at 1 PM PDT, will show you how to integrate the Slate API with Filecoin and IPFS. [Slate](https://slate.host/) is a storage application and Filecoin network client that allows you to store images, audio, video, and data through a graphical interface or API. This session will be hosted by [Jimmy Lee](https://twitter.com/wwwjim), creator of Slate.

Slate is entirely [open source](https://github.com/filecoin-project/slate). Join more than a dozen contributors and a whole community creating an entire development, design, and product management process in the open!

Register [here](https://www.eventbrite.com/e/filecoin-masterclass-registration-116772053355)

Event link will be provided after registration.
Dealing with stress
Tags: watercooler, productivity, jokes, mentalhealth
Published: 2020-08-12 19:23:44

Alright. So I’m probably… definitely the worst person to go to about stress. I’m a very (very very) stressful person, and I have no idea why. I always think it’s because I take on a lot of work, but I get even more stressed out when I have no work to do. Shrug emoji.

So the point in this blog post is to talk about how I deal with stress, or more specifically, how you really should not deal with stress. Right now, I’m writing this as a procrastination tactic because I have so much work to do and my brain is in shut-down mode. In a couple of hours it’ll be in scream mode, which is basically what happens when I procrastinate too much and then have to do everything all at once.

Haha!

##Step 1 in dealing with stress
Look at everything you have to do all at one go. Take a look at your to-do list for the week, or even better, the number of tasks you have to go through in JIRA for the entire month. Take it all in. Don’t prioritize. Don’t divide tasks up into smaller bite-sized chunks. Look at all of it.

##Step 2
Freak out about everything you have to do and take a break to calm yourself down. You’ve earned this break. Looking at your entire month in JIRA is a brain-wrecking, tear-jerking task. You deserve to pamper yourself.

##Step 3
Don’t pamper yourself. Take a break in order to calm yourself down but don’t take any steps to achieve that. Let those JIRA tasks wonder around in the back of your mind… aimlessly… peacefully… until they all merge together to form one massive ball of disorder and anxiety and run to the front of your mind. They’ll scream at you. Scream back at them.

##Step 4
Try to push the scary JIRA tasks back into your subconscious by thinking about other things. Sprint to the fridge and make sure you have enough milk for today. Think about that word sprint. Remember your JIRA sprint. Scream again.

##Step 5
Look around your environment. Take in the world. Realize how lucky you are to even be stressed in the first place. You have things to gain and things to lose. Remember everything you could be losing right now. And also remember the laundry you were meant to do yesterday but didn’t because you were screaming.

##Step 6
Do that meditation thing. Sit down, visualize your thoughts leaving your mind, focus on how you’re breathing. Fail. Think about how you’re failing. Think about your previous internet search query about how to meditate. Try to figure out why it didn’t work for you. Open Google and search it again. Freak out about how Google is evil and stealing your data. Switch to duckduckgo.

##Step 7
Open JIRA again. Go to your text editor. Make a to-do list for today. Overestimate the work you can get done. Freak out about how you’ve overestimated the work you can get done.

##Step 8
Write a blog post.
FREE Course on Node.js- Creating Server - From INSTALLATION to HOSTING - LIIMITED TIME
Tags: tutorial, codenewbie, udemy
Published: 2020-08-12 19:09:04

Special Coupon Link,for free course - FIRST 10 ONLY!!

https://www.udemy.com/course/nodejs-crash-course-for-backend-engineer/?couponCode=288A7CCC7BD353039B7F
Label Bounding Boxes with the Universal Data Tool
Tags: machinelearning, datascience, computerscience
Published: 2020-08-12 19:08:00

Labeling your data with bounding boxes is an essential first step before training a machine learning algorithm. The [Universal Data Tool] (https://universaldatatool.com/) is a free, open-source application that makes this process simple.

Before you start, you should have either...

A directory of images
A file where each line is an image URL (this is what I'll use)
Configure the Job

# Configure the Job
To begin navigate to [universaldatatool.com](https://universaldatatool.com/) or download the latest release from [github] (https://github.com/UniversalDataTool/universal-data-tool). I'll use the web version for now.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1kvd93xir7v1z39qgvla.png)


Click "Create from Template" and select Computer Vision, then configure it to only do bounding boxes. If you also want to label each bounding box with a classification, you can also configure that here.

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

# Import the Data
Navigate to "Samples", then to the "Import" page. Click "Paste Image URLs", paste the image urls and click "Add Samples".

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

# Label the Data
You can now begin labeling. Click the "Label" button at the top, then click on any sample to begin. Samples will turn blue as they're labeled.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/65pii0lzthswl2y0hs6e.png)


# Wrapping Up
When you're done, navigate to the "Settings" tab and click Download JSON. The resulting file can be loaded into the Universal Data Tool again, or parsed for usage with a machine learning algorithm.

That's it! You now have everything you need to add bounding boxes to an image dataset. Be sure to follow us on [Twitter] (https://twitter.com/UniversalDataTl), or join our [Slack] (https://app.slack.com/client/TJHDHA484) to hear more!
Nibbles: Optional chaining
Published: 2020-08-12 19:07:20

The optional chaining operator allows you to simply check deep chains in a within an object without having to verify every step.

## Syntax
```js
object?.prop1?.prop2?.prop3
```

## Example
{% jsfiddle https://jsfiddle.net/link2twenty/21butxrn/ js result %}

## Support
Current support is all major browsers except IE.

### Further reading
[Optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining)
[caniuse](https://caniuse.com/#feat=mdn-javascript_operators_optional_chaining)
Quickly changing directories in your terminal
Tags: terminal, bash, zsh, productivity
Published: 2020-08-12 18:46:02

---
title: Quickly changing directories in your terminal
published: true
description: Tools and tips for learning how to navigate your terminal quickly and efficiently.
tags: terminal, bash, zsh, productivity
canonical_url: https://www.dropseed.io/posts/quickly-changing-dirs/
---

If you spend a lot of time on the command line, eventually you'll want to know some quick ways to `cd` around.

There are a lot of tricks and tools you can find, but these are the two I use.

## Z - "jump around"

Z is fast, one-character, and becomes second nature.

To use it, type a few characters and it will `cd` straight to the most "frecent" directory that you use.

```sh
~/Development
❯ z pul

~/Development/dropseed/pullapprove master ⇣
❯
```

Technically this should be a regular expression, and there are more advanced ways to use z, but usually just hitting the first few characters (or the most unique ones) will get you where you intend to go.

An easy way to install it is with [Homebrew](https://brew.sh/):
```sh
❯ brew install z
```

[Learn more on the GitHub repo →](https://github.com/rupa/z)

## Aliases for cd

If you're using Bash, there are couple of aliases you can add to your `~/.bashrc` to make it easier to navigate back *up* the directory tree.

```sh
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
```

Now when you need to jump back a directory or two, you can simply do:
```sh
~/Development/dropseed/pullapprove master ⇣
❯ ...

~/Development
❯
```

Instead of:
```sh
~/Development/dropseed/pullapprove master ⇣
❯ cd ../..

~/Development
❯
```

It's a small thing, but when you realize how often you do it, you'll be happy to save the keystrokes.

> Note that if you are using zsh, you can get this same functionality by enabling `autocd` (or using oh-my-zsh).

You can also throw in a few very specific `cd` aliases. These are two that I use regularly:

```sh
alias dl="cd $HOME/Downloads"
alias dev="cd $HOME/Development"
```
Is "let" not a reserved keyword in JavaScript
Tags: javascript, beginners
Published: 2020-08-12 18:39:49

We can declare a new variable in JavaScript by using `var`, `let`, or`const` keywords.

For Example,
```
var a = 10;
let b = 20;
const c = 40;
```

I was playing around with above syntax, and tried something silly.

```
var let = 100;
var const = 100;
```

And. the result was surprising. `let` variable was successfully created, but for const I got an syntax error.

![let as a variable](https://dev-to-uploads.s3.amazonaws.com/i/gi54dihazdjs15y36el2.png)

You might be thinking why defining `let` as a variable did not give syntax error. I was thinking the same.

 
You might be curious to know why it happened. So, here goes your answer:

JavaScript have some reserved keywords which we can't use as a variable/identifier. Below is the list of reserved keywords as per ECMAScript 2015 (source [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar)): 

###Reserved Keywords###
`break`, `case`, `catch`, `class`, `const`, `continue`, `debugger`, `default`, `delete`, `do`, `else`, `export`, `extends`, `finally`, `for`, `function`, `if`, `import`, `in`, `instanceof`, `new`, `return`, `super`, `switch`, `this`, `throw`, `try`, `typeof`, `var`, `void`, `while`, `with`, `yield`, 

###Below are future reserved keywords ###

`enum`

###Reserved only when used inside a module ###

`await`

###Only reserved when used in strict mode ### 

`implements`, `interface`, `let`, `package`, `private`, `protected`, `public`, `static`



So From above list, as `let` is reserved only when strict mode is used. So I tried below code:

```
"use strict";
var let = 100;
```
Now finally, it gives error when `let` is used as a identifier.

![Use of Let in use strict mode](https://dev-to-uploads.s3.amazonaws.com/i/bqp8g895z7p5h2fw9mmw.PNG)



In same way we can use below keywords an identifier.

`implements`, `interface`, `let`, `package`, `private`, `protected`, `public`, `static` 

In strict mode it will give syntax error.


**Note: ** It is good idea to always give you identifier a meaningful name. Do not use reserved keyword as an identifier.

What's you thoughts, let me know in the comments.
Fizz? Buzz? FizzBuzzz!
Tags: webdev, career, beginners, javascript
Published: 2020-08-12 18:29:25

---
title: Fizz? Buzz? FizzBuzzz!
published: true
description: Interview Question
tags: #webdev #career #beginners #javascript
//cover_image: https://direct_url_to_image.jpg
---

## Interview Question:

Write a short program that prints each number from 0 to 100 on a new line. 

For each multiple of 3, print "Fizz" instead of the number. 
For each multiple of 5, print "Buzz" instead of the number. 
For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.

## Solution 1:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7xnoub50ynw96tzwhtb3.png)

## Solution 2:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6c81cmru9x0m8jclc6gn.png)

Comment below your approach!