teleren/devto huggingface dataset:
Improving CloudWatch Alarms for Lambda Errors
Tags: aws, serverless, cloudwatch, lambda
Published: 2023-10-04 05:44:03

## A simple solution to improve the CloudWatch alarm to receive Lambda error details by email. Available as CDK construct or as CloudFormation.

AWS CloudWatch is not the best service for monitoring your system. It has a ton of features, but many of them are awkward to use. But at the same time, it is baked into AWS, and you do not have to look for something else. And for a large number of solutions, it is good enough.

One of the not-so-nice things is notifying of Lambda errors. Typically, you would attach an Alarm to the Lambda error metric. The Alarm would send a message to SNS, which would send it to your email or SMS. That is a relatively common way, but not the only one. One benefit of this approach is that you do not get a ton of messages. You just get one for the Alarm being in the error state.

But this notification does not contain any details on an error. **You will have to open the AWS console, find the appropriate log group, open CloudWatch Logs Insights, write a query, and after a few minutes, you will have your error message, which quite possibly is an unimportant one-time occurrence of some timeout.** Of course, you can simplify this process, but wouldn't it be great to get a sample of errors by email? Most of the systems for monitoring and logging, like Sentry, provide that out of the box.

I will present a simple solution for getting error messages by email. It is great for smaller projects when you do not want to configure other error-logging solutions or for older systems where you do not wish to alter them just because of that.

The solution is in two forms:

- **[CDK construct](https://constructs.dev/packages/lambda-error-sns-sender)**  
  If you are building your system with CDK (or [SST](https://sst.dev/)). Available for TypeScript, Java, C#, Python, and Go.
- **[CloudFormation](https://lambda-error-sns-sender.s3.eu-west-1.amazonaws.com/lambda-error-sns-sender.yaml)**  
  For existing solutions, so you do not have to modify them. You deploy and point to the existing SNS used for CloudWatch alarms.

How does it work?

1. **Lambda is subscribed to the SNS topic where you receive your alarms.** There is a message body subscription filter that limits errors based on the Lambda error metric. You must change the filter if you defied your metric in some other way, not the default one.
1. **Lambda analyzes the message**, finds a log of the failed Lambda, and queries the log group for the period that the metric was configured, plus some additional safety time, so we do not miss that error message. It extracts just a number of errors that can fit in one SNS message.
1. **Lambda sends errors to the same SNS** that you use for alerts. So, apart from the Alarm message for changing the error state, you will receive an additional one with detailed error messages.

![lambda-error-sns-sender](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wh3twrdhnqnc9htx13xf.png)

**[Continue reading on www.serverlesslife.com…](https://www.serverlesslife.com/Improving_CloudWatch_Alarms_for_Lambda_Errors.html)**
10 Essential WordPress Plugins Every Website Needs
Tags: webdev, wordpress, website
Published: 2023-10-04 05:10:26




Introduction:
WordPress is one of the most popular content management systems (CMS) in the world, and for good reason. Its flexibility and ease of use make it a go-to choice for website owners and bloggers alike. One of the reasons behind WordPress's popularity is the vast array of plugins available, which can enhance the functionality and features of your website. In this blog post, we'll explore 10 essential WordPress plugins that every website needs to thrive.

Yoast SEO:
Search engine optimization (SEO) is crucial for driving organic traffic to your website. Yoast SEO is a powerful plugin that helps you optimize your content for search engines, ensuring your website ranks well in search results.

Akismet Anti-Spam:
Spam comments can clutter your website and harm your reputation. Akismet is a top-notch anti-spam plugin that filters out spammy comments and keeps your site clean.

W3 Total Cache:
Website speed is a critical factor for user experience and SEO. W3 Total Cache helps improve your site's performance by caching static files and reducing load times.

Wordfence Security:
Security is paramount for any website. Wordfence Security is a comprehensive plugin that protects your site from threats, monitors traffic, and scans for malware.

UpdraftPlus:
Regular backups are essential to safeguard your website against data loss. UpdraftPlus simplifies the backup process, allowing you to schedule automatic backups and store them in the cloud.

WPForms:
Creating user-friendly forms is a breeze with WPForms. Whether you need contact forms, surveys, or order forms, this plugin makes it easy to build and manage them.

MonsterInsights:
Understanding your website's traffic and user behavior is crucial for making informed decisions. MonsterInsights integrates Google Analytics into your WordPress dashboard, providing insightful data.

WooCommerce:
For e-commerce websites, WooCommerce is a must-have plugin. It transforms your site into a powerful online store, allowing you to sell products or services with ease.

Sucuri Security:
Sucuri Security offers robust website security features, including a web application firewall, malware scanning, and monitoring, to keep your site safe from online threats.

Smush:
Images play a significant role in web design, but large image files can slow down your site. Smush optimizes and compresses images automatically, enhancing page speed without compromising quality.

Conclusion:
WordPress plugins are essential tools for enhancing the functionality and security of your website. These 10 essential plugins cover a wide range of needs, from SEO and security to performance and e-commerce. By incorporating these plugins into your WordPress site, you'll be well-equipped to create a more powerful and user-friendly website that stands out in the digital landscape.
Reverse Proxy Nginx Ubuntu 20.04
Tags: nzucode, nginx, ubuntu, proxy
Published: 2023-10-04 05:07:42

#### Requirement

- Web Server Running (Apache2 on IP `10.10.10.1:80`)
- Reverse Proxy (Nginx on IP `10.10.10.2`)

#### Assumption

Di asumsikan sudah ada web server yng berjalan. Pada contoh disini web server berjalan pada IP `10.10.10.1:80`.
Reverse Proxy Server akan di jalankan di VM atau Server yg berbeda dengan IP `10.10.10.2`.

#### Installation

Install Nginx

```
apt install nginx
```
Unlink `default` config nginx

```
unlink /etc/nginx/sites-enabled/default
```
Buat file `reverse-proxy.conf` pada `/etc/nginx/sites-availible`

```
touch /etc/nginx/sites-available/reverse-proxy.conf
```
isikan dengan konfigurasi berikut:

```
server {
    listen 80;
   # listen 443 ssl;
    server_name www.domain.com;
    access_log /var/log/nginx/reverse-proxy-access.log;
    error_log /var/log/nginx/reverse-proxy-error.log;
   # ssl on;
       # include snippets/ssl-defaults.conf;
       # include snippets/proxy-defaults.conf;

    location / {
        #Set header Proxynya
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Accept-Encoding "";

         #Tujuan permintan diteruskan
        proxy_pass http://10.10.10.1/;
    }
}

```
Kemudian buat permalink file `reverse-proxy.conf` pada `sites-enabled`.

```
ln /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/reverse-proxy.conf
```
Cek apakah konfigurasinya sudah benar

```
nginx -t
```

Restart nginx dan set `enable` agar autostart

```
systemctl restart nginx
```

```
systemctl enable nginx
```
Lakukan uji coba dengan mengakses IP server reverse proxy, jika sesuai harusnya yg akan tampil adalah web server pada server 1.
Selamat mencoba
Ionic 7 + React Project Setup and Android Studio Live Reload and Debug on Real Device
Tags: ionic, react, tutorial, javascript
Published: 2023-10-04 04:57:25

- Install Ionic CLI

```bash
$ npm i -g @ionic/cli 
```

- Run this command to scaffold project

```bash
$ ionic start my-app tabs --type=react --capacitor
```

- Install android studio latest version. [link here](https://developer.android.com/studio)

- cd into your ionic project and run these command for android environment

```bash
$ ionic build
$ ionic cap add android
$ ionic cap open android
```

It will build your app and setup the android environment also open the android studio.

- If it's your first time downloading android studio, then it will download the necessary resources first automatically.

- When the installation is done and nothing is going wrong, then press the play button on the navbar or press `Shift + F10`

- [Install JDK 20](https://download.oracle.com/java/20/latest/jdk-20_windows-x64_bin.zip)

- extract JDK

- Set environment variable for JAVA_HOME targeting the JDK directory

- Run this command for live reload on android studio and on browser

```bash
$ ionic cap run android -l --external
```

## Run on Real device (Android)

- Download and install ADB. [link](https://developer.android.com/tools/releases/platform-tools)

- Extract adb

- Create an environment Path variable targeting the extracted adb directory

- Enable developer mode on your phone and enable USB debugging. [docs](https://developer.android.com/studio/debug/dev-options)

- Connect your phone to your pc and run adb from command prompt. If there's a popup in your phone asking to allow access from PC, then allow it.

- Finally run this command to install debug version of the apk on your phone

```bash
$ ionic cap run android -l --external
```
assigning the result of this type assertion to a variable (switch value := value.(type))
Tags: go, beginners, tutorial
Published: 2023-10-04 04:44:18

assigning the result of this type assertion to a variable (switch value := value.(type)) could eliminate type assertions in switch cases

![warning message code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1fg679odd9xz6cwvfq4j.png)
```
package main

import "fmt"

func main() {
	values := []interface{}{1, "two", 3.0}

	for _, value := range values {
		switch value.(type) {
		case int:
			v := value.(int)
			fmt.Printf("%d is an integer\n", v)
		case string:
			v := value.(string)
			fmt.Printf("%s is a string\n", v)
		case float64:
			v := value.(float64)
			fmt.Printf("%f is a float\n", v)
		default:
			fmt.Println("Unknown type")
		}
	}
}

```
**Change to this**

![correct version of code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5zhv35kadfn4n0lqnnd.png)

```
package main

import "fmt"

func main() {
    values := []interface{}{1, "two", 3.0}

    for _, value := range values {
        switch v := value.(type) {
        case int:
            fmt.Printf("%d is an integer\n", v)
        case string:
            fmt.Printf("%s is a string\n", v)
        case float64:
            fmt.Printf("%f is a float\n", v)
        default:
            fmt.Println("Unknown type")
        }
    }
}
```
In this example, we have a slice of empty interfaces ([]interface{}) containing values of different types. We use a for loop to iterate through the values, and within the loop, we use a type assertion in the switch statement to determine the actual type of each value and perform different actions based on the type.

By using the type assertion (value.(type)), we can access the underlying type of value without the need for separate type assertions for each case. This makes the code more concise and eliminates the need for repetitive type checks.
Typescript enum vs. "as const"
Tags: ts, typescript, enum, asconst
Published: 2023-10-04 04:21:09

---
title: Typescript enum vs. "as const"
published: true
description: Truly an incredible waste of time
tags: ts, typescript, enum, asconst
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-10-04 03:59 +0000
---

This is not a post where you learn anything. For those who want to learn, please see yourself to the exit. For those looking for unadulterated opinions from an old man yelling at clouds, then you've come to the right place.

This whole enum vs. "as const" debate is incredibly tedious and has done nothing except to further the social stock of pedants in the Typescript blogosphere. Because of this "debate" every few weeks I'm forced to opine about which one a like more or which one would fit better or which one is "bad" or which is convention, etc. The list of minor reasons goes on and on and talking about it really feels like discussing where we'd like certain grains on sand on the beach to be. A.K.A. I don't care.

Now it's not to say that people don't do this with the best of intentions. I get it, you want the code to be readable, refactorable, etc. And for this, you should be lauded. Too many times, I've seen code that is truly a nightmare because the people writing it didn't have time or didn't care enough to put some thought into it. But...I've got to say, spending days discussing how best to write a switch-statement will not move the ball as much as you think it will and most of this energy can be put towards bigger questions.

## Conclusion

Typescript team, if you're listening, the truth is I don't know how to fix this. If the solution were easy, there wouldn't be [> 300 issues on Github](https://github.com/microsoft/TypeScript/issues?q=is%3Aissue+is%3Aopen+enum). But dear god, please do something and release me from these boring conversations.
Crafting An Awesome README
Published: 2023-10-04 03:28:13

A professionally written Readme file will alleviate your project's readers and developers’ headaches. Before you give a presentation or chat about the project, a readme presents it to the audience.
Every readme file you publish has a md extension because a readme is written in a basic language termed markdown, which makes formatting and editing a breeze. A well-written readme can make the difference between your project being recognized by the development community as a gem or a superstar. The secrets of creating a readme that not only attracts attention but also keeps users and other developers informed and enthusiastic about your project are revealed in this article. 
Important components and pointers for making a README juicy:

1. Title and Summary
    Start with a title that is simple and obvious (the unheard 
    tune).
2. The table of contents.
    This applies to lengthy README files; for easier browsing, you 
     should think about incorporating a table of contents with 
     links 
   to different sections.
3. Instructional manuals:

    a. Provide step-by-step instructions for installing your 
        project's prerequisites or dependencies. 
    b. To make the installation process simpler to understand, use 
       code snippets or terminal commands.
4. Usage:
     a. Describe the usage of your project. Include illustrations, 
        samples of code, and perhaps screenshots.
     b. Discuss any advanced features as well as fundamental use 
         cases.
5. Contributing: 
         a. Explain how to file pull requests, report issues, and 
           adhere to code standards.
         b. Promote participation in your project by laying 
             forth the requirements.
6. License: 
       Indicate the license that your project is distributed 
      under. This is essential for moral and legal reasons.


A great README should be organized clearly, targeted at the right audience, and short. Common questions should be addressed, making it simple for users to get started, and fostering confidence in your project.
Using Prism with Next.js
Published: 2023-10-04 03:20:32

Prism is a popular syntax highlighter commonly used with Markdown. This example shows how to use Prism with Next.js. Use the theme dropdown in the header to switch syntax highlighting themes.

Next.js uses getStaticPaths/getStaticProps to generate static pages. These functions are not    bundled client-side, so you can write server-side code directly. For example, you can read Markdown files from the filesystem (fs) – including parsing front matter with gray-matter. For example, let's assume you have a Markdown file located at docs/my-post.js.

We can retrieve that file's contents using getDocBySlug('my-post').

// lib/docs.js

```

```
import fs from 'fs';
import { join } from 'path';
import matter from 'gray-matter';

const docsDirectory = join(process.cwd(), 'docs');

export function getDocBySlug(slug) {
  const realSlug = slug.replace(/\.md$/, '');
  const fullPath = join(docsDirectory, `${realSlug}.md`);
  const fileContents = fs.readFileSync(fullPath, 'utf8');
  const { data, content } = matter(fileContents);

  return { slug: realSlug, meta: data, content };
}
Then, we can transform the raw Markdown into HTML using remark plugins.

// lib/markdown.js

import { remark } from 'remark';
import html from 'remark-html';
import prism from 'remark-prism';

export default async function markdownToHtml(markdown) {
  const result = await remark()
    // https://github.com/sergioramos/remark-prism/issues/265
    .use(html, { sanitize: false })
    .use(prism)
    .process(markdown);
  return result.toString();
}
Passing the content returned by getDocBySlug('my-post') into markdownToHtml(content) would convert a Markdown file like this:

---
title: 'My First Post'
description: 'My very first blog post'
---

# My First Post

I **love** using [Next.js](https://nextjs.org/)

```js
const doc = getDocBySlug(params.slug);
```
into this HTML, which includes the proper elements and class names.

<h1>My First Post</h1>
<p>I <strong>love</strong> using <a href="https://nextjs.org/">Next.js</a></p>
<div class="remark-highlight">
  <pre class="language-js">
    <code>
      <span class="token keyword">const</span> doc <span class="token operator">=</span> <span class="token function">getDocBySlug</span><span class="token punctuation">(</span>params<span class="token punctuation">.</span><span class="token property-access">slug</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    </code>
  </pre>
</div>
Deploy Your Own
View the source code and deploy your own. You can add new Markdown files to docs/ and see them live instantly!
I decided to leave a review about Cashfx pocket option and other brokers
Published: 2023-10-04 02:46:59

I decided to leave a review about Cashfx, because this might be helpful. I invested about $67,000 into this platform with the aim of diversifying my trading portfolio. However, with my strict habits of growing my account 100% before taking profits, I never attempted any withdrawals, not until two months when I tried to withdraw but all effort was in vain. I called the account manager and explained the situation, he told me I would be able to withdraw after 4 working days which sounded shady to be very honest. 4 days went by, still no withdrawals. I did research about recovery tech and came across Frecuperation. They are best in dealing with online scam and assisting victims in receiving reimbursement, tracking down digital fingerprints, cyber analysis and thorough investigation. They can be contact on email support@frecuperation.online
Web3 Space ID's Name SDK
Tags: webdev, web3, tld, dns
Published: 2023-10-04 01:42:41

The SPACE ID created a Name Service protocol and SDK, so that people could register their Web3 TLD in their registry.  

https://docs.space.id/developer-guide/web3-name-sdk 

This should be an internal arrangement for registering TLDs according to their own protocol. That is, the UI is not needed. For personal use by one person. Could you do this for me? Anyone? BTW.. Web3 domain, NFT domain, Crypto   domain, Blockchain domain.. all of them is same thing! We call it Token Domain, or just tDomain. But here we are talking about TLD only.
2023 Hacktoberfest Pledge
Tags: hacktoberfest23
Published: 2023-10-04 01:14:47


### Intro
Hey there! 👋 I'm Ansell Maximilian, and I'm excited to be part of Hacktoberfest 2023! I am primarily a web developer, and my tech stack revolves around React, Tailwind CSS, and JavaScript in general.

### Background
This isn't my first rodeo with Hacktoberfest – in fact, it's my second! Two years ago, I participated for the first time and set some ambitious goals for myself. I'm proud to say that I not only met those goals but also had a fantastic time collaborating with the open-source community. I learned so much and had a blast doing it. It was an incredible experience that left me hungry for more. Unfortunately, due to the demands of life and other commitments, I couldn't participate in 2022's Hacktoberfest. I hope I can remedy that this year.


### Pledge
For Hacktoberfest 2023, I'm taking a pledge to push myself even further. My goal is clear: I want to replicate the success of my previous Hacktoberfest and contribute to open source once again. This means not only submitting pull requests but also engaging with maintainers and fellow contributors to make meaningful contributions that truly benefit the projects I work on.
Day 2: Delving Deeper into LLMs & Refreshing Machine Learning Basics
Tags: machinelearning, beginners, datascience, ai
Published: 2023-10-04 01:02:05

The journey continues, and today was all about unraveling the intricacies of Large Language Models (LLMs) and brushing up on some good ol' machine learning practices using Python.

![Image description](https://media.tenor.com/ixtUKavels0AAAAM/learning-learnding.gif)

**Demystifying the Hype around LLMs:**

Today, I wrapped up the 'Introduction to Large Language Models' on Coursera. One realization? The hype is real! LLMs are powerful, transformative, and truly at the cutting edge of AI. What stood out to me was how Google's Vertex AI isn't just another platform—it's a holistic solution. From AI solutions to search functionalities, conversations, over a 100 foundational models, and a seamless AI platform, Vertex AI seems poised to change the game.

**Back to the Basics with Python:**

Switching to Codecademy, the Machine Learning/AI Engineer Career Path took me on a nostalgic journey through Python. Implementing machine learning using Python felt like reuniting with an old friend. The exercises and challenges were a delightful mix of refreshment and new perspectives. The beauty of Python and its powerful libraries never cease to amaze me!

**Final Thoughts for the Day:**

While it's tempting to rush through the courses, I'm consciously taking the time to grasp, reflect, and practice. Every new lesson is a step closer to mastering AI, and I'm here for the long haul.

Day 2 was a blend of new insights and revisiting core principles. The adventure rolls on, and I'm eager to see where Day 3 takes me.

Stay with me, folks! There's much more to come.

**Onto Day 3!**