teleren/devto huggingface dataset:
Happy to Newb
Published: 2020-09-08 20:08:05

The first family you played in The Sims had the last name Newbie. It took me awhile to realize that meant they were a practice family. I took their life so seriously. The one bedroom apartment Bob and Linda (?) shared was the first time I had ever played a PC game for hours on end. That lead me to wondering how computers worked and I even made mods for some websites full of Sims' furniture.

I never thought back then that I would learn computer graphics so now that I am making the command queues myself, I am proud to be a newbie.
Microsoft Ignite Now Open for Registration!
Tags: microsoft, microsoftignite, azure, cloud
Published: 2020-09-08 20:03:12

Did you love my post? <a href="https://www.buymeacoffee.com/willydavidjr"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=willydavidjr&button_colour=f25a71&font_colour=000000&font_family=Lato&outline_colour=000000&coffee_colour=FFDD00"></a>

Good day devs!

Join us at Microsoft Ignite with 48 hours of continuous content and live Q&A – all free!

## **Microsoft Ignite**
Microsoft Ignite is coming directly to you this year. Over 48 hours, you will be immersed in topics with Microsoft leaders, hear from your tech heroes in the digital breakout sessions with live Q&A, technical workshops, 1:1 consultations, and so much more.

Learn new ways to use the cloud, dive into the new technologies, explore innovative development techniques, discover new ways to secure and manage your infrastructure, and more.

Connect with experts who build and support the Microsoft technologies you’re using and evaluating. Join discussions with others in the community to talk thru real-world experiences and shared interests.

Explore the latest in cloud, productivity, collaboration, security,  and application development.

Make sure you are registered to gain full access to all sessions, the Connection Zone and Learning Zone activities where you will have the opportunity to connect with peers and experts.  Registration is easy and free.  Join the conversation on Microsoft Ignite social to keep up-to-date on all event details.

## **Registration**
For full details of schedule and topics, register [here.](https://register.ignite.microsoft.com)
AWS KMS Envelope Encryption
Tags: aws, microservices, architecture, encryption
Published: 2020-09-08 19:21:33

## Background and Introduction

Traditionally applications used to store security keys used for data encryption/decryption in application config files. Drawback of storing it in config files is risk involved if not stored and managed properly.

AWS Key Management Service (KMS) is fully managed service offering which AWS itself is using to encrypt/decrypt data at rest for different AWS services like S3, EBS, RDS, etc..

AWS KMS is highly available key management service to access, store, audit secret keys called CMKs (Customer Master Keys).

There are two types of CMKs (Customer Master Keys).

**AWS Managed CMKs**

 - AWS creates keys for each of its services which provides data encryption. These keys are managed by AWS and it's default CMK used to encrypt/decrypt data for particular service.
 - Customer does not have much control on it as it can only be viewed in KMS.

**Customer Managed CMKs**

 - Customer creates keys in KMS and has full control over management of keys like Audit log, Key rotation, Key deletion, etc...
 - Customer can also upload their own keys to KMS.

## How Envelope Encryption works ?
 
AWS KMS key called CMK (Customer Master Key) is used to encrypt/decrypt data but there is limitation of it as it can encrypt data up to 4KB only so the question pops up then how it's using it for encryption of big datasets in S3, EBS, etc...

You got it right - Envelope Encryption.

> **Envelope encryption** is the practice of encrypting plaintext data with a data key, and then encrypting the data key under another key.

Let's see how envelope encryption works but before encrypting any data customer needs to create one or more CMKs (Customer Master Keys) in AWS KMS.

![enter image description here](https://miro.medium.com/max/1065/1*lVswCGRqvEKB4FYt3n_GWQ.jpeg)

**Encryption**

 - *API request is sent to KMS to generate Data key using CMK.*
 - *KMS returns response with Plain Data key and Encrypted Data key (using CMK).*
 - *Data is encrypted using Plain Data key.*
 - *Plain Data key is removed from memory.*
 - *Encrypted Data and Encrypted Data Key is packaged together as envelope and stored.*

**Decryption**

 - *Encrypted Data key is extracted from envelope.*
 - *API request is sent to KMS using Encrypted Data key which has information about CMK to be used in KMS for decryption*.
 - *KMS returns response with Plain Data Key.*
 - *Encrypted Data is decrypted using Plain Data key.*
 - *Plain Data Key is removed from memory.*

## Summary

I tried to explain here what is Envelope Encryption in AWS KMS and how can we encrypt/decrypt large amount of data using envelope encryption method.

I am looking forward to put hands-on exercise on this in next [article](https://dev.to/chiragdm/envelope-encryption-using-aws-cli-3ejd).

Thanks for joining me.

## References

https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping
Html Input onclick select text
Published: 2020-09-08 19:40:23

When users click on an input with text already there, this is the easiest way to pre-select the text for them.

```html
 <input  
  type="text"
  onclick="this.select()" 
 />
```

Not too difficult except when trying to remember Angular conventions like (click), [(click)],(onClick) etc.  No Angular needed...
UI Test Automation Framework proposal with SeleniumBase!
Tags: webtesting, seleniumbase, testing
Published: 2020-09-08 17:30:12

Considering to use [Seleniumbase.io](https://seleniumbase.io/) for my next web automation framework I decided to come up with an initial architecture diagram that illustrates the integration of the framework with the rest of components. Using `Python` `Webdriver (SeleniumBase)` and `pyTest`.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4ptrhdl75k7zhwav4grz.jpg)


In this case we will be using the [PageObjectModel](https://martinfowler.com/bliki/PageObject.html) which is commonly used as a first approach for web testing frameworks:


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


<br>
So let's elaborate a little bit further on each of the specific components: 

### SeleniumBase
Will serve as our default WebDriver wrapper, which will be in charge of most of the UI interactions, assertions and eventually reporting and logging. 

### Utilities/WebDriverWrapper
Will be used to wrap those custom UI interactions that are not supported by SeleniumBase, but still will be used across many of the pages and test cases.

### DataWrapper
Will centralize the test generation and serving process for all the test cases and keywords (common flows), so that we ensure that no hardcoded data will be generated at different stages of the test process.
The data could be anywhere from api services, json files or random generated data.

### Keywords (common flows)
Will contain user flows or actions that need interaction with at least 2 pages objects and that is commonly used across different tests. This will help us reduce code duplicity and eventually build a repository of keywords that could function as blocks to easy build new test cases.

### Base Page and Page Objects
`BasePage` will initially just be added as a placeholder in case we require it. Notice that not all the pages inherit from it, as we want to avoid the jungle inheritance problem.

The page objects will follow the pattern of providing locators and user actions that are available for specific pages. 
_Note: We could eventually split the locators under their our classes, but initially that would be an overhead._

### Base Test Case and Test Cases
Finally our test cases layer. At this point is where we are going to define our test cases structure based on actions or elements delivered by each of the PageObjects. Also at this layer only is where test assertions are executed.


## Final thoughts
Of course there is a lot of room for changes with this approach and we will be seeking for feedback on improvements. But overall based on lessons learned and trying to follow a single responsibility principle we think this initial architecture will let us:

* Start writing valuable test cases soon.
* Avoid over engineering issues.
* Heavily rely on SeleniumBase to drive most of the element interactions.
* Be mindful about classes responsibilities and code re-usabilities problems.


Anything else we are missing.
Modern JS, when to use map or for?
Tags: discuss, node, javascript
Published: 2020-09-08 19:26:07

---
title: Modern JS, when to use map or for?
published: true
tags: discuss, node, javascript
---

My main languages are C and Python. I'm not well versed in JS, and I want to learn clean code development.

Recently, I made a helper function to run some .sql files in a folder. I will put a reduced example here:

```js
const runFiles = async (files) => {
  for (const file of files){
    const query = fs.readFileSync(file, "utf-8");
    await client.query(query);
  }
}
```

Coming from imperative, and usually single-threaded languages, this seems like a natural approach to me. For each file, run query, wait, repeat.

But, I've got a suggestion that the code should be like this:
```js
const runFiles = async (files) => {
 Promise.all(files.map(async (file) => {
    const query = fs.readFileSync(file, "utf-8");
    await client.query(query);
 });
}
```

So I want to ask, to some fellow JS/Node developers here, comparing both versions:
* Is the second one clearer for you over the first one?
* Should I use a functional approach more often?
* Could this be faster? Does it runs in parallel?

Also, can you recommend me a book or resource to learn how to develop clean and modern js?
The DDD microservice with GO
Tags: microservices, go, ddd
Published: 2020-09-08 19:06:59

---
title: The DDD microservice with GO
published: true
description: A microservice base project template with DDD to start microservices with GO
tags: microservices, golang, DDD
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/nkjoiy4rbdhvnea8y9dr.png
---

# Intro
Hi everybody, these last days I decided to star a base project with the basic folder structure and libraries to start easily a new microservice with GOLANG. Right now there is a lot of continuous change in the GOLANG environment so this project uses a specific tech stack but can be adapted to any tech stack due to the architecture of DDD which is an architecture that I think helps a lot to make more refactorable any project.

# Tech Stack
Basically knowing that the arch gonna be Doman Driven Design I find the best suitable techs to apply this patterns to the project so at the end if you know about the current frameworks on the internet you should know (GOKIT)[https://github.com/go-kit/kit] as its definition is not a framework is a bunch of tools to develop microservices it supports a lot of advanced features like services discovering and circuit breakers. SO this is the main reason for me to choose this tech to develop this base project.
For the data persistence, I go for a mongo to keep a simple and versatile data model there is an official mongo connector for GOLANG so it is simple to make the decision of which library use.

![Tech stack](https://dev-to-uploads.s3.amazonaws.com/i/9o4uck63ujn4w351gqxt.png)

# Architecture
The chosen architecture will be Doman Driven Desing to keep the project well organized and very scalable.

![DDD architecture diagram](https://dev-to-uploads.s3.amazonaws.com/i/rnpl06p9zfov7zd19td0.png)

# Project
So there is the project it could be found on my GitHub page on clicking this link [https://github.com/FabianBG/gokit-base].

![Project structure](https://dev-to-uploads.s3.amazonaws.com/i/6wsmha7yx8bwl0fmxqs2.png)

I hope it helps you to get into Golang and any comments about how to improve the code it is welcome.
PHPUNIT:Demystifying the double test (Dummy,Stub,Mock)
Tags: php, beginners, testing, phpunit
Published: 2020-09-08 19:04:01

# Description
This article will help you differentiate between a Dummy, a Stub and a Mock.

# Test Double
In unit testing often, we often get to test classes.
Classes without dependencies are easy to test, but with dependencies it becomes much more complicated.
We can test a class with all its dependencies but it can be very complicated. The best solution is to isolate it from all its dependencies.
This is when the liners come in.
Take for example an actor often during filming the actor needs an understudy to perform stunts that one asks of him, it is exactly the same principle for the doublings in programming.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/klw90rilkrpy0pe26d6i.jpg)
The problem with liners is that you usually don't know how to identify them.
Do we use a **mock**, a **stub** or a **dummy**.

# But what is the difference?

To explain the difference between a **mock**, a **stub** or a **dummy**, we will first see their definitions.


## What is a **Dummy**?

A **dummy** is an empty class that we can use when we need to instantiate an object dependent on it.
It aims to make believe that a class exists to the one that we want to test.
It is usually passed as a parameter but never called.
If called, its functions will always return null.

```php
  $client = $this->getMock('GuzzleHttp\Client');
```

## What is a **Stub**?

A **Stub** is a **dummy** that will be customizable.
It will correspond to what we expect.
He can redefine his methods and tell him what to return.

 ```php
  $stub = $this->createMock(Stubclass::class)
              ->method('someStubMethod')
              ->willReturn('foo');

  $someClass->someStubMethod($stub);
```

## What is a **Mock**?

A **mock** is a duplicate that checks expectations.
We can make it check that the method is called **x** times like **never**.
If the simulation is not done as many times as expected the test will fail.
Unlike the **Stub** a **Mock** can **throw exceptions** if it does not receive the correct calls.
The purpose of the mock is not to be interested in the return value but rather to be interested in the method which is called and to know **how many times** and with what **arguments**.


> The execution will be launched once

```php
  $mock = $this->createMock(Mockclass::class)
      // Once() one time
            ->expects($this->once())
            ->methods('someMockMethod')
            ->willReturn('foo');

  $someClass->someMethod($mock);
```

> The execution will never be launched

```php
  $mock = $this->createMock(Mockclass::class)
            ->expects($this->never())
            ->methods('someMockMethod')
            ->willReturn('foo');

  $someClass->someMethod($mock);
```

# Conclusion

Now you will no longer confuse **Mock**, **Stub** and **Dummy**.
**Now you will see more clearly !!**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/78dm2mdbp2ww6wuhzzk5.gif)
Reverse Proxy with PHP 
Tags: php, devops, linux, beginners
Published: 2020-09-08 18:57:52

What is reverse proxy?

Suppose you have one VPS SERVER, One IP and some domains. You have different docker / lxc  containers . Each container contains some website. 
Naturally, each container will have its own internal IP. You don't want to purchase an IP for each domain. Instead, you want to use your public IP as shared ip between domains. Also, only one port 80 is available at host so all containers will need to listen it.

Reverse proxy is resolve a request URL to another server machine (or same server with different port) as a remote location. It get the content from the remote location and then return back to the client who request the URL.  The content or the header information can be modified before returning to the client, and the raw content may be stored as cache files or inside a database.  A Reverse proxy can be a building block for other applications, such as 
-Acting as a load balancing server
-Acting as a fail-over standby server
-Cope with a web server
acting as a cache server
acting as a search engine friendly front end
acting as a content filter
-Portal Front end which served by different type of web-services from different server.

**Reverse Proxy will help you. 
Standard solution is HAPROXY and nginx. Please search.**

In this post, I am sharing two projects to achieve the same:

1. SPIKE: ( Reverse Proxy)
Spike is a fast reverse proxy built on top of ReactPHP that helps to expose your local services to the internet

{% github slince/spike %}

2. Domain Fwd & Reverse Proxy:

https://sites.google.com/site/php5class/php-reverse-proxy/demonstraton-of-php-reverse-proxy


######***IMP REQUEST:***

###### You are most welcome to join my team 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3qhbvg5fsrh3nt7anh36.png)

[ Click here for joining my team ]
(https://forms.gle/pSCALuEWHus3pg9F6).

###### *Also you are most welcome to join OPEN SOURCE INTELLIGENT SYSTEM (OSINT) if you can help in open source project regarding safeguarding humans from various diseases like CORONA outbreak*
######https://github.com/Manishfoodtechs/OSINTHRH/wiki

Contact email: Manishfoodtechs@gmail.com. 

If you have any problem, our team is also engaged in professional consultancy and delivery.

![](https://media2.giphy.com/media/oNrPzIy3OhHm7zrvA3/source.gif)

Imagecredit: pixabay
Facebook Coding Interview: Array Partition I (Leetcode)
Tags: beginners, computerscience, codenewbie, career
Published: 2020-09-08 18:57:43

## Why should you practice coding problems?

Want a job at companies like Google, Facebook, Amazon, and more? Software engineering interviews mainly consist of data structures and algorithm problems. 

You need to do a lot of these problems in order to succeed in these interviews. Below I’ll be going through an approach to a popular problem: [Array Partition I](https://leetcode.com/problems/array-partition-i/).

Please consider subscribing on YouTube by clicking [here](https://link.mattupham.com/youtube/channel/mattupham) if you find this information useful!

## Problem Statement & Approaach

The problem statement is: 
“Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes the sum of min(ai, bi) for all i from 1 to n as large as possible.”

This basically says group an array of integers into pairs, take the minimum of those pairs, add them up. You should produce the largest sum possible, with these constraints. Below I have a full overview of the problem, with a solution.

If you want a better sense visually of how this is done, check out my in-depth explanation on YouTube below. 

{% youtube nxdc6baaioE %}
[LeetCode: Array Partition I (Overview and Solution)](https://link.mattupham.com/youtube/array_partition_i)

We want to make as many large numbers the minimums, and the general approach is to first sort the array. Once sorted, you’ll notice that we have forced as many large numbers to be the smallest of each pair. 

Since we first need to sort the array, then loop through again, our time complexity is O(n log n) time (sorting is O(n log n), looping is O(n), so the sorting overpowers the second loop. Our space complexity is O(1), since we’re sorting in place, and creating a final sum in the end.

## Conclusion

If you found this video useful, please consider subscribing to my [YouTube Channel](https://link.mattupham.com/youtube/channel/mattupham)! I talk about software & technology, overviews of coding problems, and landing jobs in tech!

Also, make sure to check out our [Discord](https://link.mattupham.com/discord) community! 4700+ members, mentorship, discussion, and resources for learning to code!

On TikTok, I mainly do quick coding, tech and productivity tips. Check them out here: [TikTok](https://link.mattupham.com/tiktok)

Here are the social platforms where we can connect:
[YouTube](https://link.mattupham.com/youtube/channel/mattupham)
[Discord](https://link.mattupham.com/discord)
[TikTok](https://link.mattupham.com/tiktok)
[Twitter](https://link.mattupham.com/twitter)
[LinkedIn](https://link.mattupham.com/linkedin/mattupham)

Thanks for reading, and feel free to DM any questions!
reset forgotten password of macOS Mojave
Published: 2020-09-08 18:28:47

forgetting the password is usual. we all forget passwords in our daily life. Whether that is the password of our phone, desktop, or any other device. Similarly, today most of the things have become private. And everyone sets a password on their device. Therefore, we always forget passwords.


You same case you could have confronted with your desktop especially your mac machines. However, with time the resetting of forgotten passwords has become easy. You can easily reset the forgotten password of your device. However, you need to follow some steps.


The steps that I am going to explain will not work with all devices. But with the macOS devices. I have written an extensive article on how to reset the forgotten passwords of macOS Mojave. You can follow the steps instructed in the article and can easily reset the forgotten password. Therefore, IF you are curious on how to do that, So, please visit the article, that I found legit. This article really helped to reset the forgotten password of my macOS Mojave device.


https://techvatan.com/reset-forgotten-password-of-macos-mojave-10-14/





Moreover, please also visit the following article for more knowledgeable content.




https://techvatan.com/create-bootable-usb-for-macos-mojave-on-windows/
CKAD Practice Questions
Tags: ckad, cka, kubernetes, certification
Published: 2020-09-08 18:18:39

![CKAD Practice Challenge](https://www.liptanbiswas.com/tuts/ckad-practice-challenges/ckad-practice-questions.png)

Practice Questions for CNCF Certified Kubernetes Application Developer Exam.

---

Access the practice test environment on Katacoda:
https://www.katacoda.com/liptanbiswas/courses/ckad-practice-challenges.


Or, directly using these links, no login required:

- [Core Concepts - 13%](https://liptanbiswas.com/tuts/ckad-practice-challenges/core-concepts.html)
- [Configuration - 18%](https://liptanbiswas.com/tuts/ckad-practice-challenges/configuration.html)
- [Multi-Container Pods - 10%](https://liptanbiswas.com/tuts/ckad-practice-challenges/multi-container-pods.html)
- [Observability - 18%](https://liptanbiswas.com/tuts/ckad-practice-challenges/observability.html)
- [Pod Design - 20%](https://liptanbiswas.com/tuts/ckad-practice-challenges/pod-design.html)
- [Services & Networking - 13%](https://liptanbiswas.com/tuts/ckad-practice-challenges/service-network.html)
- [State Persistence - 8%](https://liptanbiswas.com/tuts/ckad-practice-challenges/state-persistence.html)

---

**UPDATE**: 08/03/2021: Upgraded kubernetes version to 1.20.

03/02/2021: Some of you may be facing huge latency in the practice environment. Katacoda is limiting resources allocated to free scenarios due to huge popularity of these scenarios. In last 6 months, people spent 9429 hours on these scenarios. That's around 393 days.

![Engagement metrics](https://dev-to-uploads.s3.amazonaws.com/i/rbztl3mrcq1ao66e3m67.png)


---


### Instructions
- Please use a desktop or laptop. These do not work in mobile devices.
- This practice environment runs on Kubernetes 1.20, current version of exam.
- This is NOT a replica of actual exam and should be used for practice only.
- The questions are NOT same as actual exam.
- Successful completion of tasks can verified at the last step. You can also run `check` command anytime to verify your work.
- You can view solutions by clicking Show solution button, however you are encouraged to use Kubernetes documentation to find answers instead.
- Practice environment will be expired in 1 hour. Refresh to get new environment.

[Connect with me on Linkedin](https://www.linkedin.com/in/liptanbiswas/)