teleren/devto huggingface dataset:
Matplotlib Tutorial #7: Plot Color Customization
Tags: datascience, python, beginners, tutorial
Published: 2023-09-08 11:00:00

{% embed https://youtu.be/Vk9UKYpflBE %}

Hi everyone, Today I will show you how to color your plot.

## Marker Edge Color
You can use the keyword argument `markeredgecolor` or the shorter `mec` to set the color of the edge of the markers
```python
import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([0, 1, 2, 3, 5, 6])
ypoints = np.array([0, 1, 2, 3, 5, 6])

plt.plot(xpoints, ypoints, marker='o', markeredgecolor='r')
plt.show()
```
That will generate the following output

![Plot 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahm1upfsbnl9v6fxjnbm.png)

For the value of color, you can use basic color code such as:

- `b`: blue
- `g`: green
- `r`: red
- `c`: cyan
- `m`: magenta
- `y`: yellow
- `k`: black
- `w`: white

Other than basic value, you can use hex code and color codes from the color names supported by all browsers [https://www.w3schools.com/colors/colors_names.asp](https://www.w3schools.com/colors/colors_names.asp)

## Marker Face Color
You can use the keyword argument `markerfacecolor` or the shorter `mfc` to set the color inside the edge of the markers
```python
import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([0, 1, 2, 3, 5, 6])
ypoints = np.array([0, 1, 2, 3, 5, 6])

plt.plot(xpoints, ypoints, marker='o', markerfacecolor='r')
plt.show()
```
Which will produces the following output

![Plot 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4m8ebucqogx7p8daacb.png)

For color value you can refer to the available color value for the Marker Edge Color above.

## Line Color
You can use the keyword argument `color` or the shorter `c` to set the color of the line
```python
import matplotlib.pyplot as plt
import numpy as np

ypoints = np.arange(10)

plt.plot(ypoints, color='r')
plt.show()
```
Which will produce the following output

![Plot 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5pko5l30bl9qdxd1kau.png)

---

That is how you can customize the color of your plot. Thank you for reading and have a nice day!
Your Cloud Native Consulting Partner
Tags: cloudnative, consulting
Published: 2023-09-08 10:54:02

InfraCloud offers a comprehensive range of Cloud Native Consulting services designed to elevate your cloud-native development journey. Whether you're a startup or an enterprise, InfraCloud has the expertise and solutions to address your unique needs. Explore how we can help you reshape your approach to DevOps, Kubernetes adoption, and much more.

**Cloud Native Advisory**
Are you facing challenges in your cloud-native journey? InfraCloud's expert consultants are ready to guide you through every step. Don't waste time; get the assistance you need to level up your game.

**Maintaining Infrastructure**
InfraCloud's Site Reliability Engineers (SREs) can take the hassle out of infrastructure management. Let them handle the technical details while you focus on delivering value to your end users.

**On-Demand Remote Teams**
Extend your workforce with InfraCloud's cloud-native and DevOps engineers. They seamlessly integrate with your existing team, eliminating the complexities of hiring and retention.

## What makes Infracloud as #1 Cloud Native Consulting Services Company?

**Dedicated Architect**
Each project will have the technical lead who will manage the project and be point of contact between you and our engineering team. They will be responsible for timely deliverables along with assisting you at every step of your cloud native journey.

**Subject Matter Expertise**
Our engineers have implemented more than 100+ cloud native & DevOps solutions. We understand in and out of cutting-edge cloud native tools and are always steps ahead of the curve. This expertise helps you build the product people need faster.

**Rookies + Pros**
We have the perfect mix of rookies & skilled professionals at InfraCloud. Architects with immense experience of implementing cloud native solutions at scale. Rookies who come up with innovative ideas, some of which have garnered praise in the open source community.

**Expand Easily**
Don't let expansion scare you. We understand that application requirements change often, & you do not need to worry about it. With InfraCloud, you can quickly expand the team of engineers without the hassle of hiring and training. Our extended team brings in the expertise you need to accomplish your goals.

## Additional Resources

- Case Study: [Cloud Native Transformation for a SaaS Company](https://www.infracloud.io/customers/cloud-native-transformation-saas/)
- Blog: [Avoiding Kubernetes Cluster Outages with Synthetic Monitoring](https://www.infracloud.io/blogs/avoiding-kubernetes-cluster-outages-synthetic-monitoring/)
- Case Study: [Modernize Applications with Cloud Native](https://www.infracloud.io/customers/modernize-applications-kubernetes-cloud-native/)

## Ready to embark on your cloud-native journey? Get started with InfraCloud's Cloud Native Consulting Services today.

[Get started with Cloud Native Consulting Services. Talk to an expert!](https://www.infracloud.io/cloud-native-consulting/)
Strategy Pattern in Golang
Tags: go, designpatterns, strategypattern
Published: 2023-09-08 10:52:15

The Strategy Pattern is a design pattern that allows selecting an implementation of an algorithm's interface at runtime. It allows clients to choose from various implementations of a particular algorithm without altering the code that uses the algorithm.

## Example 1

```go
package main

import (
	"fmt"
	"strings"
)

type TranformFunc func(s string) string

func UpperCase(s string) string {
	return strings.ToUpper(s)
}

func Prefixer(prefix string) TranformFunc {
	return func(s string) string {
		return prefix + s
	}
}

func transformString(s string, fn TranformFunc) string {
	return fn(s)
}

func main() {
	fmt.Println(transformString("hello sailor", Prefixer("FOO_")))
}
```

### Here's a breakdown of the code:

**1. Strategy Interface:**
  - `TranformFunc` is the function type that represents the strategy interface.

**2. Concrete Strategies:**
  - `UpperCase`: A strategy that converts a string to uppercase.
  - `Prefixer`: Returns another strategy that prefixes a string.

**3. Context:**
  - `transformString`: A function that represents the context. It accepts a string and a strategy and returns the string after applying the strategy.

**4. Usage in main function:**
  - In the `main()` function, we are using the Prefixer strategy to prefix `"FOO_"` to the string `"hello sailor"`.

### Let's see another example to understand the Strategy Pattern even better:

**Example 2: Sorting Strategies**
Suppose we want to sort a slice of integers, but we want to provide multiple sorting strategies.

```go
package main

import (
	"fmt"
	"sort"
)

type SortStrategy func([]int) []int

func AscendingSort(nums []int) []int {
	sort.Slice(nums, func(i, j int) bool { return nums[i] < nums[j] })
	return nums
}

func DescendingSort(nums []int) []int {
	sort.Slice(nums, func(i, j int) bool { return nums[i] > nums[j] })
	return nums
}

func sortNumbers(nums []int, strategy SortStrategy) []int {
	return strategy(nums)
}

func main() {
	numbers := []int{3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5}

	fmt.Println("Original: ", numbers)
	fmt.Println("Ascending Sort:", sortNumbers(numbers, AscendingSort))
	fmt.Println("Descending Sort:", sortNumbers(numbers, DescendingSort))
}
```

### Here:

**1. Strategy Interface:**
  - SortStrategy is our strategy interface, which is a function type.

**2. Concrete Strategies:**
  - `AscendingSort`: Sorts a slice of integers in ascending order.
  - `DescendingSort`: Sorts a slice of integers in descending order.

**3. Context:**
  - `sortNumbers`: It accepts a slice of integers and a sorting strategy and returns the sorted slice.
In the `main()` function, we have used both strategies to demonstrate the sorting in ascending and descending order.

### Credits
First example taken from chapter **Advanced interfaces and typed functions** in [fulltimegodev](https://fulltimegodev.com/) course by Anthony De Meulemeester
Mastering Data Analysis with Pandas: A Comprehensive Guide for Python Enthusiasts
Tags: javascript, programming, webdev, learning
Published: 2023-09-08 10:46:36

Dealing with the "`SettingWithCopyWarning`" in Pandas is a common task when working with `DataFrames`. This warning usually appears when you are trying to modify a subset of a `DataFrame` that was created as a view of the original `DataFrame`, rather than a copy. It's essential to understand this warning and how to handle it to avoid unexpected behavior in your code. Here's a comprehensive guide on how to deal with it:

**Understanding the "`SettingWithCopyWarning`"**

`Pandas `uses a concept called "view" to optimize memory usage. When you slice or filter a `DataFrame`, you often get a view instead of a copy. This means that changes made to the view might not reflect in the original `DataFrame `as you might expect.

**Here's how to handle the "`SettingWithCopyWarning`":**

**1. Make a Copy Explicitly**

If you intend to modify a subset of your `DataFrame`and want the changes to be reflected in the original `DataFrame`, create a copy of the subset using the `.copy()` method:


![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ae943x2ipim0t56i6br.png)

Now, any changes you make to subset_copy won't affect the original DataFrame.

**2. Use .loc[] for Assignment**

When assigning values to a subset of a `DataFrame`, use `.loc[]` to ensure that the original `DataFrame `is updated correctly:


![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whyblylonkeqin0tyl3f.png)

_`This method directly modifies the original DataFrame.`_

**3. Disable the Warning**

While not recommended, you can disable the "SettingWithCopyWarning" by setting the Pandas option:


![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22zefvp0azx65k2g2jto.png)

_`However, it's generally better to address the warning explicitly rather than disabling it.`_

**4. Chain Operations Carefully**

Avoid chaining multiple operations on a `DataFrame` without intermediate assignment. Break your operations into separate lines to ensure you're working with a copy or the original `DataFrame` as intended:


![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dabhv2lnap64ko0tdz6p.png)

**5. Understand Your Data**

Finally, understanding the structure of your data and how Pandas handles views versus copies is essential. Reading and being aware of the documentation and tutorials on this topic will help you navigate this issue effectively.

By following these practices, you can confidently handle the "`SettingWithCopyWarning`" in Pandas and ensure your `DataFrame `manipulations work as expected without unexpected side effects.

`LinkedIn Account` : [LinkedIn](https://www.linkedin.com/in/matthew-odumosu/)
`Twitter Account `: [Twitter](https://twitter.com/iamcymentho)
**Credit**: Graphics sourced from [Youtube](https://www.youtube.com/watch?v=GPVsHOlRBBI)
A SHORT SALES STORY
Published: 2023-09-08 10:37:40

After university, I built and sold SCHOOL MANAGEMENT SOFTWARE, this is a program that stores exam and fee payment records of students.

I visited a big school and the teachers introduced me to the accountant. He showed interest in it and asked me to build one for the school, giving me all the details he expected. I also concluded the price with him.

Fast forward 2 months later, I was done and visited the school with the software, expecting to take my money with me home.

  But that day I met the school owner too. The school owner told me that the accountant is not the one to recommend and pay for my service.

 Also, he (the school owner) does not agree with the accountant on how the software was made. Finally, he had already contacted someone else for the program and so the school was not going to move on with mine.

The school owner paid me for the cost of transport and I went back home with my software.
AntDB-Oracle Compatibility Developer’s Manual P3–39
Published: 2023-09-08 10:32:26

##### ADD\_MONTH

The ADD\_MONTHS function adds (or subtracts if the second argument is negative) the specified number of months to the specified date.

The date in the execution result and the date of the month in the given date are the same, unless the specified date is the last day of the month, in which case the resulting date is the last day of the month in the execution result.

Example:

```
SELECT ADD_MONTHS('13-JUN-07',4) FROM DUAL;

ADD_MONTHS('13-JUN-07',4)  
----------------------------
 2007-10-13 00:00:00
(1 row)

SELECT ADD_MONTHS('31-DEC-06',2) FROM DUAL;

ADD_MONTHS('31-DEC-06',2)  
----------------------------
 2007-02-28 00:00:00
(1 row)


SELECT ADD_MONTHS('31-MAY-04',-3) FROM DUAL;

ADD_MONTHS('31-MAY-04',-3)  
-----------------------------
 2004-02-29 00:00:00
(1 row)
```

##### EXTRACT

The EXTRACT function is used to get subfields like year or hour from a date/time field. The return value of the EXTRACT function is of type number. The following are valid field names.

- YEAR

A field indicating the year.

```
SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40') FROM DUAL;

EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40')  
-------------------------------------------------------
                                                2001
(1 row)
```

- MONTH

Indicates the month of the year (1-12).

```
SELECT EXTRACT(MONTH FROM TIMESTAMP '2001-02-16 20:38:40') FROM DUAL;

EXTRACT(MONTH FROM TIMESTAMP '2001-02-16 20:38:40')  
----------------------------------------------------------
                                                    2
(1 row)
```

- DAY

Indicates the date in a month (1-31).

```
SELECT EXTRACT(DAY FROM TIMESTAMP '2001-02-16 20:38:40') FROM DUAL;

EXTRACT(DAY FROM TIMESTAMP '2001-02-16 20:38:40')  
-------------------------------------------------------
                                                 16
(1 row)
```

- HOUR

Indicates the hour field (0-23).

```
SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 20:38:40') FROM DUAL;

EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 20:38:40')  
-----------------------------------------------------
                                                  20
(1 row)
```

- MINUTE

Indicates the minute field (0-59).

```
SELECT EXTRACT(MINUTE FROM TIMESTAMP '2001-02-16 20:38:40') FROM DUAL;

EXTRACT(MINUTE FROM TIMESTAMP '2001-02-16 20:38:40')  
---------------------------------------------------------
                                                    38
(1 row)

```

- SECOND

Indicates the seconds field, including the fractional part (0-59).

```
SELECT EXTRACT(SECOND FROM TIMESTAMP '2001-02-16 20:38:40.45') FROM DUAL;

 EXTRACT(SECOND FROM TIMESTAMP '2001-02-16 20:38:40.45')  
-----------------------------------------------------------
                                                    40.45
(1 row)
```
Using @metamask/sdk-react with React
Published: 2023-09-08 10:30:06

## Introduction

Hello, I'm @calloc134.

I recently participated in the Web3 Hackathon. 
During the event, I needed to connect React with MetaMask.

Normally, one would use `web3.js`, but this time I decided to try another option: `@metamask/sdk-react`.

{% embed https://github.com/MetaMask/metamask-sdk %}

The library appears to be officially developed, but it's still in the development stage and lacks documentation.

So, I describe how to use said library in this blog post.

## How to use

### Installing the Library

First, install the library. 
I'm using pnpm as the package manager.

```sh
pnpm add @metamask/sdk-react
```

### Importing the Library in React

Next, import the library in React. 
To use MetaMask components and hooks, you'll need to wrap your components with a `MetaMaskProvider`. 
Import this near the root of your app.

```tsx
import { MetaMaskProvider } from "@metamask/sdk-react";
(...)

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  <React.StrictMode>
    <MetaMaskProvider
      sdkOptions={{
        dappMetadata: {
          name: "(Your App Name)",
          url: "(Your URL)",
        },
        checkInstallationImmediately: false,
      }}
    >
      (Place children components here)
    </MetaMaskProvider>
  </React.StrictMode>,
);
```

Now, you can use MetaMask components and hooks.

### Embedding the Login Button

To embed the login button provided by MetaMask, you can do the following:

```tsx
import { MetaMaskButton } from "@metamask/sdk-react";
(...)

function App() {
  return (
    <div className="App">
      <MetaMaskButton />
    </div>
  );
}
```

Pressing this button will activate the MetaMask extension in your browser, allowing you to log in.

### Example: Sending Transactions

@metamask/sdk-react provides numerous hooks. Here, I'll show you an example using a hook for sending transactions.

```tsx
import { useSendTransaction } from "@metamask/sdk-react";

(...)

function App() {
  const { data, isSuccess, sendTransaction } = useSendTransaction({
    to: "0x57dc7A6D9Aa8cc04E8fb629C5AC298b02C85F1e4",
    value: BigInt(transaction.amount * 10 ** 18),
  });

  return (
    <div className="App">
      <button onClick={() => sendTransaction()} />
      {isSuccess && <p>Transaction Successful</p>}
    </div>
  );
}
```

## Conclusion
This post introduced how to connect MetaMask with React using `@metamask/sdk-react` as an alternative to `web3.js`. I hope this serves as a useful reference.

## Note

There are other libraries developed by the same team behind this one, and the APIs for their hooks seem to be somewhat similar. If there's no documentation for MetaMask library, you might find the following documents useful:

{% embed https://wagmi.sh/react/getting-started %}
{% embed https://wagmi.sh/examples/connect-wallet %}
AntDB-Oracle Compatibility Developer's Manual P3–37
Published: 2023-09-08 10:16:51

### **Function**

AntDB provides a large number of functions and operators for manipulating the values of built-in data types.

#### Mathematical Functionsfunction

The following table shows the AntDB-compatible Oracle math functions. AntDB supports most implicit type conversions, and uses these functions in a variety of ways by using different argument types. Unless otherwise specified, a function of any form returns the same value as its argument type.

| Function Name| Number of arguments| Description| For example:
|----------|----------|----------|----------
| ABS| 1| Absolute value| ABS(-15)
| BITAND| 2| Bitwise | BITAND(6.3)
| CEIL| 1| Rounding up| CEIL(5.2)
| EXP| 1| nth power of e| EXP(4)
| FLOOR| 1| Rounding down| FLOOR(15.7)
| LN| 1| LN(x), the natural logarithm of x| LN(95)
| LOG| 2| log(x,y) returns the logarithm of the value y with x as the base| LOG(10,100)
| MOD| 2| mod(x,y) returns the remainder of x divided by y| MOD(11.4)
| POWER| 2| power(x, y), yth power of x| POWER(3.2)
| REMAINDER| 2| remainder(x,y), returns the remainder of x divided by y| REMAINDER(bin\_float, bin\_double)
| ROUND (number)| 1~2| ROUND(n \[, integer ]) rounding| round(4.5455, 2) round(4.4)
| SIGN| 1| Return the positive or negative sign of a number| SIGN(-15)
| SQRT| 1| square root| SQRT(26)
| TRUNC (number)| 1~2| TRUNC(n1 \[, n2 ]) truncates to the specified precision| trunc(4.567,2)
| WIDTH\_BUCKET| 4| WIDTH\_BUCKET(x, min, max, num\_buckets), the range MIN to MAX is divided into bainum\_buckets sections, each section has the same du size. Return the section where x is located. If x is less than MIN, 0 will be returned, and if x is greater than or equal to MAX, num\_buckets+1 will be returned. Neither MIN nor MAX can be NULL, and num\_buckets must be a positive integer. If x is NULL, then NULL will be returned.| WIDTH\_BUCKET(credit\_limit, 100, 5000, 10)

The following table shows the allowed trigonometric functions.

| Function Name| Number of arguments| Description| For example:
|----------|----------|----------|----------
| ATAN| 1| anti-tangent| ATAN(.3)
| ATAN2| 2| anti-tangent| ATAN2(.3, .2)
| COS| 1| Cosine| COS(180 \* 3.14159265359/180)
| COSH| 1| hyperbolic cosine| COSH(0)
| ACOS| 1| Inverse cosine, parameter value range (-1, 1)| ACOS(.3)
| SIN| 1| Sine | SIN(30 \* 3.14159265359/180)
| SINH| 1| Returns the hyperbolic sine of x| SINH(1)
| ASIN| 1| Arcine, parameter value range (-1, 1)| ASIN(.3)
| TAN| 1| Tangent | TAN(135 \* 3.14159265359/180)
| TANH| 1| Hyperbolic tangent | TANH(.5)
AntDB-Oracle Compatibility Developer’s Manual P3–36
Published: 2023-09-08 10:14:41

#### Pattern matching using the LIKE operator

AntDB provides the pattern matching function by using the traditional LIKE operator. The syntax for using the LIKE operator is shown below.

string LIKE pattern \[ ESCAPE escape-character ]

string NOT LIKE pattern \[ ESCAPE escape-character ]

Each parameter pattern defines a set of strings. If the set of strings defined by the parameter pattern contains the value of the parameter string, then the LIKE expression returns true. As expected, if the LIKE expression returns true, then the NOT LIKE expression returns false, and vice versa. The equivalent expression to NOT LIKE is NOT (string LIKE pattern).

If the argument pattern does not include a percent sign or underscore, then the pattern only represents the string itself, in which case the LIKE operator and the equals sign have the same effect. An underscore in the pattern indicates matching a single character, while a percent sign indicates matching any string.

**Example:**

```
'abc' LIKE 'abc'	true
'abc' LIKE 'a%'	true
'abc' LIKE '_b_'	true
'abc' LIKE 'c'	false
```

The LIKE pattern match covers the entire string. If you want to match from any position in the string, then the pattern must start with a percent sign and end with a percent sign.

If you want to match only the underscore or the percent sign in the string, then the two characters must be handled separately in the pattern by using the escape character. The default escape character is the backslash, but we can also choose a different escape character by using the ESCAPE clause. If you want to match the escape character itself, then you need to write two escape characters.

Note that the backslash already has a specific meaning in the string, so when the match pattern contains a backslash, you actually have to write 2 backslashes in the SQL statement. Therefore, writing a backslash that contains a backslash in a literal manner means that 4 backslashes must be written in the statement. This can be avoided by using the ESCAPE clause to select a different escape character; thus the backslash has no specific meaning for the LIKE operator (but it still has a specific meaning for the string parser, so 2 backslashes need to be written in the string).

We can also deselect the escape character by using ESCAPE. This effectively disables the escape character mechanism and makes it impossible to turn off the specific meaning of underscores and percent signs in the match pattern.

For example:

```
select 'ab\c' LIKE 'ab\\\c' from dual;
select 'ab\c' LIKE 'abx\c' ESCAPE 'x' from dual; 
```