teleren/devto huggingface dataset:
CloudWatch Monitoring and Alarm Notification for
Lambda
Published: 2022-02-22 02:31:35

This note show a basic example how to use CloudWatch to monitor a Lambda function and notify when number of invocation greater than X within several minutes. 
## Metrics to monitor
- CloudWatch metrics for a Lambda fuction
    - Number of invocation within 5 minutes (period)
- CloudWatch alarm
    - Compare the metric with a threshold > X
    - Evaluation period 1 
    - Action sends SNS notification
- CloudWatch dashboard
    - Number of invocation within each data point of 5 minutes 
    - Average duration of invocation

Some notes
- CloudWatch logs are stored for 15 months, need to save to S3 if need longer 
- Lambda sends logs to CloudWatch per 1 minute 
- Principle to prevent premature/false alarm by M out of N (the trailing window) <br/>

![111](https://user-images.githubusercontent.com/20411077/155051909-2b1754df-0518-413f-9562-e15edf94ac91.png)

![113](https://user-images.githubusercontent.com/20411077/155051926-3a8972b0-4fd5-45df-a257-f302d412d3ed.png)

## Stack in CDK 
create a lambda function
```
const fn = new aws_lambda.Function(
    this,
    "LambdaCloudWatchAlarmDemo",
    {
    runtime: aws_lambda.Runtime.PYTHON_3_8,
    handler: "index.handler",
    timeout: Duration.seconds(90),
    code: aws_lambda.Code.fromAsset(
        path.join(__dirname, "lambda")
    )
    }
)
```
create cloudwatch alarm
```
const alarm = new aws_cloudwatch.Alarm(
      this,
      "LambdaInvocationAlarmDemo",
      {
        metric: fn.metricInvocations(
          {
            statistic: 'sum',
            period: Duration.minutes(5)
          }
        ),
        threshold: 5,
        evaluationPeriods: 1
      }
    )
```
add alarm action
```
 alarm.addAlarmAction(
      new aws_cloudwatch_actions.SnsAction(aws_sns.Topic.fromTopicArn(
        this,
        "CodePipelineNotification",
        "arn:aws:sns:ap-southeast-1:account_id:CodePipelineNotification"
      ))
    )
```
cloudwatch dashboard
```
// title
dashboard.addWidgets(
      new aws_cloudwatch.TextWidget({
        markdown: `# Dashboard: ${fn.functionName}`,
        height: 1,
        width: 24
      })
    )
// number of invocation
 dashboard.addWidgets(
      new aws_cloudwatch.GraphWidget({
        title: "Invocation",
        left: [fn.metricInvocations(
          {
            statistic: 'sum',
            period: Duration.minutes(1)
          }
        )],
        width: 24
      })
    )
// duration 
 dashboard.addWidgets(
      new aws_cloudwatch.GraphWidget({
        title: "Duration",
        left: [fn.metricDuration()],
        width: 24
      })
    )
```
How to Create a Vue.js App
Tags: vue, javascript, tutorial
Published: 2022-02-22 02:06:26

Open **Command Prompt**

Creating a Folder for Vue.js
```
cd desktop
mkdir "Vue JS"
cd "Vue JS"
```


Creating a Vue.js App
```
npm init vue@latest
```


After executing the command, it will ask you some question about the vue app. 


```
cd <project-name (put your vue app's name)>
npm install
npm run dev
```


Now your have finish creating a Vue.js App. If you want to see the result, just go to http://localhost:3000
How to authentication?
Tags: auth, session, token, jwt
Published: 2022-02-22 02:01:41

---
title: How to authentication?
published: true
description: 
tags: auth,session,token,JWT
series: authentication
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--RlqwldxD--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehd9wcdwrvrn9bu5g4z5.jpg
---

> If you find that it is hard to get my meaning, email me peterlitszo at gmail.com!

Now there mainly have three ways to get the authentication:

* Session.
* Token.
* JWT.

# Session

We get the session like:

* Alice: Hello, Bob, I am Alice, my password is `PaSsWoRd`. (by HTTPS rather than HTTP)
* Bob: OK, let me check check. OK the user named Alice's `hash(password)` is really `HaShEdPaSsWoRd`! So you are must the Alice! I give you the session id: `UniqueSessionId`. hold it next time!
* Alice: Hello, Bob, I want to have some yellow picture! By `UniqueSessionId`.
* Bob: `UniqueSeesionId`? Yes you do have the permission to see the yellow picture! Give you.

After long time, there are many people!!! Bob cannot remember so many people!! He need put those information into his notebook (It means, Bob need put it in disk's database rather than memory, and he need delete those record that out-dated).

> The `UniqueSessionId`, in my opinion, the best way is using UUID.

> Where to put the `UniqueSessionId`? I think put it in cookie is a good idea. Cookie will be carried when browser request.

# Token

We get the token like:

* Alice: Hello, Bob, I am Alice, my password is `PaSsWoRd`. (by HTTPS rather than HTTP)
* Bob: OK, let me check check. OK the user named Alice's `hash(password)` is really `HaShEdPaSsWoRd`! So you are must the Alice! I give you the token: `{username: 'Alice'}, sign('by Bob')`. hold it next time!
* Alice: Hello, Bob, I want to see some yellow picture! By `{username: 'Alice'}, sign('by Bob')`.
* Bob: Let me check, `check({username: 'Alice'}, 'the word only bob know') === sign('by Bob')`. OK you must the Alice. Alice have the permission to see the yellow picture! Give you!

Bob do not need remember those session ID! What a good thing for he! He just need to calculate the function `check`'s value.

# JWT

In my opinion, the JWT **is** token, but with some rule (or protocol) to make sure everyone can deal it, and have scalable power without thinking.
My First Impressions of Dev Community
Tags: discuss, writing, career, beginners
Published: 2022-02-22 01:28:41

As a fresh user of dev.to for couple of days, I saw some posts about current status of dev.to or is it a victim of its own success? People complained about repetitive cheap curated content ranked at top all the time.

**Actually dev.to works as intended**, most user-generated content community has a perceived quality driven by hot trending topics. 

Same things happens to Twitter and Reddit but they are too big and you just don't see it, they have enough content to build personalized feed. Eventually you'll get sick of people keep tweeting about HTML, CSS, JS but you have the option to follow other topics/people.

Same thing doesn't apply to dev.to because this is a niche community with less than 1M users. If you have worked in software development long enough you'll realize that there're not much new or deep things to write about when mostly already covered in official documents.

High quality articles are expensive to produce, rock-star developers write a handful of them in 10 years, professional bloggers or book writers might cross-post a piece of their work here. 

Forget about beginner/intermediate developers writing high quality posts because they don't have enough insights and experiences to elaborate difficult concepts to recognized as quality content. The only good thing they can do are curating content and copy+modify what they know. If they don't do that then dev.to just dead already!

Css-tricks.com has around 10k reasonable good long-form articles and has traffic similar to dev.to. How can dev.to make a break though from here.

The big problem with dev.to is they want to build a **highly-interactive** with **long-form content**  community. Why is that?

- Long form content are limited and hard to mass produce, even with a big userbase.
- Highly interactive site is also impossible when number of posts and users are limited.
- Showing sorted content is harmful, it creates illusion of the whole site quality, visitors feel like that the only good thing they can find at dev.to. Personalized feed doesn't work because of limited content.

To fix above problem dev.to needs to separate discussions with articles, make it looks like a discussion centric community like Github discussions but also maintain a section of curated topic-wise quality articles as a learning source. Dev.to also should hire more technical writers to write less popular topics.

In the end it's all about perceived impression. What if dev.to wants to keep everything the same? I think it's fine if dev.to team happy with current status and want to pivot new products before dev.to declines. This site already reached its peek.

Each site serves it own unique purpose. Combine geeksforgeeks.org content with dev.to comment section will be dope!
SAP Commerce Cloud: 10 Things You Should Know
Tags: coredna, cloud, commerce, cloudskills
Published: 2022-02-22 01:25:16

Today’s online shoppers expect ease, speed, personalization, and reliability wherever they shop - online or in-store.

SAP Commerce Cloud sets out to address these high expectations. We take a deep dive into how the platform works and discover whether or not it’s been successful to meet today’s customers needs.

**Here’s what you’ll learn about SAP Commerce Cloud:**

What is SAP Commerce Cloud?
What does SAP Commerce Cloud do?
1. Omnichannel commerce
2. Product content management
3. Customer experience management
4. Order management
5. Industry-specific features
6. Real-time customer support
How does SAP Commerce Cloud integrate with other software?
How much does SAP Hybris cost?
SAP Commerce Cloud pros
SAP Commerce Cloud cons
SAP Commerce Cloud vs Core dna

**TL;DR: SAP Commerce Cloud pros and cons**


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

**What is SAP Commerce Cloud?**
SAP Commerce Cloud (originally called SAP Hybris) is a cloud-native omnichannel commerce solution for B2B, B2C, and B2B2C companies.

It caters to the unique needs and desires of every customer by delivering personalized experiences from acquisition through to retention, unifying all touchpoints (online, mobile, POS, call center, social, print) on a global scale.

**What does SAP Commerce Cloud do?**
Here is a quick overview of SAP Commerce Cloud capabilities:

1. Omnichannel commerce
Different companies use varied combinations of go-to-market models, which means reaching [customers through multiple and diverse touchpoints](https://www.coredna.com/blogs/multi-channel-selling).

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

This can be incredibly hard to manage, creating complexity and data fragmentation for the seller, lack of personalization and reliability for the customer, and can lead to higher costs for both.

Commerce Cloud aims to solve these issues with modules aimed at both B2B and B2C users.

Core B2C capabilities include an omnichannel, responsive storefront that promotes consistency across all devices, with powerful search functionality and tailored promotions and recommendations to increase customer engagement.

The B2B Accelerator module manages complex B2B relationships through intelligent pricing models, price lists, and quote generation.

Also, through self-service options like “Organization Management,” where customers can define order approval workflows, and “Quote Negotiation”, where customers can request quotes to be reviewed by managers. The checkout has B2B-friendly features like PO number entry, auto-replenish, and the ability to charge an account rather than a credit card.

Read more at [SAP Commerce Cloud: 10 Things You Should Know](https://www.coredna.com/blogs/sap-commerce-cloud)
100 días de código: 75, el comienzo de una nueva semana
Tags: spanish, 100daysofcode, webdev
Published: 2022-02-22 01:12:05

¡Hey hey hey!

Hoy ha comenzado la nueva semana y con ella el análisis de la pasada y las nuevas metas para esta.

Ahora que estoy escribiendo me he dado cuenta que he llegado a cumplir 3/4 del reto y con ello les traigo algunas observaciones sobre el reto...

No es un reto tan complicado si no mas bien una prueba para la capacidad de disciplina que dependiendo de los acontecimientos puede ser difícil seguir, sin embargo se vuelve facil conforme van pasando los días.

Un punto importante es que durante el reto debes conseguir organizarte o seguir una guia de aprendizaje como algún roadmap porque conforme van pasando los días y vas aprendiendo puedes perderte en el camino y no lograr tu meta debido a ello. 

Bien ahora si volvamos al análisis de mi semana anterior

### Metas de la semana anterior
- Aprender Redux
- Terminar el proyecto Finance y añadirle redux
- Seguir practicando para entrevistas

#### Conclusiones
Aunque he logrado practicar para entrevistas y aprender algo de redux realmente siento que aun me falta aprender mucho mas sobre este ultimo y no he logrado terminar el proyecto de finance agregando Redux, me da la sensación de que esta tomándome bastante tiempo para aprenderlo asi que intentare apurar un poco el paso con el.

### Metas de esta semana
- Aprender un poco mas sobre redux y como usarlo con typescript.
- Agregar redux al proyecto finance.
- Aprender un poco de nextjs.
- Aplicar a alguna entrevista.

### Hoy:
- Comencé otro proyecto de practica para comprender y aprender a utilizar redux en un proyecto con react.
- Practique para entrevistas.
- Practique Touch Typing.

Es el comienzo de una semana y espero que para mi y para ti sea genial, ojala tengas mucho éxito con todos tus proyectos y animo!

Hasta la proxima!

Foto cover de [Sarah Dorweiler](https://unsplash.com/@sarahdorweiler?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) en [Unsplash](https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText).
All I Know About Decibel (dB) - Part 2
Tags: dsp
Published: 2022-02-22 00:48:37

As [Part 1](https://dev.to/id120/all-i-know-about-decibel-db-part-1-3970) introduces, we get decibel using the formula

{% katex %} 
l = 10 \times log \frac{p_1}{p_2} (dB)
{% endkatex %}

I'd blame my poor English ability that I didn't realise what the name *decibel* really meant for quite a few years. It's called deci-bel so apparently there's a *Bel* first.



>![Alexander_Graham_Bell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2yicix8q1qssdwu84z7.jpg)
>
> The bel (B) and the smaller decibel (dB) are units of measurement of sound pressure  level (SPL) invented by Bell Labs and named after him
>
> from: [Wikipedia](https://en.wikipedia.org/wiki/Alexander_Graham_Bell)

That's him! As stated, using *deci-*, people can make *bel* smaller, and meanwhile we have to add the {% katex inline %}10 \times {% endkatex %} in the formula, to make *bel* become *decibel*.

You might notice that when talking about voltage and current, the formula becomes

{% katex %}
20 \times log \frac{p_1}{p_2} (dB)
{% endkatex %}

So why 20 here? I was very confused. I asked around and got this answer: For measuring something like a **magnitude**, we use {% katex inline %}20 \times {% endkatex %}, otherwise for the **power** stuffs, use {% katex inline %}10 \times {% endkatex %}... Okay then it's time to test my English again: what kind of thing is a **magnitude**? And what is not? I reckon it's a correct but not so good answer.

Finally I met a guy, he took out a piece of paper and wrote some high school maths on it:

{% katex %}
P=U \times I=U \times (U/R) = U^2 / R 
{% endkatex %}

Yeah that's Ohm's Law, I get it. Then if {% katex inline %}P_r{% endkatex %} and {% katex inline %}U_r{% endkatex %} are the references and {% katex inline %}U{% endkatex %} is the voltage we are measuring, from the original {% katex inline %}10 \times {% endkatex %} formula we have:

{% katex %}
10 \times log (P / P_r) 
{% endkatex %}

{% katex %}
= 10 \times log ((U^2/R)/(U_r^2/R))
{% endkatex %}

{% katex %}
= 10 \times log (U/U_r)^2
{% endkatex %}

{% katex %}
= 2 \times 10 \times log (U/U_r) = 20 \times log (U/U_r)
{% endkatex %}

That's how {% katex inline %}20 \times {% endkatex %} comes up. Same process for the current (Use {% katex inline %}P=I^2 \times R{% endkatex %}). Maths can be scary, but useful.

---

from [OZLab](https://blog.ozlab.io/all-i-know-about-decibel-db-part-2)
Check String If its a number
Tags: javascript, webdev, programming, shortread
Published: 2022-02-22 00:43:53

When checking string if its a number, there are a lot of ways you can check a string if its a number. You can use regex, `isNaN()` function, or a plus operator, or parseInt.

But the best function that we can use is a function called `Number()`.

The `Number()` function converts the argument to a number representing the object’s value. If it fails to convert the value to a `number`, it returns `NaN`.

We can use it with strings also to check whether a given string is a number or not.

```js
console.log(Number('195')) // 195
console.log(Number('boo')) // Nan
```
Reduce in React: The Puzzle of my Last Project
Published: 2022-02-22 00:17:45

For my latest project with the Flatiron School, my partner Dan Beachtold and I worked to make a road trip planning application. This app at it's current state is able to tell you the distance between two locations in miles, how many hours you'll spend driving there, and how much you'll pay in gas. Each trip can be then added to an itinerary, which would give the total for each leg of your journey. This final objective was one of my final jobs in the construction of our application. 

I was a little worried as I had not been taught how reduce worked in React, and had to dive into quite a bit of Google research. Unfortunately, none of the resources I found would give a good answer about how to access the data I needed within the greater data array I was being given. Eventually though I came to a revelation. Every example I was seeing on MDN used an array of JUST the numbers they needed, nothing more. This project didn't require the data to be eventually re-added, so I came to my brute force solution.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79d9xy05doy0rurmaxez.PNG)

First, I created three empty arrays for the information I needed to iterate through. Second, I created a constant which would iterate through the raw itinerary retrieved from the JSON server. This would take each required piece of information and add it to the above arrays. Once I had this information isolated I passed it into a new react component, where it could be reduced.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/231os2tevfw2qrrtzilf.PNG)

Here, the arrays were put through more conventional Reduce functions, which would print the required sum. We then also put the time number through a final function which turned the minutes into a more readable format featuring hours and minutes. 

This could ABSOLUTELY be done more efficiently, but for now it worked perfectly.
Difference between apt, apt-get and apt-cache
Tags: linux, debian, apt
Published: 2022-02-21 23:41:42

APT or Advanced Package Tool is the command line package manager for Debian based Linux distributions.It provides set of tools to search, add, upgrade or remove linux packages.Some of the tools that users mix and match to achieve end goal of package management are `apt`, `apt-get` and `apt-cache`.

#apt

* Recent addition to package management tools list compared to its peers
* Collection of commands for commonly used package management operations making it one stop solution for common operations
* Designed to improve end user experience while working on package management
* More suitable for interactive use than in scripts

#apt-get

* Have more options for package management than `apt`
* Better suited for automation scripts
* Internally used by many GUI based package management tools

#apt-cache

* Displays available information about installed and installable package
* Works on the local cache created by commands such as `apt-get update` or `apt update` hence output of `apt-cache` may be outdated depending on time of the last package update.
* `apt-cache` works in offline mode as its input is local cache 
 
#Which command should I use for package management ?

My personal preference is `apt` as it has easy to remember options usually sufficient for regular package management operations.`apt` also combines commands from `apt-get` and `apt-cache` making it a `One Stop Solution`.

![Command Options with apt, apt-get and apt-cache](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xm5myekvxjdd23z17p2.png)
JAVASCRIPT 102: INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS WITH MODERN JAVASCRIPT

Tags: javascript, webdev, beginners, programming
Published: 2022-02-21 23:23:46

# JAVASCRIPT 102: INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS WITH MODERN JAVASCRIPT

One thing that can be considered almost a given in most interviews is the test of a candidate's appreciation of data structures and algorithms. A good knowledge of what data structure to use in specific problems is what separates elite developers from the rest.

Congrats, on taking your first steps to that elite class.

## ALGORITHMS

Oxford dictionary defines an algorithm as a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer. An algorithm can be seen as a set of structured statements or instructions that dictate the steps to solving a particular problem.

When faced with a problem, a structured way to go about the algorithm is to use a **flow-chart** *(a diagrammatic representation of the steps involved)* or a **pseudo-code** *(a statement of the steps in a near-native language)*. 

Some common algorithms you can practice for interviews include:

### Fizz Buzz
Given a number as an input, print out every integer from 1 to that number. However, when the integer is divisible by 2, print out "Fizz"; when it's divisible by 3, print out "Buzz"; when it's divisible by both 2 and 3, print out "Fizz Buzz".
Reverse String
Required to reverse the order of characters in an input string.

### Palindrome
A palindrome is a word or phrase that reads the same backward as forward. Write a function that checks for this.

## DATA STRUCTURES

Now data structures.

There are a number of data structures that are indispensable to developers when coming up with algorithms or writing solutions to problems. These structures help them attain efficiency without compromising on performance.

I'd be introducing you to some of the basic ones. Here you go.

### Array

An array is an ordered data structure with elements separated by a comma while encapsulated within square brackets. For example, 

```javascript
    var List = ["boy", "girl", "woman"]
```
### Queues

The queue works conversely to a Stack. The difference is laden in the fact that Queue uses the **FIFO principle** *(First In First Out)*. Take for instance, when you queue for a bus, the first in the queue will always board first. Queue has the following methods; **enqueue, dequeue, front, isEmpty, size**.

### Stack

In stacks, the last item to get in the structure is the one that gets pulled first. This is called LIFO just like when you stack CDs on a pile, you can only remove the last stacked CD first.
.Stack has the following methods **push, pop, peek, and length**.

### Linked list.

A linked list is a data structure that imitates a kind of chain linking structure. The first node in the structure is called the **head** and it holds a pointer that connects to the next and the cycle continues till the last node is called the **tail**.