teleren/devto huggingface dataset:
CDK to deploy a Lambda function 
Published: 2022-02-12 04:35:28

There are may options to deploy a Lambda fuction: <br/>
- zip the code and upload to S3 
- share large dependencies via EFS
- inline funtion with CloudFormation <br/>

In this note, I would like to share three ways to deploy a Lambda function using AWS CDK, and integrate multiple Lambda functions with a API Gateway for testing. 

## 1. Deploy a lambda function by files 
install dependencies 
```
python -m pip install --target path-to-lambda numpy 
```
aws_lambda.Function 
```
handler_file = aws_lambda.Function(
            self,
            id="lambda-handler-wo-dependencies",
            code=aws_lambda.Code.from_asset(path.join(dirname, "lambda")),
            handler="handler.handler_file",
            runtime=aws_lambda.Runtime.PYTHON_3_8,
            memory_size=512,
            timeout=Duration.seconds(90)
        )
```
## 2. Deploy a lambda function by ecr image 

Note that the docker image is built from the local machine in this case. Here is the project structure 
```
- aws_devops
    - lambda
        - Dockerfile
        - .dockerignore
        - handler.py
        - requirements.txt
     -aws_devops_stack.py
```
```
handler_ecr = aws_lambda.Function(
            self,
            id="lambda-ecr-build-local",
            code=aws_lambda.EcrImageCode.from_asset_image(
                directory=path.join(dirname, "lambda")
            ),
            handler=aws_lambda.Handler.FROM_IMAGE,
            runtime=aws_lambda.Runtime.FROM_IMAGE,
            memory_size=512,
            timeout=Duration.seconds(90)
        )
```
## 3. Deploy a lambda function with an existring ecr image 
```
handler = aws_lambda.Function(
            self,
            id="EcrImageId",
            code=aws_lambda.EcrImageCode.from_ecr_image(
                repository=aws_ecr.Repository.from_repository_name(
                    self,
                    id="EcrImageId",
                    repository_name="EcrRepositoryName"
                )
            ),
            architecture=aws_lambda.Architecture.ARM_64,
            handler=aws_lambda.Handler.FROM_IMAGE,
            runtime=aws_lambda.Runtime.FROM_IMAGE,
            memory_size=512,
            timeout=Duration.seconds(90),
        )
```

## 4. Integrate an API Gateway with multiple lambdas
create an api gateway 
```
api_gw = aws_apigateway.RestApi(
            self,
            id="ApiGatewayLambdaDeployOptions",
            rest_api_name="api-lambda-deploy-options"
        )
```
create api resource 
```
api_file_resource = api_gw.root.add_resource(
            path_part="file"
        )
```
create lambda integration
```
 api_file_intetgration = aws_apigateway.LambdaIntegration(
            handler=handler_file
        )
```
add method to the resource 
```
 api_file_resource.add_method(
            http_method="GET",
            integration=api_file_intetgration
        )
```
Hello, world!
Tags: javascript, webdev, beginners, productivity
Published: 2022-02-12 03:28:56

That's the first thing yo do when you start coding, isn't it?

So be it for the title.

Well, so this is my first post here. If you're seeing this you can check out my projects [here](https://github.com/abhishekpawl).

As for my first post, I recently built this little utility tool to help fasten up things for me and might just help you too. Be sure to check this out add it to your chrome browser.

Repo: [Link](https://github.com/abhishekpawl/localhost)

Here's a snippet of the same.
![Snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6q7rxrqaz4nexkjdtsuo.gif)
Avoid sddm-greeter to have high CPU usage
Tags: linux, ubuntu, tutorial
Published: 2022-02-12 03:04:39

## Summary

My iMac having Ubuntu kept having high CPU usage with the program `sddm-greeter`.

## Solution

Amending the file `/etc/security/pam_env.conf` fixed up the issue :

```
/etc/security/pam_env.conf
======
#
# Avoid high cpu usage with sddm-greeter
# https://github.com/sddm/sddm/issues/323
QT_QUICK_BACKEND DEFAULT=software
```

## Reference

- [high cpu when sddm-greeter is idle](https://github.com/sddm/sddm/issues/323)

## Related Post

- [Enable your Linux Machine to show login (SDDM) with Aerial Theme when motion is detected](https://dev.to/brisbanewebdeveloper/enable-your-linux-machine-to-show-login-sddm-with-aerial-theme-when-motion-is-detected-35af)
How to monitor PostgreSQL with Prometheus and Grafana | Docker
Tags: docker, prometheus, grafana, postgres
Published: 2022-02-12 02:26:00

For this example we will use Docker compose to be able to run all the services.

1.Docker Compose

```yaml
version: "3.9"
services:
  grafana:
    image: grafana/grafana
    ports:
      - 3000:3000

  prometheus:
    image: prom/prometheus
    ports:
      - 9090:9090
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro

  postgres:
    image: postgres:12
    ports:
      - 5432:5432
    volumes:
      - ./backup:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: postgrespassword
      POSTGRES_DB: shop

  postgres-exporter:
    image: prometheuscommunity/postgres-exporter
    ports:
      - 9187:9187
    environment:
      DATA_SOURCE_NAME: "postgresql://postgres:postgrespassword@postgres:5432/shop?sslmode=disable"
    links:
      - postgres
      - prometheus

```

2.Prometheus File Settings (prometheus.yml)

```yaml
global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: postgres-exporter
    static_configs:
      - targets: ["postgres-exporter:9187"]
```

3.Run Docker Compose

```bash
docker-compose up
```
4.Check status of Prometheus and PostgreSQL Exporter

```bash
http://localhost:9090/targets
```

5.Visit Grafana Dashboard

Default

User: admin
Password: admin

```
http://localhost:3000
```

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

6.Add data source

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

Save and test


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

7.Import PostgreSQL Dashboard for Prometheus

For this we will use a Dashboard created by the community


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

https://grafana.com/grafana/dashboards/9628

8.Import JSON or code
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jt2nl7m16u5vs6acdhe8.png)


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

Code: 9628

9.Dashboard

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

Code of example (GitHub Gist)

https://gist.github.com/nelsoncode019/1c0f7930aab755223de7f971f3aca94b
Latex For Beginners Part 2
Published: 2022-02-12 01:49:26

This part will be dedicated to talking about Parts, Chapters, Sections and Paragraphs. The hierarchy being just that, so for those who don't click a lot in Microsoft Word to make sure everything is the right hierarchy, you're going to have to type it now! (Honestly I rather type than click a lot). 

For those wondering what a `section` is, it's another word for header, but more general since latex serves different needs for documents. 

Defining these are simple, just put `\` in front of the word, like so: 
```tex
\part{Part 1}
\chapter{Chapter 1}
\section{Section 1}
\paragraph{Paragraph 1}
\par Text % \par is for paragraph text, as it indents
```

> Except for `\par`, they all have alternate forms by putting `*` in front of the word, this is to not have the numbers and such 
shown.

Let's make a new document and use a variety of these to really show how they work: 

```tex 
\documentclass[11pt, letterpaper, oneside]{book}
% To use chapter, it must be book class
\title{Latex For Beginners Part 2}
\author{Mustafif}
\date{\today}

\begin{document}
   \maketitle % create title page 
   \pagenumbering{arabic} %define page numbering
   \newpage
   \tableofcontents % set table of contents
   \newpage 
   \part{The first of the first}
   \chapter{I am chapter}
   \section{I am the section}
   \subsection{I am subsection}
   \subsubsection{I am subsubsection}
   \section*{I have no number and TOC won't see me}
\end{document}
```

Run `pdflatex part2.tex` and you'll see something like this: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/prvjcwth4y144bal5fct.png)


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

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

In the next part we will discuss Equations, the fun and the pain
AlmaLinux now available on Microsoft Azure. Azure Sponsors AlmaLinux!
Tags: almalinux, opensource, linux, centos
Published: 2022-02-12 01:47:02

Today, we are glad to announce the availability of [AlmaLinux OS on the Azure marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps/almalinux.almalinux?tab=Overview
). Images are available for both Gen1 and Gen2 and are deployable from the Azure portal, Azure command line utility as well as from the marketplace link.

Aside from just images, we've also established a worldwide [mirror network](https://mirrors.almalinux.org/
) within Azure regions in order to make the user experience when installing updates or new software second to none. All updates and/or software installations will automatically use local Azure mirrors, thanks to our [new mirror service released a little while ago](https://almalinux.org/blog/the-new-and-improved-almalinux-mirror-service/
). The best part is, its all transparent to you, the user.

We would sincerely like to thank the amazing Linux team at Azure for their sponsorship of AlmaLinux. Their sponsorship of the project and collaboration will enable many great things and you will be hearing more news real soon. The Azure team were instrumental to making this a success and collaborating with them upstream was a great highlight of this journey.

We're doing lots of great work and we hope you'll join us as we continue on our journey of bringing the community the ONLY 100% community owned and governed enterprise-grade Linux distribution and CentOS alternative. Please join us on the [AlmaLinux Community Chat](https://chat.almalinux.org/
) and the [SIG/Cloud channel](https://chat.almalinux.org/almalinux/channels/sigcloud
) for any help and assistance. You can also reach out to us on [Twitter](https://twitter.com/almalinux
), [Reddit](https://reddit.com/r/AlmaLinux
) and the [AlmaLinux Cloud SIG Forum](https://almalinux.discourse.group/c/sigs/cloud-sig/10
).
Splash Screen, Onboarding Screen and Loading Screen Feature in a Vue Project.
Tags: vue, node, devops, webdev
Published: 2022-02-12 01:45:26

Splash screens, Onboarding Screens and Loading Screens are vital mico-interaction feature in a web-app especially when following a mobile-first approach / methodology. It gives the finishing touches of a tandard web application.

Before we dive into coding, let me clarify what a Splash Screen is, what a loading screen is and why this micro-interactions plays an important role in the User-Experience of your application.

## 1. A Splash Screen

In context, a splash screen is the type of micro-interaction a user expereince, at the launch of an app, that is primarily to give primary information about the app while the app contents load for a first-time.

## 2. An Onboarding Screen

This is a type of micro-interaction screen display that houses the tutorial guides presentation (step-by-step) tour on how to use an app.

## 3. A Loading Screen

This can also be reffered to as a waiting screen. It is a type of micro-interaction that displays in between the request and response time of a user.
Make The Whole Picture Link.
Tags: javascript, html, css, shopify
Published: 2022-02-12 01:32:26

 In this website, https://gymboxxx.myshopify.com/ I want the whole picture to be link and the effect to be the same. I think to make tag "a" in the begining of the picture code and the close the tag "/a "in the end of the code for the picture. The problem is that I can't find where to put the tag. Please help me it will be nice.
I want my cart to indicate that there is products in it.
Published: 2022-02-12 01:30:42

This is the website: https://gymboxxx.myshopify.com/. I want when something is adding to the cart to remove the pop up and then when the product is added to the cart, the cart icon to be blue( blue color like the social icons mouse over effect). Tell me how to remove the pop up message. I am changing the name of the modal-dialog-box.liquid to modal-dialog-box2.liquid and the message dissappear but I am wondering is this a right way to do it. The other way is to put the code inside this symbols "<!--" /code here  "-->". Tell me is this the right way. When the message is gone when adding product to cart the cart must became blue. Tell me how to make the cart blue when procducts are in it. Thank you.
Change Dark theme React
Tags: react, styled, tutorial, theme
Published: 2022-02-12 01:25:23

#### I read a lots article of writing a toggle to change the theme. For a beginner, this is entire too difficult to understand multiple files and code. 

#### I'm going to show you guys a simple way to change the by using useState and styled-components 😛 😝

Here is my step: 

Step 1 :

Install styled-components, we need this library. 

```terminal
npm install --save styled-components
```

Step 2: 
Import these things, you will use useState later 😏

```react 
import { ThemeProvider } from "styled-components";
import { createGlobalStyle } from "styled-components";
import { useState } from "react";
```

Step 3:
Initialize the Dark and Light 
Simply define our lovely variable 😛:

```react 

  const [theme, setTheme] = useState("light");
 
  const light = {
    body: "#E2E2E2" // you can change to any color you like
  };

  const dark = {
    body: "#363537" // you can change to any color you like
  };

  const GlobalStyle = createGlobalStyle`
  body{
    background: ${({ theme }) => theme.body};
  }
  `;

```
Step 4: 
Return

```react 

import "./styles.css";
import { ThemeProvider } from "styled-components";
import { createGlobalStyle } from "styled-components";
import { useState } from "react";

export default function App() {
  const [theme, setTheme] = useState("light");

  const light = {
    body: "#E2E2E2"
  };
  const dark = {
    body: "#363537"
  };

  const GlobalStyle = createGlobalStyle`
  body{
    background: ${({ theme }) => theme.body};
  }
  `;

  return (
    <ThemeProvider theme={theme === "light" ? dark : light}>
      <GlobalStyle />
      <button
        onClick={() => {
          if (theme === "light") {
            setTheme("dark");
          } else {
            setTheme("light");
 
          }
        }}
      >
        change
      </button>
    </ThemeProvider>
  );
}

```

#### Here is a demo: 
![demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nxmfqqyrom8ppqzs9lpy.gif)

### Hope these help you, Thanks for reading, Have fun! 🥰
Strategic Reasons Why Cyber Warfare Is On The Rise
Tags: cybersecurity, cyberwar, cyberattacks, cybersec
Published: 2022-02-12 00:14:54

The development of the internet and revolution in information technology present the risk of cyberwar. Catherine A. Theohary et al. define Cyberwar as a state action on other states that becomes equivalent to an armed attack or military action in cyberspace. This technology-based action can lead to a military response from the opposition with a proportional kinetic use of forces. The term Cyberwar refers to the utilization of internet and networking technologies to destroy the enemy nation’s computers and the IT infrastructure to cause a considerable amount of damage as similar to the case of traditional military operations with soldiers armed with firearms and missiles. Internet technologies are being used as cyber weapons. Therefore, nations are preparing themselves for the cyber battlespace. These nations conduct cyber espionage and cyber reconnaissance to steal crucial information about enemy countries and to check their skills and abilities in cyberspace, respectively. Nations are now more concerned about cybersecurity and want to protect their critical national infrastructures to ensure uninterrupted services for their citizens. Therefore, they have started to develop offensive cyberwar capabilities and national strategies.

Cyberwar is conducted to freeze computers with networked devices, to fail crucial servers to dead communication infrastructure, and to thwart technical strategies applied to achieve data assurance. There are several reasons why cyberwar is preferred. These reasons are as follows:

- Cyberwar becomes economical for nations as it does not require massive troops and weapons.
- To begin cyberwar, the entry cost is low as it requires only a computer and internet access.
- Cyberwar can be started silently from anywhere on a global scale.
- Tools mostly used in cyberwar are software, that can be purchased easily or downloaded from the internet.
- The massive availability of malicious tools and their delivery to anyone without any restrictions.
- Lack of technological, financial, and legal barriers to the dispersion and utilization of malicious tools and services.
- Cyberspace hides criminals due to its anonymous nature and makes origin detection difficult.
- Cyberspace delivers disproportionate power to insignificant actors and criminals.
- Cyberwar is profitable and saves lives.
- In Cyberwar, it is difficult to assess damages.
- No need to participate in combat operations.
- Cyberwar does not use the battlefield but leaves long-lasting adverse impacts on opponent countries.
- Cyberwar can be conducted with a single click on a computer.
- It is difficult to prevent cyberattacks and settle down cyberwar as these require skilled hardware and software engineers with sound knowledge and experience in networking and finding such people is difficult. The rapid expansion of IT infrastructure creates countless opportunities for cybercriminals.
- Cyberwar is a way to attain a bloodless conquest.

Hope this was helpful.
OMG! SAFe has an NPS score of -56, so it's terrible, right? Not so fast.
Tags: safe, nps, productmarketfit
Published: 2022-08-08 07:19:25

---
title: OMG! SAFe has an NPS score of -56, so it's terrible, right? Not so fast.
published: true
date: 2022-02-12 00:00:00 UTC
tags: safe,nps,productmarketfit
canonical_url: https://jhall.io/archive/2022/02/12/omg-safe-has-an-nps-score-of-56-so-its-terrible-right-not-so-fast./
---

The Age of Product web site recently published the results of their admitedly _entirely unscientific_ [SAFe NPS survey](https://age-of-product.com/safe-nps-score-56-scaling-framework/), and it’s been making the rounds on agile corners of social media.

There’s a good chance that many of you who have had the, eh… pleasure? of bumping into SAFe see that terrible score and feel some vindication. But you probably shouldn’t.

In my recent article, I explain why!

[Read the full article »](https://jhall.io/posts/nps-safe/)

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Thread of Execution - One Thing at a time
Tags: javascript, beginners, programming
Published: 2022-02-11 23:54:25

OK, you just started learning a programming language and fell in love with JavaScript. However, do you still need help with the code? Guessing different scenarios until you achieve your goal?

Please don't worry; this is normal. I just want you to know that you are not alone in this endeavour. 


Although, I want to help you. So you can get more control of your code. You can understand more about what is happening "under the hood".

#### One thing at the time

The first thing you need to understand to gain more control of your code is to know more about the role of the Thread of Execution(TE). 

By design, JavaScript was created to execute one thing at a time(Single Thread) and in a specific order(top -> bottom). It's responsible for executing line by line of your JS code. 

"I see, but what do you mean by executing?" you might ask. Let's go through an example.

### Example
Suppose we wrote the following JavaScript code:

```javascript
const author = 'Leo'

function validateAuthor(author) {
if(author === 'Spock') {
return true
}
return false
}

validateAuthor(author)

```
Alright, let's dive in:

1- Where have all the constants gone?

```javascript

const author = 'Leo'
```

Here, we declare a constant named author and assign the value 'Leo'.

And not only that. We also store this constant in our memory. We can access the value 'Leo' using the variable author.

2- "Sit tight and assess..."

```javascript

function validateAuthor(author) {
if(author === 'Spock') {
return true
}
return false
}

```
[Functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions) are a _set of statements that performs a task or calculates a value_.

Although, we still need to execute this function.
And for that, we need the "()".

For now, the TE stores this whole block in our memory. And like we see above, allowing us to use it later.

3- "Call me"

```javascript

validateAuthor(author)

```

At last, we are just calling/executing our function. The TE checks the label we use, looks into the memory and runs it. 

And not only that. Please take a look at the label author inside the parenthesis. This means that we wanna use the value of the label author('Leo'), which is already stored in our memory, as a parameter in our function.

Therefore, we grab the value 'Leo' and check if the string equals 'Spock'.

That's it. 

### Practice! 

Of course, this is a simple example. However, it would be best for you to start to create a level of understanding of how your code will be executed. Thus avoiding the guessing habit.

And the only way to improve that, it's with practice. The [Rubber duck debugging](https://en.wikipedia.org/wiki/Rubber_duck_debugging) method might be helpful.

After that, you can search for what I mean by "memory" and so on. Curiosity is an excellent tool for us developers. 

Until the next JS topic!