teleren/devto huggingface dataset:
AWS Services Guide : Introduction
Published: 2023-08-11 03:26:37


![AWS Hello](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0qj5asoez5nggrw8k9uk.png)

## Hi there! 
Welcome to my comprehensive blog series where we will be discussing and exploring the vast ecosystem of AWS Services. With over 200+ current AWS services being offered it can be difficult to know what you need and what is offered for your needs. This series is tailored to provide you with a clear and insightful understanding of AWS's offering and how you can integrate them into your next project. My goal is to equip you with the tools, knowledge and insights necessary to make informed decisions when architecting, implementing, and optimizing your cloud infrastructure on AWS. We will be breaking down the most fundamental services, their features, use cases, best practices and common errors. After each services if covered I will also give an example or way to integrate this service into a real world implementation.

Join me as we unravel the cloud-powered potential of AWS services. The future of technology is in the cloud, and together, we'll navigate its possibilities, one service at a time.

Stay tuned for the first installment, where I will be detailing AWS Identity and Access Management or better known as **AWS IAM**.

Feel free to explore this guide out of order as it will not be chronological!
Calculating Option Theta in Python
Published: 2023-08-11 03:21:28

Theta is one of the "Greeks" used to measure an option's sensitivity to time decay. Specifically, theta indicates how much an option's price declines as the expiration date approaches. Traders use theta to gauge the impact of time decay on an option's value.

Calculating theta in Python is straightforward using the `pyoptions` library. Here's a step-by-step guide:

## Import Modules

Begin by importing the necessary modules:

``python
import pyoptions
import pandas as pd
``

Pyoptions contains the pricing models while pandas is used for data analysis.

## Extract Option Data

Next, extract the relevant option data needed for theta calculation:

```python 
option = {'S': 50, 'K': 50, 'T': 30/365, 'r': 0.01, 'sigma': 0.2, 'type': 'call'}
```

This creates a dictionary with keys for stock price, strike, time to expiration, interest rate, volatility, and option type.

## Calculate Theta

Now calculate theta by passing the option data dictionary into `pyoptions.bsm.theta()`:

```python
theta = pyoptions.bsm.theta(option)
print(theta)
```

`-1.212`

The theta is returned in dollar value terms. As expected for a call option, it shows a negative theta of -$1.212 indicating time decay.

That's it! With just a few lines of Python, we can easily calculate the theta for any option to quantify time decay. Pyoptions provides a simple way to harness options analytics in Python. Theta is very useful on the option [pmcc strategy](https://theoptionsuniversity.com/poor-mans-covered-call-strategy-explained/) , [wheel strategy](https://theoptionsuniversity.com/wheel-strategy-beginners-guide/) or any other option selling strategies.
Angular + Module Federation remote import modules 👷‍♀️
Tags: angular, webpack, frontend, tutorial
Published: 2023-08-11 03:09:18

When implementing **Module Federation** in Angular (specifically using the library @angular-architects/module-federation) you need to be careful of what modules you are importing in your remotes. Some of these will break the application, but the error handling can be spotty and unclear. This can also be affected by what you share between your shell and your remotes.

Here's what I've found to be some best practices.


**Remove** these from your remote modules:
_BrowserAnimationsModule
BrowserModule
RouterModule.forRoot()_

Instead you can use:
_CommonModule
RouterModule.forChild()_

Targeting forChild with your RouterModule will ensure your shell's router outlet is being used. 

__________________________________________________________________

This next one is a little different, and will depend on your use case:

Whether you put the _HttpClientModule_ in your remote modules will be dependent if you are using **Http Interceptors** and how you are using them. 

If you are wanting to use a global interceptor in your shell project (Ex. A loading bar or spinner that fires on every API call regardless of whether or not it is in the shell or remote) then you should NOT use _HttpClientModule_ in your remote project. If you have a _HttpClientModule_ in a remote, it will ignore the shell's _HttpClientModule_ in favor for the remote's. There could be a use case for this, so just be aware of what your needs are when importing this module.


If you have any questions or anything you'd like me to add, please comment down below! 💡💡💡
Bad reasons to test
Tags: automation, generaltesting, agiletesting, cost
Published: 2023-08-17 13:06:58

---
title: Bad reasons to test
published: true
date: 2023-08-11 01:48:57 UTC
tags: Automation,Generaltesting,agiletesting,cost
canonical_url: https://gerg.dev/2023/08/bad-reasons-to-test/
---

“Complete” testing is impossible, so we have to do the best we can with the time and resources we have. Often, that comes down to making sure that there’s a good reason for each test to exist. If there isn’t, then you should remove it and spend that time on something more valuable. When evaluating test suites, I will ask, “why do you have this test?” or “why are you testing this?” To me, a good reason is that the test addresses some _specific_ concern, risk, or functionality _that no other test does_. But, I’ve heard plenty of bad reasons, too…

## To cover all the scenarios

Ok, but which scenario does _this_ test cover? Do you have a list of “all” the scenarios? Is each one unique? What makes them unique? Who gave you that list? Is it ever possible to cover them all if you did have such a list?

## To get more confidence

What are you more confident about after running this one test that you weren’t confident about before? Could you run another test to give you that same confidence? Why not? What are you worried about happening if we didn’t run this test?

## To see that it works

To see that _what_ works? It can’t be the product or application, because that’s what all the tests do. What could be broken if we didn’t run this test?

## Because the Product Owner told us to

What does the Product Owner know that you don’t? Do they have a reason? You should probably know what it is too. Maybe there’s a more effective way to test that aspect, but you have to know what aspect they’re interested in first. If they don’t have a reason, it’s probably part of your job to steer them towards more useful tests and, perhaps, illustrating why this one isn’t necessary.

## Why I care

If you don’t know what a test tests, how are you going to interpret it when it fails? Tests are only valuable if they tell us something useful when they fail. Each test costs us in time to design, write, run, analyze, and maintain. The only way to know that we’re making the most of the time and resources we have is to be sure that each test adds _specific_ value. Without that, you’ll never really know which ones are worth including and which should be excluded.
TIL #4
Published: 2023-08-11 03:03:11

Today, I finally learned to put together all my hard earned  HTML and Ruby knowledge, and built my first interactive web application. 

I had used Python in the pass more for back-end programing as well as analysing large data. But I had never made a web application. 

The raw code is mostly done but the appearance is barebones. I plan to work on in the next couple of weeks, and make it look "pretty".

I hope my CSS skills are up to par. If not, back to codecademy.
Slaying the Ruby Gym Godzilla
Tags: beginners, ruby
Published: 2023-08-11 02:40:26

Ruby Gym was the definition of delayed gratification. At first, taking on each exercise was challenging and frustrating to be honest, but I tried to carve out a chunk of time each day to chip away it. At the Leap Year exercise, I felt stuck for some time but decided to walk away from it and sure enough the following day it took me 10 minutes to wrap my head around how I wanted to finish my code. I think at the Secret Encoder exercise I finally felt like I was "getting it".  I realized writing code is feeling so much more gratifying with a couple of wins under my belt. I am definitely feeling more confident each day. Here are some big takeaways from completing the Ruby Gym module:

1. The `.each` method is super helpful to access objects within an array and apply some action/block of code to each item. It really is a powerful method that I will use with large collections of data. 

2. The `.gsub` method is my best friend. No, but in all seriousness, it is super helpful for reformatting characters. I will end up using it a lot in the future. 

3. Instead of trying to work hastily and inadvertently make a problem more complicated, remember to break down complex problems into smaller parts (thank God for sticky notes). On a couple of the Ruby Gym exercises I found myself working hastily but not efficiently. I ended up having to work longer and inefficiently since I made mistakes I later needed to clean up within my code. 

Altogether, the Ruby Gym exercises were tough but definitely gratifying. I am novice when it comes to this coding game, but I am definitely excited for what the future holds. I will continue to work hard and persevere. Onward and upwards my friends!
Manager Handbook for Distributed AntDB-T - P12
Tags: database
Published: 2023-08-11 02:07:30

## Read/write separation
The user connects to the Coordinator, executes SQL statements, and eventually the modification and query of the data will access the Datanode. Generally Datanode has synchronous or asynchronous standby nodes. In case of synchronous standby node, the data is consistent with the master node in real time, so the standby node can provide the function of data query. However, when the master node is working normally, the standby node only provides the function of data backup, which causes the waste of machine resources.

AntDB implements read-write separation at the kernel level, and by turning on the switch of read-write separation, it can be realized that the executed read operation accesses the standby node and the write operation accesses the master node, which is completely transparent to the application layer, effectively improving the utilization rate of the master and slave machine resources and increasing the throughput of the database.

**_Read-write separation control parameters_**

There are two switches involved in read-write separation, and the read-write separation function is enabled on adbmgr by means of parameter settings as follows:

In case of synchronous nodes:

```
set coordinator all(enable_readsql_on_slave = on); 
```
 
In case there are no synchronous nodes, only asynchronous nodes, and you want the asynchronous nodes to provide read functionality:

```
set coordinator all(enable_readsql_on_slave = on);  
set coordinator all( enable_readsql_on_slave_async = on); 
```
 

- enable_readsql_on_slave: The read-write separation master switch.

- enable_readsql_on_slave_async: switch to allow asynchronous nodes to provide read functionality.

The relationship between the two is as follows:

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

Note: In the scenario of concurrent read/write, if the asynchronous node provides the read function, there may be a problem that the data just written cannot be queried due to the time difference of data synchronization.

In some scenarios, when read-write separation is enabled and master stream replication is synchronized, DML operations are performed on the master node, and when the backup node queries immediately, it is found that the corresponding data cannot be found. The reason is that the DML operation of the master node has not been applied in the slave node, so the query operation sent to the slave node cannot read the latest data. If you want to avoid this situation, you can set thesynchronous_commit parameter of datanode asremote_apply to ensure that the master's operation is applied on the slave before returning the message to the client.

Login to mgr, execute the following command, and restart.

```
set datanode all(synchronous_commit = 'remote_apply'); 
```
Note that there will be some performance loss after settingremote_apply.
What are vector embeddings?
Tags: ai, beginners, vectordatabase, machinelearning
Published: 2023-08-11 01:31:14

An embedding is a representation of an object (words, sentences, images, etc.) summarized as an array of numbers (a vector - for you mathematicians out there). Together, these numbers capture the semantic information about the analyzed items and their notable features. By summarizing the object’s bulky representation in numeric form, using a model like GPT4 or others, we enable efficient searches across vast volumes of information. These searches can inform and guide us - give us hints, context, and relationships. But what are they? What do they look like?

```
vector1 = [ 34.5, 832.89, 21.41 ]
vector2 = [ 98.45, 145.03, 21.42 ]
```

These are two vectors, each with three embeddings. A vector is an array of floating-point numbers. Embeddings _are_ numbers. Even with this limited example, we can see quickly that one embedding in each array is close numerically to another. That means these vectors are related. Now imagine this, but each vector has hundreds of embeddings, and there are hundreds of millions of vectors.

That’s all well and good, but let’s think about this more with a concrete example.

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

Say you had an image of a man from a fashion shoot on location in Casablanca. When inserting the vector embeddings generated from that image into a vector index, this image is immediately related to the city of Casablanca as well to photoshoots because the floating-point numbers are close to each other. But, what other existing data in the index are other vector embeddings from the image automatically related to? Things like Morocco, Africa, Hollywood films from the 1940s, etc., but you get the idea.

Now that you know how AI models create vector embeddings from text, images, etc. What data do you have that you or your customers would benefit from a similarity search. For example, “Give me a list of writings similar to text written by Maya Angelou.”

If you had a vector index to store all of this data, what would you create?
BEST CRYPTO RECOVERY EXPERT
Tags: webdev, programming, python, css
Published: 2023-08-11 00:38:02


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

Alien Wizbot made it possible for us to get back our scammed funds, the debt imposed on us by scammer were cleared with the help of Alien Wizbot, they have best hacking service.
Responsive image carousel with automatic and manual navigation, built using React
Tags: carousel, navigator
Published: 2023-08-12 20:10:59

---
title: Responsive image carousel with automatic and manual navigation, built using React
published: true
date: 2023-08-11 00:32:00 UTC
tags: Carousel,Navigator
canonical_url: https://reactjsexample.com/responsive-image-carousel-with-automatic-and-manual-navigation-built-using-react/
---

# 🎠 Image Carousel
 ![Responsive image carousel with automatic and manual navigation, built using React](https://reactjsexample.com/content/images/2023/08/code_2023-09-22-27-20.jpg)

This project demonstrates a responsive image carousel that displays three images in a slideshow format. The carousel transitions automatically every three seconds and allows manual navigation between images.

## 📦 Installation

1. Clone the repository to your local machine using:

2. Navigate to the project directory:

3. Install the required dependencies:

4. Start the development server:

## 🚀 Features

- Displays three images in a slideshow format.
- Transitions automatically between images every three seconds.
- Allows manual navigation to the next or previous image.
- Implements an infinite loop so that after reaching the last image, the carousel starts again with the first image.
- Provides a reusable carousel component that supports independent instances.
- Fetches images from a provided API ([https://jsonplaceholder.typicode.com/albums/1/photos](https://jsonplaceholder.typicode.com/albums/1/photos)).

## 🪄 Technologies

- `CSS`
- `React`
- `Vite`

## 🐊 Usage

1. Open the web application in your browser after starting the development server.
2. You will see two carousels side by side, each displaying three random images.
3. The carousels transition automatically every three seconds.
4. Use the “Previous” and “Next” buttons to navigate manually between images.
5. Indicator dots below the carousel indicate the current image index. These dots are equipped with ARIA attributes for enhanced accessibility.

## 📷 Screenshot

![Responsive image carousel with automatic and manual navigation, built using React](https://github.com/mirayatech/image-carousel-test/raw/main/public/demo.png)

## 🤓 Future Improvements

If I had more time, I could think about making the following things better:

- Adding swipe gestures for devices you can touch.
- Making the transitions between pictures smoother for a nicer experience.
- Putting in options to change how the picture slideshow works, like how fast pictures change and if they change by themselves.
- Adding e2e tests to double-check that the image carousel works perfectly in all situations and is super reliable. These tests will make sure the carousel does what it’s supposed to do without any problems.

## GitHub

[View Github](https://github.com/mirayatech/image-carousel-test?ref=reactjsexample.com)
React To-Do App with Tailwind CSS
Tags: todo, tailwindcss
Published: 2023-08-12 20:11:13

---
title: React To-Do App with Tailwind CSS
published: true
date: 2023-08-11 00:30:00 UTC
tags: Todo,TailwindCSS
canonical_url: https://reactjsexample.com/react-to-do-app-with-tailwind-css/
---

# Smatyx Todos
 ![React To-Do App with Tailwind CSS](https://reactjsexample.com/content/images/2023/08/code_2023-09-22-25-08.jpg)

![React To-Do App with Tailwind CSS](https://github.com/minhtc-tech/p_react-todos/raw/main/images/demo.webp)

- Welcome to the React To-Do App with Tailwind CSS! This is a simple web application where you can manage your to-do list. The app is built using React for the front-end and Tailwind CSS for styling.
- Live demo: [https://smatyx-todos.vercel.app/](https://smatyx-todos.vercel.app/)
- Please give this source a star, thank you so much 🥰.

## Installation

To run this project locally, follow these steps:

1. Clone the repository or download the source code.
2. Navigate to the project directory.
3. Install the dependencies using yarn:

```
yarn install
```

## Usage

To start the development server, use the following command:

```
yarn start
```

This will start the development server and open the project in your default browser at `http://localhost:3000`.

## GitHub

[View Github](https://github.com/minhtc-tech/p_react-todos?ref=reactjsexample.com)
PHP Enums tryFrom Method
Tags: php, laravel, beginners, webdev
Published: 2023-08-11 00:19:12

---
canonical_url: https://seankegel.com/php-enums-tryfrom-method
---

I was recently working on a project where I was receiving data from an API that had a `payment_type`. I converted the `payment_type` into the enum below:

```php
enum PaymentType: string 
{
	case CREDIT_CARD = 'credit_card';
	case APPLE_PAY = 'apple_pay';
	case GOOGLE_PAY = 'google_pay';
	case PAYPAL = 'paypal';
	case SHOP_PAY = 'shop_pay';
}
```

Then, I use this enum in the data transfer object (DTO) to define the structure of the data I receive from the API.

However, the problem I was running into is the `payment_type` is not always in the response of the API data, so it could be `null`. In my DTO, I have a `from` method to build the object from the API response which looks like the following:

```php
class OrderDto
{
	...
	public static function from(array $data): self {
		return new self(
			...
			payment_method: isset($data['payment_method']) ? PaymentType::from($data['payment_method']) : null,
		);
	}
}
```

I had to check if the `payment_method` is set to, because otherwise, a `ValueError` exception will be thrown.

This is where the `tryFrom` method comes in handy. If `payment_method` is `null` or is not a valid case for the enum, it will just return `null` without throwing an exception. So now, the DTO can be updated to the following which is much cleaner:

```php
class OrderDto
{
	...
	public static function from(array $data): self {
		return new self(
			...
			payment_method: PaymentType::tryFrom($data['payment_method']),
		);
	}
}
```

Please note that this only works for [backed enums](https://www.php.net/manual/en/class.backedenum.php) in PHP 8.1+. In case you’re not familiar, a `BackedEnum` is one where each case has a value specified. So in the example above, the enum is a string backed enum since it is defined with `enum PaymentType: string`.

This would not work for a standard PHP enum like the one below:

```php
// Not a backed enum so does not include from and tryFrom methods.
enum PaymentType 
{
	case CREDIT_CARD;
	case APPLE_PAY;
	case GOOGLE_PAY;
	case PAYPAL;
	case SHOP_PAY;
}
```

If you found this tip helpful, I also have a similar one with the Carbon PHP make method. You can read that [here](https://dev.to/sean_kegel/carbon-php-quick-tip-4pdm).
What's wrong with Docker?🐳
Published: 2023-08-11 00:11:47

I've worked **a lot** with Docker over the last 5+ years and have encountered weird behaviour, bugs, and people that hate Docker. What's the communities opinion of Docker here? What do you love, what do you hate, what have you never really understood?:D Maybe we can help each other out here :)

I will start: Why is Docker support for Windows so bad? Do you think it will ever get better? 🐳👀