teleren/devto huggingface dataset:
Probability for Data Science
Tags: webdev, machinelearning, datascience
Published: 2023-04-15 04:40:05

Probability is a branch of mathematics that deals with the study of random events and the likelihood of their occurrence. It plays a crucial role in our everyday lives, from the likelihood of winning the lottery to the probability of a weather forecast being accurate. In this article, we will explore the basics of probability and provide well-detailed examples that anyone can relate to.

Understanding **Probability**:

**Probability** is a measure of the likelihood of an event occurring. It is expressed as a number between 0 and 1, with 0 meaning that the event will never occur, and 1 meaning that the event is certain to occur. For example, the probability of flipping a coin and getting heads is 0.5, which means that there is an equal chance of getting either heads or tails.

**Probability** is calculated by dividing the number of favorable outcomes by the total number of possible outcomes. For example, if you roll a six-sided die, the probability of getting a 4 is 1/6, because there is only one way to get a 4 and six possible outcomes.

Well-Detailed Examples:

**Rolling Dice:**
Suppose you roll a pair of dice. What is the probability of getting a total of 7? To answer this question, we need to know how many ways we can get a total of 7 and how many total outcomes are possible. There are six ways to get a total of 7: 1+6, 2+5, 3+4, 4+3, 5+2, and 6+1. There are a total of 36 possible outcomes (6 x 6). Therefore, the probability of getting a total of 7 is 6/36 or 1/6.

**Flipping Coins:**
Suppose you flip a coin three times. What is the probability of getting two heads and one tail? To answer this question, we need to know how many ways we can get two heads and one tail and how many total outcomes are possible. There are three ways to get two heads and one tail: HHT, HTH, and THH. There are a total of 8 possible outcomes (2 x 2 x 2). Therefore, the probability of getting two heads and one tail is 3/8.

**Weather Forecast:**
Suppose you are planning a picnic for next weekend. The weather forecast says that there is a 30% chance of rain. What is the probability that it will not rain? To answer this question, we need to subtract the probability of rain from 1. Therefore, the probability of not raining is 1 - 0.3 = 0.7 or 70%.

**Conclusion:**

**Probability** is an essential concept in mathematics that is used in many fields, from science and engineering to economics and finance. Understanding probability allows us to make informed decisions based on the likelihood of certain events occurring. The examples provided in this article are just a few of the many ways that probability can be used in everyday life. By applying the principles of probability, we can better understand the world around us and make better decisions.
Can You Guess the output?? ;)
Tags: cpp, programming, discuss, codenewbie
Published: 2023-04-15 07:21:55

```
#include <iostream>
#include <signal.h>
#define m_sig signal(SIGSEGV, sig_memory);
void sig_memory(int code)
{
    std::cout << "something went wrong!\n";
    exit(0);
};

class Test
{
private:
    Test();
    int data;

public:
    Test(const int &value) : data(value){};
    int get_data() const { return this->data; };
    void set_data(const int &value);
};
void Test::set_data(const int &value)
{
    this->data = value;
};
#define ONE
template <typename T>
void print_pointer(const T *const p)
{
    if (p == nullptr)
    {
         std::cout << "you are passing null pointer to argument!\n";
         return;
     };
     std::cout << *p << "\n";
}
int main()
{
    m_sig

#ifndef ONE
        Test test1 = 45;
#else
        Test test1(90);
#endif
    std::cout << test1.get_data() << '\n';
    int *const ptr = 0;
    *ptr = 56;
    print_pointer(ptr);
    return 0;
}
```
Fixing Bugs or Writing Algorithms? A Superhero “Would You Rather” 🦸🏻‍♀️💥🦸🏻
Tags: discuss, beginners, codenewbie
Published: 2023-04-15 07:00:00

The Bug Buster vs. Algorithm Master. Would you rather have the power to instantly zap away any bug in your code with the snap of your fingers, or the ability to create complex algorithms at lightning speed with just a single thought? Engage!

---

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more engaging, thought-provoking, and sometimes silly discussions just like this.
Resolving ImagePullBackOff and Accessing a LoadBalancer Service in Minikube
Published: 2023-04-15 06:56:12

**Summary**: This document details the steps taken to resolve the ImagePullBackOff error and access a LoadBalancer service in a Kubernetes cluster running on Minikube.

## Issue
The ImagePullBackOff error occurred while deploying the hello-world-microservice in a Kubernetes cluster running on Minikube. This issue prevented the deployment from starting. Additionally, accessing the LoadBalancer service using the curl command did not return any output.

## Resolution
### Fixing the ImagePullBackOff error

1. Update the image name in the Kubernetes deployment manifest to use the correct image name available in the container registry.
2. Apply the updated deployment manifest:

`kubectl apply -f k8s-deployment.yaml`

In terraform `terraform apply`


### Accessing the LoadBalancer service
Check the logs of the running pods to see if there is any error or if the application has started properly:
```
kubectl logs hello-world-microservice-b849675f-gns8s -n hello-world
kubectl logs hello-world-microservice-b849675f-jrgpp -n hello-world
```
Access the service from within the cluster using a temporary pod with the curl command:

`kubectl run curl-test --image=curlimages/curl:latest --rm -it --restart=Never --namespace=hello-world --command -- sh`

Then, within the curl-test, Run:
`
curl hello-world-microservice:80
`

I am doing this because it's a web application. This depends on and defer based on the program.


## My issue with Minikube
The actual problem I had was not with code and image but Minikube.

Since Minikube doesn't support the LoadBalancer service type out-of-the-box, run the minikube tunnel command in a separate terminal to create a network route on the host to the service CIDR of the cluster using the cluster's IP address as a gateway:

`minikube tunnel`

Check if the service's external IP:
`kubectl get svc hello-world-microservice -n hello-world`

Access the service using the external IP and port:
`curl http://<EXTERNAL_IP>:80`

Conclusion
By updating the image name in the Kubernetes deployment manifest and using the minikube tunnel command, I was  successful in resolving the ImagePullBackOff error and accessed the LoadBalancer service in the Minikube Kubernetes cluster.
I do badly at tests
Tags: beginners, architecture
Published: 2023-04-15 06:54:57

I am an Information Technology major, a sophomore. I'm writing my second semester exams now, and today I wrote an exam on computer architecture.

Now, while studying the material for the course, reading stuff online about concepts like pipelining and parallel processing, I enjoyed every bit of that.

Understanding the concepts were intuitive, I understood them on an empirical level. Some conventions in a C plus plus course I take and concepts became clearer as well.

Problem is, I wasn't able to put in writing what these concepts mean in computer science jargon. I got into this mental block. And there was no way I could use "explain-like-i'm-five" grammar in this exam. It was clearly stated in the instructions that jargon was to be strictly used to answer these questions to get full marks.

What caused my mental block? I was a nervous wreck overthinking how to present my thoughts in needy jargon.

I'm used to writing and speaking "explain-like-i'm-five" grammar from my experience in content writing and ghost writing.

Maybe it's because I'm going to be graded, I felt trapped in my head. I reenacted many Prison Break episodes in m head, I won an Noble prize for Science in another universe in my head. All while exams were ongoing.

On the other hand, swapping definitions of concepts and practical scenarios where they were implemented with my roommate in pidgin English was more interesting and refreshing. 

**I don't do well on tests** might not be a suitable title for this post, but I wanted to use a Suits reference.
Microservice with Kubernetes, Terraform, and Nest.js in Mac
Published: 2023-04-15 06:44:17

*Prerequisites:**

- Install Node.js: https://nodejs.org/en/download/
- Install Docker: https://www.docker.com/products/docker-desktop
- Install Kubernetes CLI (kubectl): https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/
- Install Minikube (for local Kubernetes cluster): https://minikube.sigs.k8s.io/docs/start/
- Install Terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli




## 1. Creating Nest.js
I won't tell about Nest.js because it runs in 3000 port which already has pre-built "Hello World!" in the base boilerplate. So, I won't do anything new.


Install Nest.js CLI globally: `npm install -g @nestjs/cli`
Create a new Nest.js project: `nest new hello-world-microservice`

## 2: Containerize the Nest.js application

Create a Dockerfile in the project root with the following content:

```Dockerfile
FROM node:lts

RUN npm i -g pnpm

WORKDIR /app

COPY package.json pnpm-lock.yaml ./

RUN pnpm install

COPY . .

RUN pnpm run build

EXPOSE 3000

CMD ["pnpm", "run", "start:prod"]
```

**Build the Docker image: `docker build -t hello-world-microservice` .**


## 3: Set up Kubernetes deployment and service

1. Start Minikube: minikube start
2. Set Docker environment: eval $(minikube docker-env)

## 4: Set up Terraform

This is the crucial part of running the micro service.

```tf
provider "kubernetes" {
  config_path = "~/.kube/config"
}

resource "kubernetes_namespace" "hello-world" {
  metadata {
    name = "hello-world"
  }
}

resource "kubernetes_deployment" "hello-world-microservice" {
  metadata {
    name      = "hello-world-microservice"
    namespace = kubernetes_namespace.hello-world.metadata.0.name
  }

  spec {
    replicas = 2

    selector {
      match_labels = {
        app = "hello-world-microservice"
      }
    }

    template {
      metadata {
        labels = {
          app = "hello-world-microservice"
        }
      }

      spec {
        container {
          name  = "hello-world-microservice"
          image = "hello-world-microservice"
          image_pull_policy = "Never"

          port {
            container_port = 3000
          }
        }
      }
    }
  }
}

resource "kubernetes_service" "hello-world-microservice" {
  metadata {
    name      = "hello-world-microservice"
    namespace = kubernetes_namespace.hello-world.metadata.0.name
  }

  spec {
    selector = {
      app = "hello-world-microservice"
    }

    port {
      port        = 80
      target_port = 3000
    }

    type = "LoadBalancer"
  }
}

```

1. Initialize Terraform: terraform init
2. Apply the Terraform configuration: terraform apply



## 5: Test the "Hello World" Microservice

1. Get the Minikube IP: `minikube ip`
2. Get the service's external port: `kubectl get services -n hello-world`
3. Combine the Minikube IP and the external port, and open the URL in your browser or use curl. For example, if Minikube IP is 192.168.49.2 and the external port is 32000, you can use curl http://192.168.49.2:32000 to see the "Hello World!" message.
4. This doesn't work for few in that case you have to work should use `minikube tunnel`
This week’s newsletter is out! (15-04-2023) - And Then They Cut Off the Podcasts
Tags: tech, webdev, discuss
Published: 2023-04-15 06:40:07

---
title: This week’s newsletter is out! (15-04-2023) - And Then They Cut Off the Podcasts
published: true
description: Another week of great javascript, tech and web development links.
tags: javascript, tech, webdev, discuss
---

And Then They Cut Off the Podcasts

https://markjgsmith.substack.com/p/mark-smiths-newsletter-15-04-2023

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
All about APIs
Tags: http, webdev, beginners, programming
Published: 2023-04-14 18:34:21

As per the official definition by Mozilla 

> An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. 

In a simple term client and server can pass the extra bit of information(contextual/meta data) with the request and response using the http headers.

These are further divided into four parts;

- Request headers
  These are use to send information while making a client to 
  sever call.

- Response headers 
  Contrary to the first one, these are use to send information 
  while sending the response back to the client from the 
  server. 
  
- Representation headers 
  This holds the information about the body of the response. 

- Payload headers
  This is used to hold the information about the payload data. 


**Commonly used headers**

1. Accept
   _Media types/data types are accepted by the server._

2. Content-type
   _This can be used both by clients and servers to identify 
   the format of the data in their request or response._

3. Accept-encoding
   _This provides meta-information such as the encoding method 
   client can understand._

4. Host
   _It specifies the domain name. This means information such 
   as the host and the port._

5. Authorization
   _This is used to pass the credentials (such as information, 
   keys or tokens) primarily to let the server authenticate 
   the request._

6. Access-control-allow-origin
   _This is to restrict the origin which tries to fetch the 
   resource._ 

7. Accept-language
   _Helps in determining the detail that client is accepting 
   the response in the mentioned language._

8. Access-control-allow-methods 
   _This helps in knowing which methods are allowed to access 
   the cross origin resources._ 


![Http_Calls](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd31eqlh0oafoc81s7ef.jpg)


 **Http Request Methods**

1. Get 
   _The Get method is the most common of all these request 
   methods. It is used to fetch the resources from the 
   server._

2. Post
   _The Post method is used to submit the information to the 
   server. Since, we are submitting the data the post method 
   often changes the state of the server._

3. Put
   _The put method is used to change data already present in 
   the resource collection._

4. Patch
   _Contrary to put, the patch request method is used to 
   modify only the necessary part of the data or response. 
   Simply stating it never modifies the entire response._ 
 
5. Delete
   _As per its name, delete request method is used to delete 
   the specific resource. It requests that the origin server 
   delete the resource identified the request URL._


**Resources are datasets in the above statements.
 
## Connects

Check out my other blogs: 
[Travel/Geo Blogs](shishsingh.wordpress.com)
Subscribe to my channel: 
[Youtube Channel](youtube.com/@destinationhideout)
Instagram:
[Destination Hideout](https://www.instagram.com/destinationhideout/)
HTML
Published: 2023-04-15 06:10:50

HTML or Hypertext Markup Language is the standard language used to create web pages. It is a markup language that is used to describe the structure and content of a webpage. HTML is designed to be easy to read and understand, and it is used to create websites that are accessible to all users, regardless of the browser or device they are using. In this article, we will discuss the syntax of HTML and how it is used to create web pages.

HTML uses a set of tags to define the elements of a webpage. These tags are enclosed in angle brackets and consist of a tag name, attributes, and content. The tag name represents the type of element that is being defined, and the attributes provide additional information about the element.

The basic structure of an HTML document is as follows:

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<!-- Page content goes here -->

</body>
</html>

The first line of an HTML document is the DOCTYPE declaration, which tells the web browser what type of document it is. The HTML tag is used to define the beginning and end of the HTML document. The head tag is used to define the head section of the document, which contains information about the document such as the title, meta tags, and links to external files. The title tag is used to define the title of the document, which appears in the browser tab.

The body tag is used to define the body section of the document, which contains the content of the webpage. HTML tags are used to define the structure of the content, such as headings, paragraphs, lists, and images. For example, the h1 tag is used to define a top-level heading, while the p tag is used to define a paragraph of text.

HTML tags can also have attributes, which provide additional information about the element. Attributes are defined using the name=value syntax, where the name is the name of the attribute and the value is the value of the attribute. For example, the img tag is used to define an image, and it has attributes such as src, alt, and width. The src attribute specifies the URL of the image, while the alt attribute provides alternative text for users who cannot see the image.

In addition to tags and attributes, HTML also supports comments, which are used to add notes to the code. Comments are enclosed in <!-- and -->, and they are not displayed in the web browser.
Blazor WebAssembly vs. Blazor Server: Which One Should You Choose?
Tags: dotnet, dotnetcore, programming, beginners
Published: 2023-04-15 05:51:55

Blazor, the open-source web framework from Microsoft, allows developers to build web applications using C# and .NET instead of JavaScript. Blazor supports two deployment models: WebAssembly and Server. While both models share the same programming model, there are significant differences between them. In this post, we'll explore the differences between Blazor WebAssembly and Blazor Server and help you decide which one is right for your project.

**Blazor WebAssembly**
Blazor WebAssembly allows you to run the entire application in the client's web browser. When the user requests the application, the application's code is downloaded to the client's machine, compiled, and executed inside the browser's sandbox. This means that the application can run offline, and the user can continue to use the app even when they're not connected to the internet.

**Blazor Server**
Blazor Server, on the other hand, runs the application on the server and uses SignalR to provide real-time communication between the client and the server. When the user requests the application, the server sends the HTML, CSS, and JavaScript to the client. The user interacts with the app, and the app sends the user's input to the server for processing. The server then sends the updated HTML, CSS, and JavaScript to the client, and the process repeats.

**Which One Should You Choose?**
The choice between Blazor WebAssembly and Blazor Server depends on your project's requirements. If your application needs to run offline, or you need to take advantage of client-side processing power, then Blazor WebAssembly is the better option. On the other hand, if your application requires real-time communication, or you have performance concerns, then Blazor Server is the way to go.

In this post, we explored the differences between Blazor WebAssembly and Blazor Server and helped you decide which one is right for your project. Remember, both models share the same programming model, so whichever one you choose, you'll still be able to leverage the power of C# and .NET to build your web application.
Install Docker on Centos 9
Published: 2023-04-15 05:50:40

Remove conflict packages with Docker first
```
dnf -y remove podman runc
```

install repo
```
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/docker-ce.repo
dnf --enablerepo=docker-ce-stable -y install docker-ce
```

Autoload docker
```
systemctl enable --now docker
```

Check it
```
rpm -q docker-ce
docker version
```
Mindset of a web developer
Tags: webdev, beginners, programming, javascript
Published: 2023-04-15 05:43:20

There is one thing that all good programmers have in common and that is that they have a good mindset. They built their mindset throughout trials and tribulations that they went through while they learned to code and even after that. Of course not all developers or programmers have the same mindset, but there are some basic elements of these mindset that all developers have, or should have.

So what are these basic mindset shifts or perceptions that every developer should master?

Well, here they are:

1. Remember your goal
2. Put your ego to the side
3. Look at your code from a different angle
4. Learn when you need to take a break

---

## 1. Remember your goal
This is especially important when you get stuck with one of your projects or just simply go through a hard time developing something.
In these times it is really important to remember why you are doing what you are doing, and what are your goals because that's the only way you can push through these hard times.

But please be aware that simply keeping your goals in mind won't make you succeed in life. To succeed you need to be consistent on your journey. If you are interested on this topic, I highly recommend you checking out a book named [Atomic Habits](https://jamesclear.com/atomic-habits).


## 2. Put your ego to the side
Putting your ego to the side is especially important when you have to ask someone for advice or when you have to google something because you forgot it, and these times your ego can be a barrier telling you that you don't need help, because you know the answer to that problem, but in reality we all know that that is not true all the time. There are times when you simply need to ask someone, or you need to google something, and for that you need to let go of your ego.


## 3. Looking at your code from a different angle
When you are seemingly unable to solve a problem in your code with a specific approach, maybe what you should try is take a step back and look at the problem again and try to solve it from a different angle or with a different approach.


## 4. Learn when you need to take a break
You need to learn when to take a break. Why? Because when you are stuck on a problem you can get overwhelmed or frustrated, and when you are frustrated it's going to be very hard to solve that problem, because you won't be able to think with pure logic.

It is very important to learn to take breaks, so you can calm your mind, regroup your thoughts and solve that problem.