teleren/devto huggingface dataset:
Day 78: Web Storage
Tags: webdev, frontend, 100daysofcode, html
Published: 2023-10-31 17:01:27



### 🌐 What is the Web Storage API?

The Web Storage API comprises two mechanisms: `localStorage` and `sessionStorage`. These are ways to store key-value pairs in a web browser. 

- `localStorage`: Offers persistent storage that persists even after the browser is closed and reopened. Data stored here remains until explicitly removed by the application or the user.
- `sessionStorage`: Provides session-based storage where data persists for the duration of the page session. Once the user closes the tab or browser, the data is cleared.

### Basic Usage:

```javascript
// Storing data in localStorage
localStorage.setItem('key', 'value');

// Retrieving data from localStorage
const value = localStorage.getItem('key');

// Removing data from localStorage
localStorage.removeItem('key');
```

### Advantages of Web Storage API:

1. **Simple Interface**: Offers an easy-to-use key-value pair storage system.
2. **Large Storage Capacity**: Allows for more significant data storage compared to cookies.
3. **Better Security**: Data stored in the Web Storage API is not transmitted to the server with every HTTP request, enhancing security.

### Tips

1. **Data Serialization**: Objects can be stored by serializing them using `JSON.stringify` and deserialized using `JSON.parse`.
2. **Error Handling**: Always handle exceptions when working with Web Storage to prevent the application from crashing due to storage limitations or security issues.
3. **Clear Outdated Data**: Regularly clear unused or outdated data to optimize storage and maintain efficiency.

### Best Practices:

1. **Encrypt Sensitive Data**: If storing sensitive information, consider encrypting it before saving it in the Web Storage.
2. **Graceful Degradation**: Always ensure your application gracefully handles scenarios where Web Storage may not be available or accessible.
3. **Consistent Data Structure**: Maintain a consistent structure for stored data to ease retrieval and manipulation.

### Comparing Web Storage Options:

Here's a comparison between `localStorage` and `sessionStorage`:

| Feature         | `localStorage`                    | `sessionStorage`               |
|-----------------|----------------------------------|------------------------------|
| **Scope**       | Origin-specific                    | Tab or window-specific        |
| **Persistence** | Survives browser close              | Cleared at the end of session |
| **Storage**     | Larger storage capacity            | Limited storage capacity       |
| **Accessibility**| Accessible from any window/tab     | Accessible only within the tab |
| **Security**    | Relatively secure                  | More secure                    |
| **Expiration**  | Does not expire unless cleared    | Cleared when the session ends |
| **Usage**       | Long-term data storage             | Short-term data storage        |
Applying the Power of Machine Learning for Data and Analytics
Published: 2023-10-30 23:40:01

**1. Introduction**

Data analytics is the process of examining data to uncover insights and make informed decisions. Machine learning is a subset of artificial intelligence that empowers data analytics by automating predictions based on data patterns.

**2. What is Machine Learning?**

Machine learning is a technology that enables computers to learn and make predictions or decisions without being explicitly programmed. It's divided into three main types: supervised learning, unsupervised learning, and reinforcement learning.

**3. Data Collection and Preprocessing**

Quality data is essential for machine learning. Data preprocessing includes cleaning and preparing the data for analysis.


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

**4. Supervised Learning**

Supervised learning is used for tasks like classification and regression. It involves using labeled data to train a model.


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

**5. Model Evaluation**

To understand how well your model performs, you can use evaluation metrics like accuracy, which measures how often the model is correct.


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

**Conclusion**

Machine learning is a powerful tool that can enhance your data analytics efforts. By understanding its basics and applying it to your data, you can make more accurate predictions and gain valuable insights.
Hướng Dẫn Đăng Ký V99 Siêu dễ dàng
Published: 2023-10-31 03:11:08

Hướng Dẫn Đăng Ký V99 Siêu dễ dàng
Đăng ký #V99co đơn giản và nhanh chóng
Đăng ký #v99.com hưởng chương trình khuyến mãi đặc biệt dành cho thành viên mới
Ưu đãi lên đến 200% giá trị số tiền bạn đã nạp ban đầu
Nhanh tay đăng ký #v99  trải nhiệm chơi game nhận ngay ưu đãi
Chi Tiết Đăng Ký CMT
Web: https://v99.com.co/dang-ky-v99/
Fanpage: https://www.facebook.com/v99comco
Mail: v99comco@gmail.com
Địa chỉ: 157 Ng. 86 P. Hào Nam, Chợ Dừa, Đống Đa, Hà Nội, Việt Nam
Sđt: 09453077445
**#v99 #v99comco #codeV99**
netty5: Channel, ChannelPipeline and ChannelHandler
Tags: netty, java
Published: 2024-03-04 11:40:34

This post is based on the source code of netty-5.0.0.Alpha5.

# Channel

When making a network connection, **new instance** will be created.

Channel contains:
- IP address and port of destination
- EventLoop instance which serves this channel
- ChannelPipeline instance which stores series of Channelhandler
- function of operations can act on it

Channel.pipeline().fireChannelRead(Buffer) will be called when data is read from network layer.

Reference of Channel may be passed into user logic code, for sending reply first call Channel#isActive to check if that channel is active or not. Then call Channel#write or Channel#writeAndFlush.

# ChannelPipeline

When creating a new *Channel*, a new *ChannelPipeline* instance is also created. On the fly modification of *ChannelHandler* in *ChannelPipeline* without affecting other *ChannelPipeline* is supported (One of the use cases is to switch to TLS session after an unencrypted session is created in StartTLS protocol).

ChannelHandler(s) which handle application logic are added during ChannelPipeline initialization. To use Bootstrap class as example,

```java
Bootstrap b = new Bootstrap();
b.handler(new ChannelInitializer<DatagramChannel>() {
  @Override
  protected void initChannel(DatagramChannel ch) {
    ChannelPipeline p = ch.pipeline();
    p.addLast(new DatagramDnsQueryEncoder())
      .addLast(new DatagramDnsResponseDecoder())
      .addLast(new SimpleChannelInboundHandler<DatagramDnsResponse>() {
        @Override
        protected void messageReceived(ChannelHandlerContext ctx, DatagramDnsResponse msg) {
          try {
            handleQueryResp(msg);
          } finally {
            ctx.close();
          }
        }
      });
  }
});
```

On *ChannelPipeline* implementation *DefaultChannelPipeline*, there is two lists of *ChannelHandlerContext*.

- handlers: *DefaultChannelHandlerContext* list, use for instance lookup
- head: first element (always HeadHandler) of DefaultChannelHandlerContext double linked list. First ChannelHandler processing bytes from network layer
- tail: last element (always TailHandler) of DefaultChannelHandlerContext double linked list. First ChannelHandler processing objects from from application

Functions of ChannelHandlers in the chain are run in the same *EventExecutor*.

# ChannelHandler

Code in *ChannelHandler* can be run in different *EventExecutor* at the same time. So make sure that the class is thread safe.

A *ChannelHandlerContext* instance, will be passed as parameter when function of this interface is called. For example
 
```java
Future<Void> write(ChannelHandlerContext ctx, Object msg);
```

*ChannelHandlerContext* contains:
- *Channel*
- *ChannelHandler*
- *ChannelPipeline*

Do not include processing expensive jobs or using blocking functions in any function of *ChannelHandler*.

When calling Channel#write, message will be go to the beginning of  ChannelPipeline. But when calling ChannelHandlerContext#write, message will be go to next ChannelHandler.

# Reference
https://www.youtube.com/watch?v=_GRIyCMNGGI
Today I learned - HTTP Requests
Published: 2023-10-31 20:24:10

Today I learned about HTTP requests and completed the Umbrella project. HTTP requests are the fundamental unit of web applications. The request is sent from the client to the server, which responds to the request. The request line is the first line of the HTTP request and contains three parts: the verb, the resource path, and the HTTP version. The status line is the first line of the response and contains the HTTP version, the status code, and the reason phrase. Ruby has useful libraries for placing HTTP requests.
[AWS] How To Query CloudWatch Logs Using Amazon Athena
Tags: cloudwatchandathena, cloudwatch, athena, aws
Published: 2023-12-29 07:48:59

---
title: [AWS] How To Query CloudWatch Logs Using Amazon Athena
published: true
date: 2023-04-03 19:23:14 UTC
tags: 
- CloudWatchAndAthena
- CloudWatch
- Athena
- AWS
canonical_url: https://www.kmp.tw/post/howtoquerycloudwatchlogsusingamazonathena/
---


# Situation

### Integration Cloud Watch & Amazon Athena

<!--more-->

## Step 1 : Add Athena Data Source
![img01](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena01.png)

### Choice Amazon CloudWatch Logs
![img02](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena02.png)

### Enter Source Name And Click Create Connector Lambda Function

![img03](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena03.png)

### In Application Settings, Enter Your `Bucket Name` To SpillBucket, Then Click Deploy
![img04](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena04.png)
![img14](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena14.png)


![img05](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena05.png)


### Go Back To Athena Page, And Click Next
![img06](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena06.png)

### After Review, Click Create Data Source
![img07](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena07.png)
![img08](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena08.png)
## Step 2 : Create WorkGroup
### Enter WorkGroup Name, Choice Engine Type.
![img09](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena09.png)


### In Query Edit Console, Add Query Result Bucket And Click Save.
![img10](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena10.png)
![img11](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena11.png)


## Step 3 : Go To Athena Edit Page, Enter Query & Run That.
![img12](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena12.png)
![img13](https://img.kmp.tw/HowToQueryCloudWatchLogsUsingAmazonAthena13.png)
Flask Demo posting
Published: 2023-11-01 10:18:44

# Creating a RESTful API with Flask: GET and POST Methods

In this article, we'll explore how to create a RESTful API using the Flask web framework in Python. We'll focus on two essential HTTP methods: GET and POST.

## Prerequisites

Before you start, make sure you have the following installed:

- Python: You'll need Python installed on your system.
- Flask: You can install Flask using `pip install Flask`.

## Setting Up Your Flask Application

Start by creating a new directory for your project and a Python file (e.g., `app.py`) to hold your Flask application.

```
# Import the Flask module
from flask import Flask, request, jsonify

# Create a Flask app
app = Flask(__name__)

# Dummy data for demonstration
data = []

# Define a route for the root URL
@app.route('/')
def hello_world():
    return "Hello, World!"

# GET Method
@app.route('/api/data', methods=['GET'])
def get_data():
    return jsonify(data)

# POST Method
@app.route('/api/data', methods=['POST'])
def add_data():
    new_item = request.json  # Get JSON data from the request body
    data.append(new_item)   # Append data to the list
    return jsonify({"message": "Data added successfully!"})

if __name__ == '__main__':
    app.run(debug=True) 
   ```
Convert HTML to Markdown (md)
Tags: html, markdown, javascript, node
Published: 2023-11-01 14:25:01

HTML and Markdown are both lightweight markup languages used to create formatted text. HTML is more complex and widely used, but Markdown is simpler and easier to read and write.

Download the Github repo: https://github.com/myogeshverma/convert-html-markdown

```JS
const { NodeHtmlMarkdown } = require("node-html-markdown");
const glob = require("glob");
const { promisify } = require("util");
const fs = require("fs");
const fsExtra = require("fs-extra");

const readFileAsync = promisify(fs.readFile);
const writeFileAsync = promisify(fs.writeFile);

const nhm = new NodeHtmlMarkdown(
  /* options (optional) */ {},
  /* customTransformers (optional) */ undefined,
  /* customCodeBlockTranslators (optional) */ undefined
);

const fileDirectory = "PATH TO YOU FOLDER with name ConfluencePages";
(async () => {
  try {
    const getDirectories = function (src, ext) {
      return glob.sync(`${src}/**/**/*.${ext}`);
    };

    const allFiles = getDirectories(fileDirectory, "html");

    for (const iterator of allFiles) {
      const data = await readFileAsync(iterator, "utf8");
      const content = nhm.translate(data);
      const localPath = iterator.replace(
        "ConfluencePages",
        "ConfluencePagesMD"
      );

      const dirPath = localPath.split("/");
      dirPath.pop();

      fsExtra.ensureDir(dirPath.join("/"), (err) => {
        console.log("fsExtra.ensureDir ~ err:", err)
      });
      
      writeFileAsync(
        `${localPath.substring(0, localPath.length - 5)}.md`,
        content,
        (err) => {
          if (err) {
            console.error(err);
          }
          console.log("file written successfully");
        }
      ).catch((err) => {
        console.log("writeFileAsync ~ err:", err);
      });
    }
  } catch (err) {
    console.error(err);
  }
})();

```
Venous Insufficiency
Tags: vascularheallth, venousinsufficiency, health
Published: 2023-11-02 07:31:32

[Venous insufficiency](https://elitevs.com/venous-insufficiency-causes-signs-and-symptoms-treatment/) is a vascular condition affecting the veins in the legs, disrupting the flow of blood back to the heart. Weakened or damaged valves in the veins allow blood to pool, leading to symptoms such as swelling, pain, and varicose veins. While often associated with aging, venous insufficiency can affect people of all ages. It may be caused by genetics, prolonged sitting or standing, obesity, or pregnancy. Recognizing early signs is crucial for timely intervention. Treatment options range from lifestyle changes and compression therapy to minimally invasive procedures, enhancing circulatory health and relieving symptoms for a better quality of life.
Placeholder Maintainer
Tags: hack23maintainer
Published: 2023-11-02 12:58:20

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a maintainer. Is this your first Hacktoberfest, or have you maintained in others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Project
<!-- Tell us about the repository that you hosted. What processes did you set up to review and merge pull requests? Feel free to embed your GitHub repo by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your project goals changed since publicly maintaining it? -->
Placeholder Maintainer
Tags: hack23maintainer
Published: 2023-11-02 17:15:57

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a maintainer. Is this your first Hacktoberfest, or have you maintained in others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Project
<!-- Tell us about the repository that you hosted. What processes did you set up to review and merge pull requests? Feel free to embed your GitHub repo by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your project goals changed since publicly maintaining it? -->
MarketRacoon - Investment tracking made easy!
Tags: stocks, cryptocurrency, investmentmanagement
Published: 2023-11-03 00:24:52

MarketRacoon was born with the idea of consolidating all your investment data into a single, simple, UX-friendly software-as-a-service (SaaS) product so you can easily understand how your personal finance planning is progressing.

Take control of your financial investments with MarketRacoon as your trusted companion! Join us today.

https://marketracoon.com
Best Digital Marketing Company in india
Published: 2023-11-03 11:14:10

We at [DigiAvenir](https://digiavenir.com/) are passionate about assisting companies in thriving in the digital environment. We offer creative solutions that help our clients achieve their goals by leveraging our skills in website building, digital marketing, and market research. Our mission is to strengthen your brand, improve your online presence, and gain a firm foothold in the ever changing digital landscape.
Sales Data Analytics: The Power of Data-driven Marketing Strategies
Published: 2023-11-03 13:21:24

Using sales data analytics can maximize your business revenues in many ways.

Most companies want to leverage [big data analytics](https://www.bluent.com/business-services/data-analytics/) for sales and marketing benefits besides using advanced BI and automation tools.

A recent survey says that the global sales analytics software market is set to increase from US $4.1 billion in 2022 to US $12.3 billion in 2032, at a CAGR of 11.62%.

From sales professionals to marketing enthusiasts, data-driven sales analysis lets professionals know more about their target audience, competitors, and upcoming market changes.

If you want to boost your sales and profits, then big data can help you refine your marketing strategy and decision-making.

Want to use the power of sales and marketing data for high revenues? Go through this blog and understand how sales analytics can transform your business in detail.

**What is Sales Data Analytics?**

Have you ever wondered how only a few brands achieve overnight success while many fail to do so? What makes their marketing campaigns so precise while targeting the audience? How do their sales teams manage to generate whopping revenues out of conversions?

Being a marketer or a sales executive, you must have similar questions in mind while encountering the success stories of your competitors.

Source by: [https://www.bluent.net/blog/sales-data-analytics-guide/](https://www.bluent.net/blog/sales-data-analytics-guide/)
Await Tuples Directly
Tags: csharp, dotnet
Published: 2023-11-03 22:49:06

Imagine if you could write code like this:

```csharp
var task1 = CountAsync();
var task2 = GetMessageAsync();

// How to await tuples directly!?
var (count, message) = await (task1, task2);
// or even this:
var (count, message) = await (CountAsync(), GetMsgAsync());
```

This would allow you to **await multiple asynchronous tasks** in a **single line** of code, without using `Task.WhenAll` or `Task.WhenAny`. How cool is that?

Unfortunately, this is not possible in C# as it is. A `Tuple` is not an awaitable type, and you cannot use the `await` keyword on it. Does that mean we have to give up on this idea? NO!

We can make it happen by using the power of **extension methods**.

You may already know that in C#, you can **await any object** that has a `GetAwaiter` method that returns a `TaskAwaiter`. This means that we can add an extension method called `GetAwaiter` to tuples and make them awaitable.

```csharp
public static TaskAwaiter<(T1, T2)> GetAwaiter<T1, T2>(this (Task<T1>, Task<T2>) tuple)
{
  async Task<(T1, T2)> UnifyTasks()
  {
    var (task1, task2) = tuple;
    await Task.WhenAll(task1, task2);
    return (task1.Result, task2.Result);
  }
  
  return UnifyTasks().GetAwaiter();
}
```

That's it, all done!

Now you can easily await on tuples. To make it available on all types of tuples and enumerables, I've written this library on [GitHub](https://github.com/mehrandvd/EasyAsync/tree/main). 

All you need is to install [EasyAsync](https://www.nuget.org/packages/EasyAsync) Nuget package:
```powershell
Install-Package EasyAsync
```
Simplexity Personal & Blog multipage theme.
Tags: webdev, tailwindcss, astroj
Published: 2023-11-04 09:13:43

Simplexity ⏤ Personal & Blog multipage theme.
Built with Astro, Tailwind CSS

See it live and learn more.  
→ https://lexingtonthemes.com/info/simplexity

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r14gbeem3u8r27ssxev5.png)
Javascript [array methods] - slice, splice
Published: 2023-11-05 02:11:31

```TS
const items: any[] = [0,1,2,3,4,5]
/* syntax
slice()
slice(start)
slice(start, end)
*/

console.log(`
from3: ${items.slice(3)}
from2To4: ${items.slice(2,4)}
all: ${items.slice()}
`)

/*
splice(start)
splice(start, deleteCount)
splice(start, deleteCount, item1)
splice(start, deleteCount, item1, item2)
splice(start, deleteCount, item1, item2, …, itemN)
*/

items.splice(4,0,"X")
console.log(`insert in index 4: ${items}`)
items.splice(1,1,"Y")
console.log(`replace in index 1: ${items}`)
items.splice(7,0,"i1","i2", "i3")
console.log(`added at the end: ${items}`)
```

result: 

> [LOG]: "
> from3: 3,4,5
> from2To4: 2,3
> all: 0,1,2,3,4,5
> " 
> [LOG]: "insert in index 4: 0,1,2,3,X,4,5" 
> [LOG]: "replace in index 1: 0,Y,2,3,X,4,5" 
> [LOG]: "added at the end: 0,Y,2,3,X,4,5,i1,i2,i3"
Thethaovn thethaovn.club
Tags: sport
Published: 2023-11-05 06:17:43

Thethaovn hiện đang là một trong các nhà cái mới hàng đầu hiện nay. Sân chơi chuyên cung ứng các sản phẩm.
Địa chỉ: 33/6E Phan Huy Ích, Phường 12, Gò Vấp, Thành phố Hồ Chí Minh, Việt Nam.
Email: thethaovninfo@gmail.com 
Website: https://www.thethaovn.club/ 
Điện thoại: (+84) 325983806
#thethaovn #thethao #thethaovnclub
**https://www.facebook.com/thethaovninfo**
https://twitter.com/Thethaovninfo
https://www.youtube.com/@thethaovninfo
https://www.pinterest.ph/Thethaovninfo/
https://social.msdn.microsoft.com/Profile/Thethaovninfo
https://social.technet.microsoft.com/profile/thethaovninfo/
https://www.blogger.com/profile/09168755337885071244
https://www.reddit.com/user/Thethaovninfo
https://medium.com/@thethaovninfo
https://www.flickr.com/people/199206252@N05/
https://www.tumblr.com/thethaovninfo
https://www.scoop.it/u/thethaovninfo-gmail-com
https://ext-6432546.livejournal.com/
https://thethaovninfoblog.wordpress.com/
https://sites.google.com/view/thethaovnclub
https://tinyurl.com/556h76y6**
https://ok.ru/thethaovninfo