teleren/devto huggingface dataset:
Code Smell 89 - Math Feature Envy
Tags: oop, webdev, cleancode, tutorial
Published: 2021-10-04 15:28:04

*One class calculating formulas for another class.*

> TL;DR: Leave the formulas to the objects gathering the information.

# Problems

- Declaratively

- Low reuse

- Real-world concept missing

- Encapsulation

# Solutions

1. Move the math formula to the class

2. Search for [real-world abstractions](https://dev.to/mcsee/the-one-and-only-software-design-principle-3086)

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/4b3483f5be825913df7a6c709efebdbc)
```javascript
function area(rectangle) { 
  return rectange.width * rectangle.height;
  //Notice we are sending consecutive messages to
  //the same object and doing calculations
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/891b1df84cd9e0528fad2dae42322c54)
```javascript
class Rectangle {
    constructor(width, height, color) { 
         this.height = height;
         this.width = width;
    }
 
    area() {
        return this.width * this.height;
    }
}
```

# Detection

Since many cascading messages are sending to the same object, we can detect a pattern.

# Tags

- Encapsulation

- Coupling

# Conclusion

This is a very basic smell. If we are manipulating another object characteristics, we should let it do it the maths for us.

# Relations

{% post https://dev.to/mcsee/code-smell-63-feature-envy-502f %}

# More Info

- [The one and only one software principle](https://dev.to/mcsee/the-one-and-only-software-design-principle-3086)

# Credits

Photo by <a href="https://unsplash.com/@michalmatlon">Michal Matlon</a> on <a href="https://unsplash.com/s/photos/math">Unsplash</a>
  
* * *

> Computer science is not about machines, in the same way that astronomy is not about telescopes. There is an essential unity of mathematics and computer science.

_Michael R. Fellows_
 
{% 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 %}
How to make A calculator With Js With Source Code
Tags: javascript, css, html, beginners
Published: 2021-10-04 15:19:25

In this Post You Will Learn How To make a simple calculator using vanilla Javascript 

Source code
https://codesandbox.io/s/zen-napier-lipwv

Youtube Video
https://www.youtube.com/watch?v=CI2GwL--ll8
ASK: how do you feel about starting selling github repo?
Tags: github, startup, webdev, discuss
Published: 2021-10-04 15:15:25

Hello to dev.to community. We are improve our marketplace [code.market](code.market) step-by-step, and now we wannа give to developer option: 

*Selling private github repository via our platform*

*This is a little bit custdev:* Would this option be useful or not? I would love catch your detailed answer in the comments. 

Thank you 🙏
Windows, Angular CLI, and NodeJS
Tags: angular, windows, node, development
Published: 2021-10-04 15:12:51

---
title: Windows, Angular CLI, and NodeJS
published: true
description: I recently had the honor of working with a neighbor beginning his development journey. I saw that he was using Git Bash ... mostly unsuccessfully. He had figured out some creative `npx` commands.
tags: Angular, Windows, NodeJS, Development
series: Reference Windows
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vgk5zmbjnj4nerpit45g.png
---

I recently had the honor of working with a neighbor beginning his development journey. He is taking a course through his employer and using a work computer with Windows installed.

Initially, I saw that he was using [Git Bash](https://gitforwindows.org/) ... mostly unsuccessfully. In particular, the Angular CLI was failing with `command not found.` He apparently had figured out some creative `npx` commands.

I wanted something simpler for him.

Knowing he had NodeJS installed, we set the path to the Angular CLI and made a custom shortcut to the NodeJS Command Prompt.

## Setting the Path

We followed the rabbit hole and found the Angular CLI in the following location ...

```script
C:\Users\<username>\AppData\Roaming\npm\node_modules\@angular\cli
```

Then, we opened the Environment Variables and added this to the Path. This ensures that we are able to reference the CLI in the command prompt later.

![Windows Environment Variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsp3gs45e275q6m6jtvo.png)

![Windows Environment Variables - New](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/el31d8hvciif79hgsz8a.png)

## Custom Shortbut

Then, we located the NodeJS Command Prompt shortcut ...

```script
C:\Program Files\nodejs
```

We then copied the shortcut and placed it on the desktop to make things a bit easier.

The biggest change we made to the shortcut was to set the "Start In" folder to the root of his projects folder ... we got to these settings by Right-Clicking and selecting Properties.

![NodeJS Command Prompt Properties](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlzptzhf73fzv71m881l.png)

The TARGET here should be ...

```script
C:\Windows\System32\cmd.exe /k "C:\Program Files\nodejs\nodevars.bat"
```

## Windows 11

The previous information works for Windows 10 and Windows 11. However, I've used the newer terminal settings to add a profile. These images have everything I think you need.

Add the prompt to the list ...

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

Then, set is as default ...

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

## Conclusion

This simple setup gave him much more flexibility without any hassles for Angular development using the CLI.
Git hooks and Docker for Continuous integration - part 2
Tags: docker, devops, cloud, codequality
Published: 2021-10-04 15:00:24

# Local Continuous integration flow

---

## User branch - pre-push git hook

A CI build process will be triggered by a User *pre-push* Git Hook. At the end of each build the CI pipeline status will be displayed on the Git repository (if you want, you can even stop user pushing code change if the CI process fails 🛑 )

![Alt User git branch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4a3oh0nqeegct78w8n8k.png)

---

## Main branch - after merge

If the User branch or Pull request is ✅ , we can use Github or Bitbucket api for merging the code/Pull Request.
Once the Pr has been merged we can trigger an automatic CI pipeline on Main/Master branch.

![Alt Master branch merge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbwavjt74tnya0nwtxft.png)

---

## How to run multiple parallel CI pipelines with Docker

![Alt Docker networks](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iyltc42fqfiwlh7krlwn.jpeg)

First we should know how to create private sub-networks with Docker engine.
In Docker you can create multiple bridge networks.
Containers connected to the same user-defined bridge network effectively can resolve each other.
Using a user-defined network provides a scoped network in which only containers attached to that network are able to communicate.

Docker engine allows you to create multiple networks.
Example: we want max 254 parallel CI pipelines with max 126 **containers** for each network.

The Docker configuration will be:

* "Subnet": "172.20.X.0/24",  // 172.20.X.1 - 172.20.X.254
* "IPRange": "172.20.X.0/25", // 172.20.X.1 - 172.20.X.126
* "Gateway": "172.20.X.12"

where 1 <= X <= 254

Single network configuration:

```javascript

const availableNetwork = 1;

const networkConfig = {
  "Subnet": `172.20.${availableNetwork}.0/24`,  
  "IPRange": `172.20.${availableNetwork}.0/25`,
  "Gateway": `172.20.${availableNetwork}.12`
}

const networkOption = {
  "Name": networkName,
  "Driver": "bridge",
  "Labels": {
    "name": networkLabel
  },
  "IPAM": {
    "Config": [networkConfig]
  }
}
```

---

Article part 1: [Git hooks and Docker for Continuous integration - part 1](https://dev.to/simone_a/git-hooks-and-docker-for-continuous-integration-1c36)

Check LocalCI: [localci.io](localci.io)
String Builder 
Tags: java, algorithms, programming, beginners
Published: 2021-10-04 14:54:55


## Introduction

String Builder is a separate class just like String, which allows us to modify the values(mutability).
### Need of String Builder
As we know that Strings  are immutable ,because of which
each and every time we need to create an object and that object will have no reference in later cases while running the loop , hence there will be huge memory wastage and due to this we use String Builder.
### Code
```java
public class SB {
    public static void main(String[] args) {
        StringBuilder builder=new StringBuilder();
        for(int i = 0;i<26;i++){
            char ch=(char) ('a'+i);
            builder.append(ch);
        }
        System.out.println(builder.toString());
    }
}

```
### Code Explanation:
* This is a simple code which  demonstrates the use of String Builder class to print all alphabets from a-z, and to show how efficient it is in space and time complexity.
* So inside the main function, we create a StringBuilder using "new" keyword, just like how we use to create for Strings.
* Now inside the ```for``` loop we take ASCII value of a and add it to the iterating variable ```i``` and finally typecast the ASCII value to a character and assign it to ```ch```.
* In next step we add(```append```) each character to the builder and finally print it after converting them to String format by calling toString() Method.


### Code Analysis
1.Now if we analyze the Time Complexity of using **Strings** for the above example:

```[a,ab,abc,abcd,...........,abcdefghijklmnopqrstuvwxy] ```

* Here, Size of each items are 1+2+3+4...+26 (N). This can be represented as N(N+1) /2 .

* After eliminating constants and less dominating terms , we finally obtain O(N^2).

* All of these large Strings will have no reference variable [Wastage of Space].

2.Now if we analyze the Time Complexity of using **String Builder**  for the above example:

* Here instead of creating new object every time , it makes changes in the existing object itself[like how Arrays does], hence saving memory space and time.
 For example:
```["abc"+d -> "abcd"]```

* Due to this the Time Complexity is O(N).
CSS @Media Rules that fits all possible devices.
Tags: css, media, responsive, html
Published: 2021-10-04 14:54:17

In this shot, I will share my experience with responsive design using css @media Rules.

Before you start adding responsiveness into your app, you have to ask yourself
"am I going to design the app in **Mobile-First Approach**  or **Desktop-First Approach**?"

> Mobile-First Approach is designing or developing an app for **Mobile** before designing for desktop web or any other device.

> Desktop-First Approach is designing or developing an app for **Dekstop** before designing for Mobiles or any other device.

Here are the **@media rules** that I personally use to fit all possible devices and screen sizes.
> Sizes from [Chrome device toolbar](https://developer.chrome.com/docs/devtools/device-mode/). 

## Desktop-first

``` css
/* ================ Desktop First ================ */

/* Any other bigger devices */
body {
  background: brown;
}
/* Ultra HD */
@media (max-width: 3840px) {
  body {
    background: red;
  }
}
/* Full HD */
@media (max-width: 2560px) {
  body {
    background: blue;
  }
}
/* Labtop L*/
@media (max-width: 1440px) {
  body {
    background: green;
  }
}
/* Labtop */
@media (max-width: 1024px) {
  body {
    background: cyan;
  }
}
/* Tablet */
@media (max-width: 768px) {
  body {
    background: purple;
  }
}
/* Mobile */
@media (max-width: 425px) {
  body {
    background: yellow;
  }
}
```
With Desktop-first we use `max-width` and the order of the sizes from **larger** (at the top) to **smaller** (at the bottom).

## Mobile-first

```css
/* ================ Mobile First ================ */

/* Any other smaller devices */
body {
  background: brown;
}
/* Mobile */
@media (min-width: 425px) {
  body {
    background: yellow;
  }
}
/* Tablet */
@media (min-width: 768px) {
  body {
    background: purple;
  }
}
/* Labtop */
@media (min-width: 1024px) {
  body {
    background: cyan;
  }
}
/* Labtop L*/
@media (min-width: 1440px) {
  body {
    background: green;
  }
}
/* Full HD */
@media (min-width: 2560px) {
  body {
    background: blue;
  }
}

/* Ultra HD */
@media (min-width: 3840px) {
  body {
    background: red;
  }
}
```
With mobile-first, we use `min-width`, and the order of the sizes from **smaller** (at the top) to **larger** (at the bottom).

<a href="https://www.linkedin.com/in/youssefzidan/" target="_blank">
    <img src="https://img.shields.io/badge/LinkedIn-%230077B5.svg?&style=flat-square&logo=linkedin&logoColor=white" alt="LinkedIn">
event booking app node.js
Tags: help, node
Published: 2021-10-04 14:53:29


![event app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uxhtz90wbzq2qarvq1wu.png)
I want some help for creating booking link. And how to make booking slot unavailable once booked. Kindly help me to approach this problem.Any help is highly appreciated.
Thanks.
Essential AWS Services for Database Administrators to Learn
Tags: dba, aws, career, learning
Published: 2021-10-04 14:49:20

Why AWS?

Cloud is becoming a vital part of Database Administration because it provides various database services & Infrastructure to run Database Ecosystems instantly. AWS (Amazon Web Services) is one of the pioneers in the Cloud according to the Gartner magic quadrant. Knowing more cloud infrastructure technologies is going to give more mileage to your Administrator career. In this article, you will find some of the AWS services which Database Administrators should know as they are basic to run Database opration.
Essential AWS Services List For Database Administrator (DBA)

Network
VPCs
Subnets
Elastic IPs
Internet Gateways
Network ACLs
Route Tables
Security Groups
Private Subnets
Public Subnets
AWS Direct Connect

Virtual Machine 
EC2
AWS Work Space

Storage
EBS
EFS
S3

Database as Services (RDS)
MySQL / MariaDB
PostgreSQL
Oracle
Micrsoft SQL Server
AWS Aurora PostgreSQL/MySQL

Database Managed Services
AWS Dynamo DB
AWS Elasticsearch 
Amazon DocumentDB

Messaging & Event Base Processing 
Apache Kafka (Amazon MSK)

 

Warehousing/ OLAP /Analytics Stagging DB
AWS Redshift

 

Monitoring 
Cloud watch
Amazon Grafana
Amazon Prometheus

 

Email Service
Amazon Simple Notification Service

Security 
IAM
Secrets Manager

Database Task Automation
AWS Batch
AWS Lambda
Cloud Formation

Command-line interface (CLI) to Manage AWS Services
AWSCLI

Migration 
Database Migration Service

Budget 
AWS Cost Explorer
AWS Budgets

Some other Services & Combination worth of Exploring

Read more:
https://thedbadmin.com/essential-aws-services-for-database-administrators-to-learn/
My Coding Bootcamp Journey - 2 weeks to lift-off
Tags: codenewbie, javascript, webdev
Published: 2021-10-04 14:41:26

With 2 weeks until the start of the [bootcamp](https://northcoders.com/our-courses), it's starting to get real. This week I thought I would do a little interview with myself.

## Who are you, Rich?
I am a married man, living with my wife in the East Riding of Yorkshire, UK. Until recently I was a part-time customer delivery driver for Waitrose. I have a degree in Mechanical Engineering (from a couple of decades ago) but did not pursue a career in that area. I first started using the Internet & web about 20 years ago.

## What interests you?
Coding, of course! Also Tech4Good, mapping/geolocation, climate change, protecting democracy. I'm interested in how I can apply my coding/tech skills to these areas.

## What do you know now?
Basic JavaScript, HTML & CSS, a (very) little about making a map on the web.

 ## What have you learned so far on the precourse?
The importance of having a solid grasp of the basics and problem solving.

## What's been hard?
Not over-thinking things. Keeping it simple and then refining - I tend to jump ahead too much.

## What has been fun?
Connecting with my future bootcampers on Slack and actually completing the problems we have been set.

## What are you doing next week?
The PRE-2 section of the precourse which introduces regular expressions 🤯 and functional programming.

I've also signed up to the [OS Map & Hack](https://www.ordnancesurvey.co.uk/business-government/developers/hackathon) but not sure how much time I'll have for that!
⚙️ Create an API in Swift and Deploy It to AWS Lambda
Tags: android, swift, aws
Published: 2021-10-04 14:39:29

#### 📚 Learn how to create and deploy a serverless HTTP API using Swift and AWS Lambda.

### <br>

In almost every real mobile application, we are probably going to need a backend side where our business logic will be handled. In most cases, there will be two different teams, one for mobile and one for the backend side of the project. But, what if we, as iOS developers, could write our own backend in our preferred language? Let's explore in this article how we can achieve this using Swift AWS Lambda Runtime together with AWS Lambda.

## What is AWS Lambda?

In simple terms, it is a service provider by AWS in which we can run our code without the need to configure and manage a server. We just upload our code as a zip file, and AWS automatically does all the configurations needed in the server to make our software available.

One of the main differences between this approach and having a dedicated server, in addition to simpler administration, is that if at some point we need to increase our processing power to scale up our application, AWS Lambda does that automatically for us if we design the application correctly.

You can check out more at this [link](https://aws.amazon.com/lambda/).

## Swift AWS Lambda Runtime

A custom AWS Lambda runtime is basically a library that is in charge of managing and executing the Lambda function's code when it is called. With [Swift AWS Lambda Runtime](https://swift.org/blog/aws-lambda-runtime/), we can now write serverless code in Swift and make it ready for use with AWS Lambda service.

## Creating Our HTTP API

For this tutorial, we will create a simple HTTP API in Swift and expose it through [API Gateway](https://aws.amazon.com/api-gateway/), which is another service available in AWS suite that allows us to expose our Lambda function as HTTP endpoints.

### Prerequisites

- Have XCode installed
- Have an AWS account.
- Have an Auth0 account.
- Have Docker installed in your machine to compile the code that we will upload to AWS.


[Read more...](https://auth0.com/blog/create-an-api-in-swift-and-deploy-it-to-aws-lambda/?utm_source=content_synd&utm_medium=sc&utm_campaign=aws)
Live Coding: Coffee and Code with Chris Bongers on Integrating Typesense search to an Astro static website!
Tags: opensource, devops, website, typesense
Published: 2021-10-04 14:38:16

Aviyel’s flagship **Coding & Coffee** ☕️ is back and this time, we have onboarded Chris Bongers, a full-stack developer. Chris has been passionate about dev work and has been blogging plus guiding young engineers ever since.

Aviyel and Chris are teaming up to bring a live session on Typesense search to an Astro static website.

###What’s in it for you?
- 
Hands-on experience with Typesense, an open-source search engine and viable alternative to ElasticSearch.
- 
Typesense’s configuration guide, quick start with Typesense’s dashboard and UI/UX for both beginners and advanced users.
- 
Bombard speakers with your questions to dive deep into open source technology (and maybe start a full-time career).
- 
An evening of knowledge, fun, and coding with a bunch of expert speakers

This is your chance to finally get started with open source. Confirm your presence by registering today.

Mark your Calendar: 📆  **8th October, Friday**

Time: **9.00AM PST | 12.00PM EST**

Join here 📌
https://bit.ly/2ZQgMKx

Impressed? Check out the rest of our [events](https://bit.ly/3l9hM4J)!

Let’s code together!

Team Aviyel
Get a head start with the Dream11 clone app, which offers financial benefits to your company.

Tags: beginners, challenge
Published: 2021-10-04 14:02:37

There is nothing nowadays that does not have a revenue model. Every stream has enhanced and huge revenue sources for both users and administrators, including Fantasy gaming through applications like Dream11. The users of these applications form virtual teams and participate in virtual games in the apps. Each tournament's winner receives additional points and incentives. Similarly, the admin for referral users, subscriptions, advertisements, and other services has a variety of reasons to earn consistent money. Developing your Dream11 clone from INORU has several advantages, including improved commercial potential.
Visit Us: https://www.inoru.com/dream11-clone
Windows Server Migration is just mad
Published: 2021-10-04 14:00:30

PRE: SHRINK ALL DRIVES 
1) Take a bare Metal Back UP --> Shrinking drives too much wont allow for making back up
2) Take back ups of each drive separatly
3) Put images on a USB storage that is defintatly going to be recognized by windows
4) Make a windows server Rescue USB
5) Use CloneZilla Or Gparted or... clone the disks
6) pop in the system
7) if failed put in the Bootable cd
8) try to restore the image 



sudo add-apt-repository ppa:gezakovacs/ppa
sudo apt update
sudo apt install unetbootin


https://www.ubackup.com/

https://clonezilla.org/


alt:
https://support.thinkcritical.com/kb/articles/create-bootable-windows-7-or-windows-2008-r2-usb-flash-drive