teleren/devto huggingface dataset:
Calculating and Understanding Measures of Central Tendency
Tags: python, programming
Published: 2023-12-13 00:34:31

In the realm of statistics, measures of central tendency play a pivotal role in unraveling the story behind a dataset. In this blog post, we'll embark on a journey to review and practice calculating the mean, median, and mode. Along the way, we'll gain insights into when each measure is most appropriate and the valuable information they provide.

## 1. **Mean: The Central Hub**

The mean, often referred to as the average, is the heartbeat of a dataset. Calculated by summing up all values and dividing by the total count, the mean provides a glimpse into the center of mass of the distribution.

**Formula:**
Mean = Sum of all values/Number of values

```python
# Python code for calculating the mean
data = [10, 15, 20, 25, 30]
mean = sum(data) / len(data)
print(f"Mean: {mean}")
```

### Insights:
- Use the mean for approximately symmetric data.
- Caution: Sensitive to extreme values.

## 2. **Median: Navigating the Midpoint**

The median takes us on a journey through the middle ground of a dataset. Unfazed by extreme values, the median is the middle value when the data is sorted.

**For Odd Number of Values:**
Median = Middle value

**For Even Number of Values:**
Median = Sum of the two middle values/2

```python
# Python code for calculating the median
data = [10, 15, 20, 25, 30, 35]
data.sort()
n = len(data)
median = (data[n // 2 - 1] + data[n // 2]) / 2 if n % 2 == 0 else data[n // 2]
print(f"Median: {median}")
```

### Insights:
- Use the median for skewed data or datasets with outliers.
- Robust and resistant to extreme values.

## 3. **Mode: Unveiling the Most Frequent**

The mode takes us to the heart of frequency. It identifies the most common value(s) in a dataset, making it relevant for both numerical and categorical data.

```python
# Python code for calculating the mode
from statistics import mode

data = [10, 15, 20, 25, 30, 30]
try:
    mode_value = mode(data)
    print(f"Mode: {mode_value}")
except StatisticsError:
    print("No unique mode")
```

### Insights:
- Use the mode for categorical data or when identifying the most common value is paramount.
- Less commonly used for numerical data.

## When to Use Each Measure:

### Mean:
- Use when data is approximately symmetric.
- Caution: Sensitive to outliers.

### Median:
- Use when data is skewed or contains outliers.
- Robust and resistant to extreme values.

### Mode:
- Use for categorical data or when identifying the most common value is essential.
- Can be informative for identifying peaks in numerical data.

## Bringing it All Together:

In conclusion, mastering measures of central tendency empowers you to unravel the nuances within a dataset. Whether you're exploring the average, navigating the midpoint, or unveiling the most frequent values, each measure serves a unique purpose. Practice calculating these measures and recognize the situations where each shines. As you navigate the statistical landscape, the mean, median, and mode will guide you in uncovering the rich insights hidden within your data. Happy calculating!
Circular queue
Published: 2023-12-13 00:12:42

 class CircularQueue {
    private int maxSize;
    private int front;
    private int rear;
    private int[] queue;

    public CircularQueue(int size) {
        maxSize = size + 1; // One extra space to differentiate between front and rear.
        queue = new int[maxSize];
        front = rear = 0;
    }

    public boolean isEmpty() {
        return front == rear;
    }

    public boolean isFull() {
        return (rear + 1) % maxSize == front;
    }

    public void enqueue(int item) {
        if (isFull()) {
            System.out.println("Queue is full. Cannot enqueue.");
        } else {
            queue[rear] = item;
            rear = (rear + 1) % maxSize;
            System.out.println(item + " enqueued to the queue");
        }
    }

    public int dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty. Cannot dequeue.");
            return -1; // Return a special value to indicate an empty queue.
        } else {
            int item = queue[front];
            front = (front + 1) % maxSize;
            System.out.println(item + " dequeued from the queue");
            return item;
        }
    }

    public void display() {
        System.out.print("Queue: ");
        int i = front;
        while (i != rear) {
            System.out.print(queue[i] + " ");
            i = (i + 1) % maxSize;
        }
        System.out.println();
    }

    public static void main(String[] args) {
        CircularQueue queue = new CircularQueue(5);

        queue.enqueue(1);
        queue.enqueue(2);
        queue.enqueue(3);
        queue.enqueue(4);
        queue.display();

        queue.dequeue();
        queue.display();

        queue.enqueue(5);
        queue.enqueue(6);
        queue.display();

        queue.dequeue();
        queue.dequeue();
        queue.dequeue();
        queue.display();
    }
}
Five Resources to Help You Code Accessible Forms, Form Validation, and Error Messages
Tags: a11y, javascript, web
Published: 2023-12-14 18:49:08

---
title: Five Resources to Help You Code Accessible Forms, Form Validation, and Error Messages
published: true
date: 2023-12-13 00:00:00 UTC
tags: a11y, javascript, web,
canonical_url: https://gingerkiwi.dev/blog/2023-12-13-accessible-forms-resources/
---

I'm working on the first of several accessible forms tutorial articles today. It's taking longer than I'd planned to code and write another Cats and Coffee themed tutorial. So for this week's Web Accessibility Wednesdays, here's some of the resources I'm using.

1. [A Guide To Accessible Form Validation](https://www.smashingmagazine.com/2023/02/guide-accessible-form-validation/)
  - [Sandrina Pereira](https://www.smashingmagazine.com/author/sandrina-pereira/)
  - Publication: Smashing Magazine
  - Format: Article with embedded codepen
  - Feb 27, 2023
2. [Structuring Accessible Forms](https://racheleditullio.com/talks/accessible-forms/)
  - Rachele DiTullio
  - Publication: [Rachele DiTullio.com](https://racheleditullio.com)
  - Format: Article with embedded CodePen, and links to GitHub and several YouTube videos
  - Note: The [Axe-Con webinar on March 2023](https://www.youtube.com/watch?v=hc_mWh4T2bE&feature=youtu.be) has American Sign Language interpretation
  - Last updated: March 17, 2023
3. [Usable and Accessible Form Validation and Error Recovery](https://webaim.org/techniques/formvalidation)
  - Publication: Web AIM Blog
  - Format: Article with code snippets
4. [The Anatomy of Accessible Forms: Error Messages](https://www.deque.com/blog/anatomy-of-accessible-forms-error-messages/)
  - [By Raghavendra Satish Peri](https://www.deque.com/blog/author/raghavendra-perideque-com/)
  - Publication: Deque Systems website
  - Format: Article with code snippets
  - June 25, 2019
5. [Create accessible forms](https://www.a11yproject.com/posts/how-to-write-accessible-forms/)
  - [Hamsa Harcourt](https://www.a11yproject.com/authors/#hamsa-harcourt)
  - Publication: [The A11y Project](https://www.a11yproject.com)
  - Format: Article with code snippets
  - September 19, 2020
Circular queue
Published: 2023-12-13 00:12:37

 class CircularQueue {
    private int maxSize;
    private int front;
    private int rear;
    private int[] queue;

    public CircularQueue(int size) {
        maxSize = size + 1; // One extra space to differentiate between front and rear.
        queue = new int[maxSize];
        front = rear = 0;
    }

    public boolean isEmpty() {
        return front == rear;
    }

    public boolean isFull() {
        return (rear + 1) % maxSize == front;
    }

    public void enqueue(int item) {
        if (isFull()) {
            System.out.println("Queue is full. Cannot enqueue.");
        } else {
            queue[rear] = item;
            rear = (rear + 1) % maxSize;
            System.out.println(item + " enqueued to the queue");
        }
    }

    public int dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty. Cannot dequeue.");
            return -1; // Return a special value to indicate an empty queue.
        } else {
            int item = queue[front];
            front = (front + 1) % maxSize;
            System.out.println(item + " dequeued from the queue");
            return item;
        }
    }

    public void display() {
        System.out.print("Queue: ");
        int i = front;
        while (i != rear) {
            System.out.print(queue[i] + " ");
            i = (i + 1) % maxSize;
        }
        System.out.println();
    }

    public static void main(String[] args) {
        CircularQueue queue = new CircularQueue(5);

        queue.enqueue(1);
        queue.enqueue(2);
        queue.enqueue(3);
        queue.enqueue(4);
        queue.display();

        queue.dequeue();
        queue.display();

        queue.enqueue(5);
        queue.enqueue(6);
        queue.display();

        queue.dequeue();
        queue.dequeue();
        queue.dequeue();
        queue.display();
    }
}
QUEUE
Published: 2023-12-13 00:10:15

public class circularqueue {
    private int maxSize;
    private int front;
    private int rear;
    private int currentSize;
    private int[] queueArray;

    public circularqueue(int size) {
        maxSize = size;
        queueArray = new int[maxSize];
        front = 0;
        rear = -1;
        currentSize = 0;
    }

    public boolean isEmpty() {
        return currentSize == 0;
    }

    public boolean isFull() {
        return currentSize == maxSize;
    }

    public int size() {
        return currentSize;
    }

    public void enqueue(int item) {
        if (isFull()) {
            System.out.println("Queue is full. Cannot enqueue " + item);
        } else {
            rear = (rear + 1) % maxSize;
            queueArray[rear] = item;
            currentSize++;
            System.out.println(item + " enqueued to the queue");
        }
    }

    public int dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty. Cannot dequeue.");
            return -1; // You can choose a different value to represent an error condition
        } else {
            int dequeuedItem = queueArray[front];
            front = (front + 1) % maxSize;
            currentSize--;
            System.out.println(dequeuedItem + " dequeued from the queue");
            return dequeuedItem;
        }
    }

    public int front() {
        if (isEmpty()) {
            System.out.println("Queue is empty. No front element.");
            return -1; // You can choose a different value to represent an error condition
        } else {
            return queueArray[front];
        }
    }

    public static void main(String[] args) {
        circularqueue queue = new circularqueue(5);

        queue.enqueue(1);
        queue.enqueue(2);
        queue.enqueue(3);
        queue.enqueue(4);
        queue.enqueue(5);

        System.out.println("Front element: " + queue.front());
        System.out.println("Queue size: " + queue.size());

        queue.dequeue();
        queue.dequeue();

        System.out.println("Front element after dequeue: " + queue.front());
        System.out.println("Queue size after dequeue: " + queue.size());
    }
}
QUEUE
Published: 2023-12-13 00:05:13

import java.util.Scanner;

public class Main {
    static int[] queue;
    static int n;
    static int front = -1, rear = -1;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter the size:");
        n = scanner.nextInt();
        queue = new int[n];
        int ch;
        do {
            System.out.println("\nEnter your choice:\n 1.INSERT\n2.DELETE\n3.DISPLAY\n0.EXIT");
            ch = scanner.nextInt();
            switch (ch) {
                case 1:
                    insert();
                    break;
                case 2:
                    deleted();
                    break;
                case 3:
                    display();
                    break;
                default:
                    System.out.println("enter valid option...");
                    break;
            }
        } while (ch != 0);
    }

    static void insert() {
        Scanner scanner = new Scanner(System.in);
        int item;
        if (rear >= n - 1) {
            System.out.println("queue is overflow");
        } else {
            System.out.print("Enter element to be inserted: ");
            item = scanner.nextInt();
            rear = rear + 1;
            queue[rear] = item;
            if (front == -1) {
                front = 0;
            }
            System.out.println("Insertion done... & item inserted=" + item);
        }
    }

    static void deleted() {
        if (front == -1) {
            System.out.println("queue is underflow");
        } else {
            System.out.println("Item deleted..." + queue[front]);
            if (front == rear) {
                front = -1;
                rear = -1;
            } else {
                front = front + 1;
            }
        }
    }

    static void display() {
        if (front == -1) {
            System.out.println("queue is empty");
        } else {
            for (int i = front; i <= rear; i++) {
                System.out.println(queue[i]);
            }
        }
    }
}
Intro to Python's "Lock" w/ Flask
Tags: flask, python
Published: 2023-12-12 23:41:36


# Mastering Concurrency in Flask with Python's `Lock`

## Introduction

In the dynamic world of web development, Python's Flask framework stands out for its simplicity and flexibility. However, as with any web framework, Flask applications can run into concurrency issues, especially when multiple requests try to modify shared resources simultaneously. This article delves into one such challenge and demonstrates how Python's `Lock` mechanism provides an elegant solution.

## The Challenge of Concurrent Requests

Consider a Flask application receiving data through an API endpoint. This data might be processed and stored, or used to modify existing records in a database. Now, imagine multiple requests hitting the endpoint at the same time. Without proper handling, these concurrent requests could lead to race conditions, where the outcome depends on the sequence or timing of the requests. Such scenarios can result in data corruption, duplication of records, or other unintended consequences.

## Enter Python's `Lock`

To manage such concurrency issues, Python offers a synchronization mechanism called `Lock` in its `threading` module. A lock allows only one thread to access a particular block of code at a time, effectively preventing other threads from executing the same code block until the lock is released.

## Implementing `Lock` in Flask

Here's how you can implement a `Lock` in a Flask route:

1. **Import the Lock:**
   ```python
   from threading import Lock
   ```

2. **Initialize the Lock:**
   ```python
   lock = Lock()
   ```

3. **Use the Lock in a Route:**
   ```python
   @app.route('/endpoint', methods=['POST'])
   def handle_request():
       with lock:
           # Process the request
           pass
       return 'Request processed', 200
   ```

In this setup, when a POST request hits the `/endpoint`, the `with lock:` statement ensures that only one request at a time enters the processing block. Subsequent requests wait until the lock is released. This sequential processing guards against the dangers of concurrent access.

## Benefits and Considerations

The primary benefit of using `Lock` is the prevention of race conditions, ensuring data integrity and consistency. However, it's crucial to use locks judiciously. Overuse can lead to bottlenecks, reducing the application's ability to handle high volumes of traffic efficiently.

## Conclusion

Concurrency management is a critical aspect of web application development. In Flask, Python's `Lock` provides a straightforward yet powerful tool to handle concurrent requests safely. By integrating `Lock` into your Flask routes, you can protect shared resources and maintain the integrity of your application's processes.

If you have any questions or want to connect I am on [X](https://x.com/tunahorse21?t=AtMZYVon-YTic3MxkKt5xA&s=09)
Day 852 : Repeat
Tags: hiphop, code, coding, lifelongdev
Published: 2023-12-12 23:22:07

_liner notes_:
- Professional : Not a bad day. Got to talk with the Client SDK engineering team and showed them some of the issues I was running into. I cleaned up a demo application I refactored, tested it to make sure it still works and pushed the code to the repository for review. Looked into meetups that are in the San Francisco / Oakland area that I can reach out to see if they have any event happening around the time I'll be there next year. Also did another read through of the self assessment I filled out before and totally missed that there was another section at the bottom I didn't fill out. I put in the a rough draft and will check it over again before sending it out.

- Personal : Got the background removal working when you use an image that's hosted somewhere else. Went pretty smoothly. I just added another endpoint in another project that I had. I went through some tracks for the radio show. Did some research for my side project. Watched an episode of "Dr. Stone" and went to sleep.

![Looking over the Bagan, Myanmar landscape with a bunch of temples and trees everywhere with a mountain range in the distance with the sun setting behind it.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxf5kbkcvey34xj244uf.jpg)

Looking to do a repeat of last night. I want to add uploading an image from a computer and have its background removed. I did something similar in another project. Going to see if I can build off of that. Listened through some tracks for the radio show. End the night watching an episode of "Dr. Stone" and if I have time, watch "Dr. Who".

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube AcEMi-Q9mJA %}
WhiteBIT to List Ukraine's UAHg Stablecoin
Tags: cryptocurrency, crypto, stablecoin
Published: 2023-12-12 22:50:41

In a significant development for Ukraine's growing digital economy, WhiteBIT, a prominent cryptocurrency exchange, has announced the integration of the country's first stablecoin, UAHg, into its trading platform. This strategic move represents a crucial milestone in the Ukrainian cryptocurrency sector, offering expanded transactional opportunities for both individual users and businesses.
UAHg, a stablecoin pegged to the Ukrainian hryvnia (UAH) at a one-to-one ratio, is designed to support Ukrainian crypto initiatives and mirror the hryvnia's valuation in the global cryptocurrency market. Notably, UAHg is issued on multiple blockchain platforms, including Ethereum, Tron, and BNB Chain, highlighting its versatility and broad applicability.
The UAHg project aims to establish an efficient and transparent mechanism for the transfer of virtual assets, thereby enhancing their practical use. A key goal of this initiative is to mitigate the risks associated with value and liquidity loss in the cryptocurrency domain. Central to UAHg's mission is the creation of a robust hryvnia-based crypto infrastructure, enabling transactions to be executed directly in Ukrainian hryvnia. This eliminates the need for double conversion, streamlining the process for users.

The Ukrainian stablecoin UAHg is set to make its debut on the WhiteBIT platform starting December 18, 2023. This development marks a significant step in cryptocurrency innovation.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcwoeylxuxnixvgyk3wx.png)
Amazon QuickSight Summary
Tags: aws, cloud, datascience, beginners
Published: 2023-12-12 20:26:00

Amazon QuickSight is a **serverless** machine powered **business intelligence** service, and so when you hear business intelligence, that means that you're going to create **interactive dashboards**.

So this is what QuickSight looks like, you can create dashboards and these dashboards are connected to data sources that you own, and therefore you can create these nice visuals.

So it's **fast**, it's **automatically scalable**, you can embed it in website, and you get a per-session pricing.

The use cases for QuickSight are going to be around **business analytics**, **building visualization**, **performing ad-hoc analysis** in the visual fashion, to get business insights using data.
And so you can connect to many data sources such as **RDS**, **Aurora**, **Athena**, **Redshift**, **S3**, and so on.

Now there is something called the **SPICE engine**, it's an in-memory computation engine and it only works if you actually import data directly into Amazon QuickSight.
It doesn't work if Amazon QuickSight is connected to another database.

And finally, QuickSight has some very nice user level features, and so it's possible in the Enterprise edition of Amazon QuickSight to set up **column-level security**, **CLS**, to prevent some columns from being displayed for some users if they don't have enough access rights.

So what does QuickSight integrate with?
Well, you can integrate it with many data sources from AWS, for example, your RDS database, or Aurora, or Redshift, which is a great data warehousing service, or Athena to do ad-hoc queries on Amazon S3, or Amazon S3 to actually import data, or OpenSearch, or Timestream to visualize your time stream data in an optimized fashion.

You can also integrate with third party data sources that are software as a service and supported by QuickSight, and the full list is on the QuickSight website, but some of them include Salesforce, and also Jira.

You can also integrate with third party databases such as Teradata, or for example, an on-premises database that is using the JDBC protocol internally.

And as I said, you can import data sources directly into QuickSight, such as your Excel files, your CSV file, JSON documents, TSV, or the EFS CLF format for log formats.
And if these data sources are imported into Amazon QuickSight, then you can leverage the SPICE engine to perform in memory computation in a very, very fast way.

[GitHub](https://github.com/a00ayad00)
[LinkedIn](https://www.linkedin.com/in/a00ayad00)
[Facebook](https://m.facebook.com/a00ayad00)
[Medium](https://a00ayad00.medium.com/)