teleren/devto huggingface dataset:
Deploying different CloudFormation stacks based on different AWS accounts with AWS CDK
Tags: aws, cdk, javascript, devops
Published: 2022-09-09 03:01:57

AWS CDK is a great tool to write AWS `infrastructure as code` in your favorite language. Apart from all the awesome features that CDK offers, one of the things that I personally like is that it helps us to make sure we `don't repeat ourselves` or [DRY principal](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)

As most of the teams use multiple environments to build a product, we need to deploy resources to all those environments. Not that always the environments have the same resources or configurations, in fact, most of the time you'd have different resources or setups for your `dev` compared to `prod` or `staging`. In the AWS, you would have different accounts for different environments due to various reasons such as security, access distribution and etc.

In my case, I wanted to deploy to these environments as efficiently as possible. I have some common resources between these environments and some resources that are specific to each one. On the other hand, I want to have only one CDK app handling my deployments to different environments.

The solution that I came up with was using `assume role` I can figure out which account we want to deploy and based on that account number and a simple mapping between environments and accounts, I figure out which environment is the one we want to deploy so I just deploy the stacks that I want for that environment.

As you can see this is very easy since we're writing the infrastructure imperatively: 


```js
/* eslint-disable no-new */

const AWS = require("aws-sdk");
const cdk = require("@aws-cdk/core");
const { CommonStack } = require("./stack");
const { DevStack } = require("./dev-stack");
const { ProdStack } = require("./prod-stack");


const sts = new AWS.STS({});

const TEST_REGION = "eu-west-1";
const DEV_REGION = "eu-west-1";

const AWS_ACCOUNT_IDS = {
  development: "000000000",
  quality: "00000000",
  production: "000000000",
};

class App extends cdk.App {

  deployCommonStacks() {
    this.commonStack = new CommonStack(
      this,
      "commonStack",
      {}
    );
  }
  
  deployDevStacks() {
    this.devStack = new DevStack(
      this,
      "devStack",
      {}
    );    
  }
  
  deployProdStacks() {
    this.prodStack = new ProdStack(
      this,
      "prodStack",
      {}
    );    
    
  }

  async deployStacks() {
    const assumed = await sts.getCallerIdentity({}).promise();
    console.log("deployStacks() caller identity:", assumed);

    this.deployCommonStacks();

    if (assumed.Account === AWS_ACCOUNT_IDS.development) {
      console.log("Deploying to development account:");
      this.deployDevStacks();
    }

    if (assumed.Account === AWS_ACCOUNT_IDS.production) {
      console.log("Deploying to production account:");
      this.deployProdStacks();
    }

    return assumed.Account;
  }
}

const app = new App();
app
  .deployStacks()
  .then(acc => {
    console.log(`deployStacks() completed for account: ${acc}`);
  })
  .catch(e => {
    console.log("error in deployStacks():", e);
  });
```
System Design: CAP theorem
Tags: distributedsystems, architecture, tutorial
Published: 2022-09-09 03:01:49


CAP theorem states that a distributed system can deliver only two of the three desired characteristics Consistency, Availability, and Partition tolerance (CAP).

![cap-theorem](https://raw.githubusercontent.com/karanpratapsingh/portfolio/master/public/static/courses/system-design/chapter-II/cap-theorem/cap-theorem.png)

Let's take a detailed look at the three distributed system characteristics to which the CAP theorem refers.

### Consistency

Consistency means that all clients see the same data at the same time, no matter which node they connect to. For this to happen, whenever data is written to one node, it must be instantly forwarded or replicated across all the nodes in the system before the write is deemed "successful".

### Availability

Availability means that any client making a request for data gets a response, even if one or more nodes are down.

### Partition tolerance

Partition tolerance means the system continues to work despite message loss or partial failure. A system that is partition-tolerant can sustain any amount of network failure that doesn't result in a failure of the entire network. Data is sufficiently replicated across combinations of nodes and networks to keep the system up through intermittent outages.

## Consistency-Availability Tradeoff

We live in a physical world and can't guarantee the stability of a network, so distributed databases must choose Partition Tolerance (P). This implies a tradeoff between Consistency (C) and Availability (A).

### CA database

A CA database delivers consistency and availability across all nodes. It can't do this if there is a partition between any two nodes in the system, and therefore can't deliver fault tolerance.

**Example**: [PostgreSQL](https://www.postgresql.org), [MariaDB](https://mariadb.org).

### CP database

A CP database delivers consistency and partition tolerance at the expense of availability. When a partition occurs between any two nodes, the system has to shut down the non-consistent node until the partition is resolved.

**Example**: [MongoDB](https://www.mongodb.com), [Apache HBase](https://hbase.apache.org).

### AP database

An AP database delivers availability and partition tolerance at the expense of consistency. When a partition occurs, all nodes remain available but those at the wrong end of a partition might return an older version of data than others. When the partition is resolved, the AP databases typically re-syncs the nodes to repair all inconsistencies in the system.

**Example**: [Apache Cassandra](https://cassandra.apache.org), [CouchDB](https://couchdb.apache.org).


---

_This article is part of my open source [System Design Course](https://github.com/karanpratapsingh/system-design) available on Github._

{% github karanpratapsingh/system-design %}
Automating the selection of named profiles from the .aws/credentials file
Published: 2022-09-09 02:57:55

While working continuously on the AWS CLI, I found it tedious to switch between users by manually exporting the AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY as these credentials need to be set in every session of the shell. So I have created a bash script to automate this selection in which you can provide a named profile & based on the access key ID & secret access key the above environment variables would be set automatically.

To understand more on named profiles, please go through the AWS documentation link:

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

The .aws/credentials file created follows a format shown below:
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

[user1]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY

In case I do not specify any named profile, the default profile would be applied as below

**aws ec2 describe-instances**

else if I want a specific profile to be applied to my command I can :
**aws ec2 describe-instances --profile user1**

This will list the ec2 instances for the user profile of user1.

You can automate this so that every time you open a shell you just provide the named profile to the script & it will set the access credentials for you that will be valid for the entire session.

While working on this automation I came across Ben Kehoe's article regarding the same & this worked as an inspiration to write my own script:

https://ben11kehoe.medium.com/aws-configuration-files-explained-9a7ea7a5b42e

I have placed the bash script my GitHub repository:

https://github.com/neetu-mallan/AutomateCLINamedProfileSelection

Check the README.md file to understand what the script does:

https://github.com/neetu-mallan/AutomateCLINamedProfileSelection/blob/main/README.md
Appropriate Algorithm for Influencers Ranking
Tags: algorithms, help, discuss, machinelearning
Published: 2022-09-09 02:51:20

Hello everyone,

I have just started working on my first project on ranking influencers and I have a few doubts about it.

**DESCRIPTION**

The objective of this project is to rank different social influencers according to their influential power based on a set of metrics. The idea is rank the influencers based on the score calculated.

Metrics collected:
- username
- categories (the niche the influencer is in)
- influencer_type
- followers
- follower grow, follower_growth_rate
- highlightReelCount, igtvVideoCount, postsCount
- avg_likes, avg_comments
- likes_comments_ratio (comments per 100 likes, use as in authentic indicator)
- engagement_rate
- authentic_engagement (the number of likes and comments that come from real people）
- post_per_week
- etc

Here's how the data collected looks like:

![Sample_data](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jf1ypmkwnhuhb3w3o67b.png)

While here is the expected results:

![Expected_results](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zddyf48dmhe3xvuy1iri.png)


I have tried a numbers of approaches for the ranking algorithms on my project as in the following:
a) Regression model

b) Classification model

c) Machine learning model like SVM, Decision Tree and Deep Neural Network

d) Learning to rank algorithm like CatBoost

e) Any other suitable algorithm

**QUESTION**

I would like to ask which of the algorithm from the above will be more appropriate and applicable to this project? Any ideas will be much appreciated if anyone of you here came across with similar projects or have some ideas about it. Thank you in advance!
Smallest Number in Infinite Set
Tags: python, leetcode
Published: 2022-09-09 02:47:08

You have a set which contains all positive integers [1, 2, 3, 4, 5, ...].

Implement the SmallestInfiniteSet class:

SmallestInfiniteSet() Initializes the SmallestInfiniteSet object to contain all positive integers.
int popSmallest() Removes and returns the smallest integer contained in the infinite set.
void addBack(int num) Adds a positive integer num back into the infinite set, if it is not already in the infinite set.


```py
class SmallestInfiniteSet:
    import heapq
    def __init__(self):
        self.summary = list(range(1, 1001))
        heapq.heapify(self.summary)
        self.deleted = set()
    def popSmallest(self) -> int:
        A = heapq.heappop(self.summary)
        self.deleted.add(A)
        return A
    def addBack(self, num: int) -> None:
        if num in self.deleted:
            self.deleted.remove(num)
            heapq.heappush(self.summary, num)
        
```
EXAM TEST 1
Published: 2022-09-09 02:12:54

**Chapter 2, 3, 5, 6, 7, 10**

1. on servera create file pengaturan.conf in direktory /home/student/

2. in pengaturan.conf create text:
SSID:TJKTADB
ABSENID=XX

3. on servera ensure that newly created users have passwords that must be changed every 60 days.

4. on servera create group KARYAWAN with ID 37800 andgroup ADMIN with ID 11011

5. on servera create member for group KARYAWAN "nunung, ela, fahmi"

6. on servera create member for group ADMIN "avis, harist, rifai". create password for user harist is 'tkj'.

7. on servera Configure administrative rights for all members of ADMIN to be able to execute any command as any user.

8. on servera Change the password policy for the rifai account to require a new password every 15 days.

9. on servera Change the group ownership of the /home/student/DATA directory to the ADMIN group.

10. on servera Set permissions on the /home/student/DATA directory. On the /home/student/DATA, read/write/execute permissions (7) for the owner/user and group, and no permissions (0) for other users.

11. on serverb Install and Configure the httpd.x86_64 service to start at system boot. and Verify that the httpd service is enabled and active at system boot.

12. switch to harist user on servera. and use ssh-keygen command to generate passphrase-less SSH keys for harist on servera. use ssh-copy-id command to send the public key of the SSH key pair to harist on serverb.
Palindrome Linked List - I
Published: 2022-09-09 02:00:18

Approach 1 :
1) Reach till middle of list;
2) Reverse from middle till last
3) compare & return 

```js
var isPalindrome = function(head) {

    const midElementOfList = getMiddleElemnt(head);
    const reversedFromMiddleTillEnd = reverseList(midElementOfList);
    return checkIfPalindrome(head, reversedFromMiddleTillEnd);
};

var getMiddleElemnt = (head) => {
let slow = head;
let fast = head;
    
    while(fast && fast.next !==null && fast.next.next !== null){
        slow = slow.next;
        fast= fast.next.next;
    }
    return slow;
}
var checkIfPalindrome = (head, reverseList) =>{
    while(head!==null && reverseList !==null){
        if(head.val!== reverseList.val){
            return false;
        }
        head = head.next;
        reverseList= reverseList.next;
    }
    return true;
}

var reverseList = function(head) {
    
const reverseR = (head) => {
   if (head === null || head.next === null) {
    return head;
  }
   let rest_trail = reverseR(head.next);
    const nextOfHead = head.next;
    nextOfHead.next = head;
    head.next = null;
    return rest_trail;
}
return reverseR(head);   
}

```
Approach 2 :
1) Reach till end of list & store value of each node in array.
2) Now Reverse array & compare each element with actual array.

Approach 3 :
1) Clone out List first - (Add's complexity & extra work) 
1) Now Reverse cloned List
2) Compare each element with actual List.
Conversor de moeda
Tags: codepen
Published: 2022-09-09 01:07:19

<p>Como tudo, a base é o pilar do conhecimento assim como os pilares são de uma casa.
Nesse desáfio busquei treinar um pouco mais aquilo que é a visão do design da coisa e essencialmente pôr em prática os desafios que a Raffa e o pessoal da imersão sugeriram.
Peguei como imagem do fundo a moeda de #ANGOLA, que é o pais de onde eu sou e no âmbito do desfios de javascript, procurei crira duas funções que convertem noedas diferentes, uma é o kwanza moeda do meu país e o outro a de Bitcoin.</p>

<p>podem checkar tá funcionar tudo perfeitinho e claro estou aberto para ideias no discord da imersao pessoal
bem haja time #imersaodev, #alura </p>

{% codepen https://codepen.io/daveMurphy/pen/BaxKBve %}
👉5 Best Online Tools Every developer/designer needs👈
Tags: webdev, beginners, codenewbie, design
Published: 2022-09-09 00:35:28

Note: If you have a tool in mind that I've missed, it would help a lot if you commented it below. :) BTW, Some of the links are affiliated(Not Sponsored), however, I promise you that I'll only recommend you tools that I personally use. 

In this post, I'll go over 5 of the best online Tools I believe each and every developer needs to use. I'll go over how I personally use the tools and what I use them for.

## Canva
Canva is a great tool I use to design elements. I personally love using it to create short videos and design logos for my project.

![Canva Home Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2oa4zghz2m5boimtou2.png)

It really is a great tool I would recommend to developers and designers alike. 

Note: Clicking on the link below when joining canva will allow you to get a free premium element.
[Canva](https://www.canva.com/join/ykr-hzq-fmx)

## Trello
Trello is a great way to manage your projects. Trello shines especially well in team management, but I would also use it in my personal projects too.

![Trello](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60oqwz6y0di55s083z0c.png)

Trello is great for individual project management or team management. 

[Trello](https://trello.com/)

## Siteground
For anyone developers or designers who want a portfolio to display their works, or to create any type of website, you should check out siteground.


![Siteground](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha5936e1yhg2z7pwy2p3.png)

I personally use siteground to host my [personal blog](https://freetechnologyhelp.com/), and I'll recommend you to use it as well. 

[Siteground](https://www.siteground.com/recommended?referrer_id=8833701)

## Visual Studio Code
Most of you that are reading this probably already have an IDE installed. For the few of you who are still using your OS default notepad, I strongly recommend you to check out VS Code.


![Visual Studio Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wwospj726zi84u77vycc.png)

It is an easy-to-use IDE that many developers out there use. 

[VS Code](https://code.visualstudio.com/)

## Chrome Developer Tools
I cannot conclude this list with anything else but the Chrome Developer Tools. This is by far the most important in this entire list.(Except VS code) When I get an error, the first thing that I'll open is the Chrome Developer Tools.

![Chrome Developer Tools](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7u3yt1jh4o7b9avzefa.png)

To get the chrome Developer tools, first, you'll need to open up google chrome. After that, right-click (or double tap on mac) to open up the context menu. After that, select inspect.

[Google](https://www.google.com/)
<!-- wp:heading -->
<h2>Conclusion:</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Thanks for reading! If you have any questions or suggestions, remember to comment below. </p>
<!-- /wp:paragraph -->
A New Beginning
Tags: opensource
Published: 2022-09-09 00:25:10

**About Me**

Hi all, my name is Arhchuthan Baskarasingham! I am a computer programming student in the Computer Programming & Analysis program (CPAC). My main programming languages of interest are C++, C and JavaScript. I am mainly interested in web design and have a general interest in game design. I am currently taking this course (OSD600) because I was always curious of how Open Source Development worked and was hoping to experience something new out of my comfort zone.

**What I Am Hoping To Accomplish**

As mentioned before, I have a general interest in game design and wanted to see if I could contribute my skills in C/C++ to any Open Source projects regarding game design. I have used this program before called the CEMU emulator to emulate video games for the WII U console, and I was amazed at what the creators were able to achieve. They were able to emulate the games as close as possible to the original and even provide options to play them in 4k resolution (an option that was not possible on the original WII U console). I'm hoping I could contribute to a project in regards to game emulation.

**Trending GitHub Repo**

Original repo: {% embed https://github.com/RPCS3/rpcs3 %}
Forked repo: {% embed https://github.com/abaskarasingham/rpcs3 %}

I found a trending GitHub repo called rpcs3 which is a Open Source PlayStation 3 Emulator and debugger written in C++ for Windows, Linux, macOS, and FreeBSD. Not only have I picked this due to being interested in game emulation, but I was surprised to see this on the trending GitHub page as I was just trying out this emulator for the first time last summer. I remember reading about how most of the popular triple A games were not as accessible for most computers on the low to mid tier end, as well as some high end computers due to not being optimized at the moment. I even had some trouble with running some PS3 games myself on the emulator and was wondering when it would be optimized for more computers. Perhaps I could contribute to this GitHub repo to assist in the optimization of rpcs3?
Looking for a study buddy to learn Web Dev
Tags: javascript, webdev, beginners, vue
Published: 2022-09-09 00:21:11

It's so boring to code without sharing your progress and thoughts.
Maybe somebody is experiencing the same.

I'm 26yo. I have recently started to work as a Dev. I have some knowledge of JS and Java. I'm going to learn VueJS and Spring to improve my skills. Looking for someone who is learning Web Dev, beginner/junior level.

Time zone: Toronto, Eastern Standard Time.
Blog: 2022-09-09: Content & Tooling Team Status Update
Tags: puppet, content, updates
Published: 2022-09-09 14:48:09

---
title: Blog: 2022-09-09: Content & Tooling Team Status Update
published: true
date: 2022-09-09 00:00:00 UTC
tags: puppet, content, updates
canonical_url: https://puppetlabs.github.io/content-and-tooling-team/blog/updates/2022-09-09-status-update/
---

## Happy Friday y’all!

It’s Friday! It’s time again to reflect on the week in the CAT team.

This week we have welcomed [Jordan Breen](https://github.com/jordanbreenpuppet) to the team. Jordan is joining us as an Associate Software Engineer and we are delighted to have him as part of the team. In his own words: “I am joining Puppet having recently graduated from Ulster University with a degree in Software Engineering and having gained valuable experience on placement as a technical consultant at Codec. I spend my time off watching just about any football game on the tele, or I can be found at Brewster Park supporting my local GAA club.”

Otherwise, this week has been relatively quiet. Here are the updates.

## Community Contributions

We’d like to thank the following people in the Puppet Community for their contributions over this past week:

- [`puppetlabs-accounts#415`](https://github.com/puppetlabs/puppetlabs-accounts/pull/415): “Fix sshkey\_mode bug”, thanks to [holtwilkins](https://github.com/holtwilkins)

- [`puppetlabs-apache#2303`](https://github.com/puppetlabs/puppetlabs-apache/pull/2303): “Simplify the logic in \_require.erb”, thanks to [ekohl](https://github.com/ekohl)

- [`puppetlabs-apache#2300`](https://github.com/puppetlabs/puppetlabs-apache/pull/2300): “Test proxy\_dest\_reverse\_match parameter”, thanks to [traylenator](https://github.com/traylenator)

- [`puppetlabs-apache#2293`](https://github.com/puppetlabs/puppetlabs-apache/pull/2293): “Fix deprecation warning about performing a regex comparison on a hash”, thanks to [smokris](https://github.com/smokris) and the following people who helped get it over the line ([ekohl](https://github.com/ekohl))

- [`puppetlabs-apache#2280`](https://github.com/puppetlabs/puppetlabs-apache/pull/2280): “Parameterize CRS DOS protection”, thanks to [Vincevrp](https://github.com/Vincevrp)
Are code freezes ever a good idea?
Tags: codefreeze, cicd, qa
Published: 2022-09-09 12:32:46

---
title: Are code freezes ever a good idea?
published: true
date: 2022-09-09 00:00:00 UTC
tags: codefreeze,cicd,qa
canonical_url: https://jhall.io/archive/2022/09/09/are-code-freezes-ever-a-good-idea/
---

I recently learned of a GitHub app to facilitate code freezes, and it even supports scheduled code freezes.

Despite my immediate reaction of…

 ![facepalm](https://jhall.io/images/picard-facepalm.jpg)

…it got me thinking: Is there ever a valid case for a code freeze?

I came up with two, partly overlapping, answers.

1. A code freeze is a useful emergency tool.

2. Slow review processes.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._