teleren/devto huggingface dataset:
Multi-Tier Architecture on AWS EKS using Terraform
Tags: aws, kubernetes, wordpress, mysql
Published: 2021-05-29 04:16:58

<h3>About AWS EKS:</h3>
Amazon Elastic Kubernetes Service (Amazon EKS) gives you the flexibility to start, run, and scale Kubernetes applications in the AWS cloud or on-premises. Amazon EKS helps you provide highly-available and secure clusters and automates key tasks such as patching, node provisioning, and updates. Customers such as Intel, Snap, Intuit, GoDaddy, and Autodesk trust EKS to run their most sensitive and mission critical applications.
[source: aws.amazon.com]

<h4><b>Create an IAM user and run aws configure<b></h4>
https://www.youtube.com/watch?v=wRzzBb18qUw
https://www.youtube.com/watch?v=EAqK404sOI4

<h3>Creating an AWS EKS Cluster using Terraform</h3>
TF Script - https://github.com/RajitPaul11/terraform_aws/blob/main/AWS_EKS_RDS/main.tf
<ol>
<li>terraform init</li>
<li>terraform validate</li>
<li>terraform plan</li>
<li>terraform apply --auto-approve</li>
</ol>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3aioc669vyrem5hqz7g3.png)

<h3>Creating NodeGroup IAM Role</h3>
TF Script - https://github.com/RajitPaul11/terraform_aws/blob/main/AWS_EKS_RDS/ng_iam_role.tf
<ol>
<li>terraform validate</li>
<li>terraform plan</li>
<li>terraform apply --auto-approve</li>
</ol>

<h3>Creating Nodegroup in EKS Cluster</h3>
TF Script -
https://github.com/RajitPaul11/terraform_aws/blob/main/AWS_EKS_RDS/eks_ng.tf
<ol>
<li>terraform validate</li>
<li>terraform plan</li>
<li>terraform apply --auto-approve</li>
</ol>

<h3>Creating an RDS DB Instance</h3>
TF Script - 
https://github.com/RajitPaul11/terraform_aws/blob/main/AWS_EKS_RDS/rds.tf
<ol>
<li>terraform validate</li>
<li>terraform plan</li>
<li>terraform apply --auto-approve</li>
</ol>

<h3>Now we need to update kubeconfig and connect locally installed eksctl to AWS EKS Cluster</h3>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oy5mdc5lnyzhkdg4zox2.png)
<b><i><mark>aws eks update-kubeconfig --name EKS-TF --region ap-south-1</mark></i></b>
<b><i><mark>eksctl utils write-kubeconfig --cluster=EKS-TF</mark></b></i>

<h3>Setting up the Wordpress-Deployment.yaml with necessary MySQL attributes</h3>
https://github.com/RajitPaul11/terraform_aws/blob/main/AWS_EKS_RDS/wordpress-deployment.yaml

<h3>Deploying Wordpress on the EKS Cluster</h3>
TF Script - 
https://github.com/RajitPaul11/terraform_aws/blob/main/AWS_EKS_RDS/null_res_wp.tf
<ol>
<li>terraform init</li>
<li>terraform validate</li>
<li>terraform plan</li>
<li>terraform apply --auto-approve</li>
</ol>

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

Github - https://github.com/RajitPaul11/terraform_aws/tree/main/AWS_EKS_RDS

<h3>Thanks for reading, see you on the next blog!</h3>
Choose your first language
Published: 2021-05-29 04:00:35

Throughout many years, one of the biggest question in the tech industry is "What is the best programming language to start?". While this is a very opinionated topic, in my opinion, I heavily believe that the best one is the one that suits you the most. 

I know, this sounds really stupid, but for real, just have a look at some popular languages out there, see some programs written in them, and just blindly pick the one you see appealing. This is actually a good way to choose your first language, as the one you see interesting at first sight is probably the one that helps you stick with programming for a long run. 

Many people say that Python is the best starter language because it's easy, while others say that C, C++ and Java are the best because they force you to be strict with your code. To me, these words are straight up BS, since it depends on individual's opinion. Some might say Javascript or Ruby is easier than Python, or some beginners might give up due to the difficulties with C or Java. So the best one is probably the one that you think that's good. Besides, if the language you choose is utterly useless, just switch to another language, now that you have the core understanding of the previous language, you can learn any other ones.

In conclusion, just pick the language that you see interesting, don't let some old man scares you :v

Here are the top most popular languages with many great options for you: https://pypl.github.io/PYPL.html
What is an Api ?
Tags: api, webdev
Published: 2021-05-29 03:10:58

#Application Programming Interface

Think of it as a set of tools designed for software developers. API makes your life easier by giving you access to data and providing you with an abstraction of the implementation.
##Interface
-> Interface, through which the user interacts. The developer knows what' s happening behind the scenes.
-> When the user clicks, it does something! APIs works actually as interfaces that are abstracting details for him.
##Flashlight API
-> Let’s say when the user clicks, it throws the flashlight. So, it' s worth noting the code probably also uses the Flashlight API
-> This API abstracts away the details of how to send flashlight to the user when he interacts with the button
-> You just need to call on/off method of a Flashlight API to make it work!
##UI V/S API
-> User Interface (UI) is made for the user interaction.
-> Application Programming Interface (API) is made for the programmers to use. They save you   from needing to create everything yourself.
##SOAP APIs V/S REST APIs
-> Soap/Web based API calls are sent from web apps using XML between systems through HTTP
-> Rest is a style of architecture that provides standards on the web between systems
-> Well, SOAP stands for Service Object Access Protocol and REST stands for Representational State Transfer
-> Soap/Web API can only work with XML but Rest API can work with plain text, HTML, XML, JSON, etc.
HOW TO: Multiple .xlsx files to one .csv using R/RStudio
Tags: tutorial, datascience
Published: 2021-05-29 02:50:44

This how-to will help you to take data from multiple MS Excel files into one big CSV file using packages and a simple program in R.

* First you must have installed R (RStudio is optional).
* Once installed, run R and open a new console.
* In the console, write the following to install and load the `readxl` package:

```R
> install.package("readxl") # install the package
> library(readxl) # load the package
```

* Make sure to set the working directory to the folder where your Excel files are allocated. Use `setwd()` function in the console to do this:
```R
setwd("C:/your_path_goes_here/xlsx_folder")
```
* To check if the previous step is correct, run `getwd()` in the console.

* Now run the following subroutine:
```R
# list of the names of the excel files in the working directoy
lst = list.files()
# create new data frame
df = data.frame()
# iterate over the names in the lists
for(table in lst){
  dataFromExcel <- read_excel(table)
  df <- rbind(df,dataFromExcel)
} 
write.csv(df, "data.csv")
```
* This program will fetch the `.xlsx` files by their names, read their data and write it over `dataFromExcel` variable (you can read the [read_excel() documentation](https://www.rdocumentation.org/packages/readxl/versions/0.1.1/topics/read_excel) to give specific information on how to read the file). Then the `rbind()` function will merge the rows from both data frames. This will loop over all the Excel files in the folder (Note: try to have ONLY Excel files in your folder).

* Finally, the `write.csv()` function will create a .csv file from the data we just uploaded to our main data frame `df` with the name “data.csv” in the current working directory.

Don't forget to give a ❤️ if you found this useful :)
5/28 TIL: Docker Compose,  Volumes, cURL
Tags: todayilearned
Published: 2021-05-29 02:43:01

Docker-compose

```

version: '3'
  services:
    server:
      build: .
      volumes:
        - .:/app
      ports:
        - 9090:9090
      command: ['wait-for-it.sh', 'db:3306', '--', 'air']
      depends_on:
        - db
    db:
      image: mysql
      restart: always
      environment:
        MYSQL_USER: admin
        MYSQL_PASSWORD: password
        MYSQL_ROOT_PASSWORD: password
        MYSQL_DATABASE: sampleDb
      ports:
        - '3306:3306'
      volumes:
        - mysql_db:/var/lib/mysql
      command:
        [
          'mysqld',
          '--character-set-server=utf8mb4',
          '--collation-server=utf8mb4_unicode_ci',
        ]
  volumes:
    mysql_db:
```

- Two containers: server & db
- server
    - builds the Dockerfile in the current path
    - runs on port 9090 on both the host and within the container
    - executes 'wait-for-it.sh' to wait on the availability of port 3306 before running 'air'--using wait-for-it.sh is just an example and this shell script has to be installed as part of the Dockerfile[https://github.com/vishnubob/wait-for-it](https://github.com/vishnubob/wait-for-it)
    - depends on db container
- db
    - runs on mysql image
    - we have a 'named volume' called mysql_db at the last line of this docker-compose.yml file and we have that mounted to 'var/lib/mysql' directory in the db container's virtual file systems (watch 3:40 here for details [https://www.youtube.com/watch?v=p2PH_YPCsis&ab_channel=TechWorldwithNanaTechWorldwithNana](https://www.youtube.com/watch?v=p2PH_YPCsis&ab_channel=TechWorldwithNanaTechWorldwithNana))

cURL & its flags

- curl is a tool to transfer data from or to a server, using one of the supported protocols (FTP, HTTP, SFTP, and many more)
- Example:

```

RUN curl -fLo [install.sh](http://install.sh/) [https://raw.githubusercontent.com/cosmtrek/air/master/install.sh](https://raw.githubusercontent.com/cosmtrek/air/master/install.sh)

```

- -f allows the HTTP to fail silently on server errors
- -L will make curl redo the request on the new place if the server reports that the requested page has moved to a different location
- -o writes the output to the specified file
- -s is silent mode
- -S is used with -s and it makes curl show an error message if it fails. ex) -sSfL
(Humor) The Top 10 Web Dev Debates
Tags: humor, twitter, discuss, webdev
Published: 2021-05-29 02:34:51

1. let vs. const
2. Is HTML a programming language?
3. Is React a framework or a library?
4. What’s the best frontend framework?
5. Code comments vs. self-explanatory code
6. Array iteration methods
7. What’s the best code bundler?
8. Semicolons vs No Semicolons
9. let vs const again
10. Should CSS be mixed with HTML?
11. Is _insert_technology_ declining or gaining popularity?

What are some others? (No arguing here!)
PIVOT-UNPIVOT
Tags: sql, database
Published: 2021-05-01 12:21:02

##What is PIVOT?
You can rotate your SQL table using pivot function where you transform your row values into columns. Here you can turn unique values from one column into multiple columns.

##What is UNPIVOT?
While PIVOT turns values from one column into multiple columns, UNPIVOT turns multiple column into row values of single column.

##Use Cases
These two functions of SQL is generally used to reorganize data, so that, the data can be viewed more efficiently and is more understandable than before.

##Syntax:
####PIVOT
```sql
SELECT (Column1, Column2, ...) 
FROM (TableName) 
PIVOT
 ( 
   AggregateFunction(ColumnToBeAggregated)
   FOR PivotColumn 
   IN (PivotColumnValues1, PivotColumnValues2, ...)
 ) AS (Alias)
```
####UNPIVOT
```sql
SELECT (Column1, Column2, ...) 
FROM (TableName) 
UNPIVOT
 ( 
   AggregateFunction(ColumnToBeAggregated)
   FOR PivotColumn 
   IN (PivotColumnValues1, PivotColumnValues2, ...)
 ) AS (Alias)
```

##Example:
So, a table that looks like this:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cl49twnd8nmwsot68mh2.png)
 
Can be converted into something like this:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50u81prljk6c3xhqn9nj.png) 
 
With this piece of code:
```sql
SELECT BRAND, TABLET, MOBILE, OS 
FROM(
    SELECT BRAND, PRODUCT, PRICE FROM TECHPRODUCTS
)
PIVOT (
    SUM(PRICE)
    FOR (product)
    IN ('TABLET' TABLET, 'MOBILE' MOBILE, 'OS' OS)
) ORDER BY BRAND;
```
####If you want to learn more about PIVOT and UNPIVOT please refer:
https://blogs.oracle.com/sql/how-to-convert-rows-to-columns-and-back-again-with-sql-aka-pivot-and-unpivot
Truncate a string
Tags: javascript, tutorial, beginners
Published: 2021-05-29 02:23:33

* Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a `...` ending.
```
function truncateString(str, num) {
  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 8);
```
* First let's see how slice works:
```
// slice() method should work for this as well; whats slice?
let name = "randy";
console.log(name.slice(0, 3)); // will display ran
```
* Answer:
```
function truncateString(str, num) {
  if (str.length > num) {
    return str.slice(0, num) + "...";
  }
  return str;
}

console.log(truncateString("A-tisket a-tasket A green and yellow basket", 8)); // will display "A-tisket..."
// console.log("A-tisket a-tasket A green and yellow basket".length); will display 43
```
What is your Webdev workflow as a freelancer?
Tags: webdev, html, css, help
Published: 2021-05-29 02:18:42

So not too long ago, I built a website for my dad's company and although both parties were happy with the result, I personally felt the need to improve on how I approach future projects to increase efficiency and maximize productivity.

I would like to know, as a freelancer, How do you plan your web development projects for clients. What is the workflow? Do you sit with the client and go through each section of the webpage ,discussing what color should that be or what size should that text be? Things like that.

Really looking forward to your responses so that I can tackle the next project confidently and efficiently.
Exploring the Glassmorphism Hype
Tags: showdev, css, webdev
Published: 2021-05-29 02:07:23

## Just hover the buttons!

> I have to be honest: most hypes come and go. The frosted glass look that currently seems to be the "must have" will fade as well. Additionally, whether it is the accessibility and the contrast-issues or the --- never mind, I just hovered the button and I love it! 

I imagine I am not the only one with that experience. I decided to create a little CSS template so you can [hover the buttons](https://gaudiamus-css.github.io/glass/) as well. Joke aside, the template is built on [Gaudiamus CSS](https://github.com/gaudiamus-css/gaudiamus-css.github.io) and therefore allows very easy adoption to whatever corporate identity you need to adhere to. If you like it, don't forget to leave me a star on GitHub:

{% github gaudiamus-css/glass %}
W88 - Link đăng nhập W88 mới nhất 
Published: 2021-05-29 01:58:31

Website: 	
https://ghienchoibai.com/w88/
https://ghienchoibai.com/w88club/
https://ghienchoibai.com/w88yes/
https://ghienchoibai.com/w88banh/
https://ghienchoibai.com/w88mp/
Introduction to Chore-cli, easy to generate development infrastructure for typescript project.
Tags: typescript, infrastructure, boilerplate
Published: 2021-05-29 01:50:01

I made a library to generate development infrastructure for typescript project.

chore-cli is the super assistant for building a typescript library. It can generate development infrastructure for projects or libraries, such as prettier, eslint, husky etc, or even Github Actions Config files. It can save a lot of time every time you create new stuff.

As we know, These tools like eslint, prettier can make the codebase better. But it takes us a lot of time to configure them. If you don't want your enthusiasm for writing code to be consumed by these configurations, and if you don't like doing these annoying "chores" frequently, try chore-cli.

It's easy to use：
```sh
npx chore-cli <path-to-project>
```

![Chore-cli](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycgvdhduwaoyo945v2pl.gif)

Take a look at the [README.md](https://github.com/iwfan/chore-cli) for examples and further documentation, and let me know if you find any bugs, or you have any idea for improving it.
Repeat a String Repeat a String
Tags: javascript, tutorial, beginners
Published: 2021-05-29 01:29:52

* Repeat a given string `str`(first argument) for `num` times (second argument). Return an empty string if `num` is not a positive number. You can also use the built-in `.repeat()` method or recursion.
```
function repeatStringNumTimes(str, num) {
  return str;
}

repeatStringNumTimes("abc", 3);
```
* This could be done with .repeat() method like so:
```
 if (num < 0) return ""; 
 return str.repeat(num); // would console log abcabcabc;
```
* Also recursion would work here like so;
```
function repeatStringNumTimes(str, num) {
 if (num <= 0) return "";
 if (num === 1) return str; //base case
 return str + repeatStringNumTimes(str, num - 1);
};
repeatingStringNumTimes("abc", 3);
// "abc" + repeatStringNumTimes("abc", 2)
// "abc" + repeatStringNumTimes("abc", 1)
// "abc"
```
```
function repeatStringNumTimes(str, num) {
  let final = "";
  if (num < 0) return "";
  for (let i = 0; i < num; i++) {
    final = final + str;
  }
  return final;
}

console.log(repeatStringNumTimes("abc", 3)); // will display abcabcabc
```
Checking If A String Ends With The Given Target String
Tags: javascript, tutorial, beginners, devops
Published: 2021-05-29 01:00:39

* Check if a string (first argument, `str`) ends with the given target string (second argument, `target`).

* This challenge can also be solved with the `.endsWith() method`, which was introduced in ES2015. 
```
function confirmEnding(str, target) {
  return str;
}

confirmEnding("Bastian", "n");
```
*First let's learn substr:
```
let sentence = "I'm running in 5 minutes.";
console.log(sentence.substr(2)); // would return "m running in 5 minutes". If (0,5) it would give me the letters that start at 0 and end at 5 not including 5.
// If we're trying to find the end parts of the sentence simply.
console.log(sentence.substr(-2); // would display "s."
// also could be done with endsWith()
if (str.endsWith(target)) {
  return true;
}
 return false;
};
```
Answer:
```
function confirmEnding(str, target) {
  if (str.substr(-target.length) === target) {
    return true;
  } else {
    return false;
 }
}

console.log(confirmEnding("Bastian", "n")); // will display true
```
CSS Custom Properties
Tags: html, css
Published: 2021-05-29 00:53:24

I've been working on a Razor project and was finding a way to dynamically assign style values to `::before` elements. Best way to do this is via [CSS Custom Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)

Here's what I came up with Razor code:

css
```
.wrapper::before {
  background-color: var(--label-color);
  content: var(--label-text);
}
```

razor
```
@{
  var labelText = "Some Label";
  var labelColor = "blue";
}
<div class="wrapper" style="--label-color: @labelColor; --label-text: '@labelText'">
  Hello
</div>
```
Edge GraphQL with Cloudflare Workers
Tags: cloudflare, graphql, workers, apollo
Published: 2021-05-29 00:48:17

---
canonical_url: "https://ajcwebdev.com/deploy-gql-edge-server-with-cloudflare/"
description: "How to run a GraphQL server on the edge with Apollo GraphQL, Cloudflare Workers, Webpack, and Wrangler."
---

## Outline

- [Introduction](#introduction)
  - [Generate Project](#generate-project)
  - [Set Account ID in Wrangler Configuration](#set-account-id-in-wrangler-configuration)
  - [Deploy to Cloudflare](#deploy-to-cloudflare)

> ___All of this project's code can be found in the [First Look monorepo](https://github.com/ajcwebdev/a-first-look/tree/main/deployment/cloudflare-graphql/) on my GitHub.___

## Introduction

### Generate Project

```bash
wrangler generate my-graphql-server https://github.com/signalnerve/workers-graphql-server
```

### Set Account ID in Wrangler Configuration

```toml
name = "workers-graphql-server"
type = "webpack"
zone_id = ""
account_id = ""
route = ""
workers_dev = true
webpack_config = "webpack.config.js"
```

### Deploy to Cloudflare

```bash
cd my-graphql-server
wrangler publish
```

```
✨  Built successfully, built project size is 560 KiB.
✨  Successfully published your script to
 https://workers-graphql-server.anthonycampolo.workers.dev
```

![01-pokemon-graphql](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mxhczudxzft7uek4ft3d.png)
KISS Design Principle in 100 seconds
Tags: javascript, webdev, design, architecture
Published: 2021-05-29 00:33:21

## :bulb: What does KISS stand for?
:kiss: KISS principle (or Keep It Simple, Stupid) is a design principal which states that most systems work best if they are kept simple rather than made overly complicated. KISS is used in a variety of disciplines, such as interface design, product design, and software development.

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

## :bust_in_silhouette: Origination

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ef5m4m17ypgpef91voyy.jpg)
This principle is thought to have been coined by the late Kelly Johnson, who was the lead engineer at the Lockheed Skunk Works (a place responsible for the S-71 Blackbird spy plane amongst many other notable achievements).

Kelly explained the idea to others with a simple story. He told the designers at Lockheed that whatever they made had to be something that could be repaired by a man in a field with some basic mechanic's training and simple tools. The theater of war (for which Lockheed’s products were designed) would not allow for more than that. If their products weren't simple and easy to understand – they would quickly become obsolete in combat conditions and thus worthless.

## :star: Why KISS?
- Less code takes less time to write, minimizes the amount of bugs, and is easier to modify and maintain.
- The more complex something is, the more ways there are for it to fail, and the more difficult it is to explain to someone else who needs to understand it.
- Perfection is reached not when there is nothing left to add, but when there is nothing left to take away.

## :bookmark: Variants
- Keep it short and simple
- Keep it simple and straightforward

## :memo: Side Notes
- Not to make things so simple that they compromise the functionality of the final design.
- Users will live with a little complexity if it enhances their overall experience.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7gzqv0rus35v4tbya8n.jpg)

## :iphone: Keep in Touch
If you like this article, don't forget to follow and stay in touch with my latest ones in the future by following me via:

- **Twitter:** https://twitter.com/RichardWynn01
- **Medium:** https://richard-wynn.medium.com
- **Github:** https://github.com/richard-wynn

## :newspaper: Other Programming Principles
Be interested? :smiley: You can visit the links below read my other posts in my programming principles series 
- [Single Responsibility Principle (SRP) in 100 seconds](https://dev.to/richardwynn/single-responsibility-principle-srp-in-100-seconds-3b1d)
- [YAGNI Principle in 100 seconds](https://dev.to/richardwynn/yagni-principle-in-100-seconds-1i6j)