teleren/devto huggingface dataset:
If S3 buckets are for static file hosting, and not for running server side code, then why do we host react sites on S3?
Published: 2023-03-14 04:32:11

Node.js and Webpack are often used for server-side tasks like bundling and optimizing code. However, in the context of hosting a React app on an S3 bucket, Node.js and Webpack are used during the development and build process, not at runtime on the server.

When you build a React app, you use Node.js and Webpack to bundle your code into a single JavaScript file that can be served to the client. The resulting bundled file contains the client-side JavaScript code that runs in the user's browser, not on the server.

Once the React app is built and bundled, you can deploy the static files to an S3 bucket, which is a simple storage service that can serve files over the internet. When a user visits your React app hosted on S3, their browser downloads the static files from the S3 bucket and runs the JavaScript code on the client-side, not on the server.

In contrast, a Rails or Flask application typically requires server-side code to run, as these applications often generate HTML pages dynamically and handle user requests on the server. This requires a server environment that can run the application code, process incoming requests, and generate responses dynamically.

While Node.js and Webpack are used during the build process of a React app, they are not used to run the application on the server. Hosting a server-side application, such as a Rails or Flask app, requires a different hosting solution than hosting a static website on S3.
LERN WEBDEV from THESE RESOURCES for Best Result!
Tags: webdev, web3, javascript
Published: 2023-03-14 04:30:00

Learn For Free 👇🏻

📄 **HTML** → w3schools
[HTML](https://www.w3schools.com/html/)

🎨 **CSS** → FreeCodeCamp
[CSS](https://www.freecodecamp.org/news/tag/css/)

🔀 **Git/GitHub**→ LearnGitBranching.js .org
[Git](https://learngitbranching.js.org/)

🚀 **Javascript**→ Javascript .info
[Javascript](https://javascript.info/)

🎨 **UI/UX **→ Hackdesign
[Hackdesign](https://hackdesign.org/)

⚛️ **React** → React-tutorial .app
[REACT](https://react-tutorial.app/)

🗃️ **SQL **→ Sqlbolt
[SQL](https://sqlbolt.com/)

🚀 **API** → RapidAPI
[API](https://rapidapi.com/)

🎨 **Tailwind** → Tailwindcss .com
[Tailwind-CSS](https://tailwindcss.com/)

🖥️ **Node** → learn Basics from Youtube
[NODE From Youtube](https://youtu.be/TlB_eWDSMt4)

**IMPORTANT NOTE**
Stay calm * Hydrated * Practice
Orwith as a programmatical concept.
Tags: rust, watercooler
Published: 2023-03-14 04:29:54

One problem I wanted to solve was designating "and/or" to its own word; there are two reasons that motivate me: firstly, because "and/or" is so common it deserves its own concept, and secondly, because I hate '/'s and '-'s in my compound words <sub>("and/or" is not a compound, but other compounds usually do have hyphens in them)</sub>.  
Firstly, before we can look at what "orwith" is as a programmatical concept, we must first know what the term means.
The word "orwith" is a compound of English "or" and English "with", where the two ideas unite.

\[See definition sites: [DeviantArt](https://www.deviantart.com/kattytheenby/journal/Def-Orwith-950684792), [Urban Dictionary](https://www.urbandictionary.com/define.php?term=Orwith)\]
So, what does this word mean? As I said, it can mean "and/or", but formally it is defined as:
> conjunction. 1.) Being accompanied with or replaced by something (as specified in the context); and/or.
>
> preposition. 2.) Indicating that both options are possibilities; "or with".

With this knowledge in mind, we can properly formulate an idea of what this may look like.  
The first step in turning this idea into a programming concept was to basically make an "`AndOr`" `enum`:
```rust
enum Orwith<T> {
    With(T, T),
    Or(T)
}
```
Now, the next thing we need to do is make a function that takes arguments, which represent the two grammatical constituents, and returns a corresponding instance of `Orwith`:
```rust
impl<T> Orwith<T> {
    fn orwith(x:Option<T>, y:Option<T>) -> Self {
        match (x, y) {
            (Some(vx), Some(vy)) => Self::With(vx, vy),
            (Some(v), _) | (_, Some(v)) => Self::Or(v),
            _ => /* ??? */
        }
    }
}
```
Everything is all fine and well here until we get to the `_` case.
Unfortunately, since Rust makes us handle every case, we have to present a new possibility to "and/or" that it wouldn't otherwise have: neither option. To reflect this, the code is changed to:
```rust
enum Orwith<T> {
    Neither,
    With(T, T),
    Or(T)
}
```
With this new `Neither` state, the code should look like this:
```rust
enum Orwith<T> {
    Neither,
    With(T, T),
    Or(T)
}

impl<T> Orwith<T> {
    fn orwith(x:Option<T>, y:Option<T>) -> Self {
        match (x, y) {
            (Some(vx), Some(vy)) => Self::With(vx, vy),
            (Some(v), _) | (_, Some(v)) => Self::Or(v),
            _ => Self::Neither
        }
    }
}
```

Now we have successfully encapsulated the idea of "one being accompanied, or replaced, by another" in a simple `enum`.
To utilize it further, one could utilize it further by giving `Orwith` instance methods to operate with the (possible) values contained. For you, [I have already done this on GitHub in `CalinZBaenen/Orwith`](https://github.com/CalinZBaenen/Orwith).
Observability DR Strategy in AWS: Necessity or Expense?
Tags: aws, observability, security, disasterrecovery
Published: 2023-03-14 04:21:00

Observability is a key concept in modern software development and system engineering, referring to the ability to understand and troubleshoot complex distributed systems. An observability DR strategy is an essential component of maintaining system availability and ensuring that key services can be quickly restored after a disaster. This blog post will focus on observability DR strategies in AWS, outlining key components of an effective plan.

**AWS Observability Services:**

AWS provides several tools for monitoring, troubleshooting, and debugging applications and infrastructure. CloudWatch is the primary monitoring service in AWS, providing metrics, logs, and alarms for AWS resources. AWS X-Ray is a service for tracing and analyzing application performance, while AWS Config helps with resource inventory, compliance, and configuration management. An effective observability DR strategy in AWS should take advantage of these tools to maintain visibility into system health and performance.

**Observability DR Plan for AWS:**

An observability DR plan for AWS should focus on maintaining data backup, redundancy, and failover mechanisms for observability tools and systems. This may include deploying redundant monitoring systems across multiple availability zones, setting up backup data stores, and creating disaster recovery runbooks. To ensure the observability DR plan is effective, it should be tested regularly through failover testing, backup testing, and disaster recovery drills.

**Disaster Recovery Testing:**

Regular testing of the observability DR plan is critical to ensure it works as expected when a disaster occurs. Testing should include failover testing, testing backups, and conducting disaster recovery drills. AWS provides several tools to facilitate testing, such as AWS CloudFormation, which can be used to automate the creation of a test environment.

**Best Practices for Observability DR Strategy in AWS:**

Effective observability DR strategies in AWS should follow best practices, including monitoring key metrics, setting up alarms, and establishing incident response procedures. Other best practices include setting up autoscaling groups for monitoring resources, using AWS Elastic Load Balancers for distributing traffic, and implementing AWS Identity and Access Management (IAM) policies to manage access to observability systems.

In conclusion, an observability DR strategy is an essential component of maintaining system availability and ensuring key services can be quickly restored after a disaster. AWS provides several observability services, and effective observability DR strategies in AWS should focus on maintaining data backup, redundancy, and failover mechanisms, as well as testing regularly and following best practices. By implementing an effective observability DR strategy in AWS, organizations can maintain visibility into system health and performance and quickly respond to any disruptions that occur.
Introduction to JDBC package, driver class and environment class provided by openGauss
Published: 2023-03-14 04:08:47

JDBC package
openGauss provides two kinds of JDBC jar packages: postgresql.jar and openGauss-jdbc-xxxjar. The functions of the two jar packages are the same, just to resolve the JDBC driver package name conflict with PostgreSQL.

Execute build.sh in the source code directory of the Linux server to obtain the driver jar packages postgresql.jar and opengauss-jdbc-xxxjar, which are located in the output directory in the source code. It can also be obtained from the release package on the official website, the package name is openGauss-xxx-JDBC.tar.gz.

The driver package is compatible with PostgreSQL, and the class name and class structure are completely consistent with the PostgreSQL driver. Applications that used to run on PostgreSQL can be directly transplanted to the current system for use.

driver class
illustrate:

openGauss is compatible with the use of PG in the use of JDBC. When loading PostgreSQL and openGauss JDBC drivers with the same name in the same JVM virtual machine, there may be a conflict of org.postgresql.Driver driver class.

Compared with the PG driver, the openGauss JDBC driver has mainly enhanced the following features:

Support SHA256 encrypted login.

Supports docking with third-party logging frameworks that implement the sf4j interface.

Support disaster recovery switching.

Environment
The client needs to configure JDK1.8, the configuration method is as follows:

Enter "java -version" in the DOS window to check the JDK version and confirm that it is JDK1.8. If JDK is not installed, please download the installation package from the official website and install it.

Configure system environment variables according to the following steps.

a. Right-click My Computer and select Properties.

b. Click Advanced System Settings in the left navigation bar of the System page.

c. On the System Properties page, click Environment Variables on the Advanced tab.

d. On the Environment Variables page, click New or Edit in the System Variables area to configure system variables.
openGauss call stored procedure
Published: 2023-03-14 04:05:49

**call stored procedure**
openGauss supports directly invoking pre-created stored procedures through JDBC, the steps are as follows:

Call the prepareCall method of Connection to create a call statement object.

Connection myConn = DriverManager.getConnection("url","user","password");
CallableStatement cstmt = myConn.prepareCall("{? = CALL TESTPROC(?,?,?)}");
Call the setInt method of CallableStatement to set parameters.

cstmt.setInt(2, 50); 
cstmt.setInt(1, 20);
cstmt.setInt(3, 90);
Call the registerOutParameter method of CallableStatement to register the output parameters.

cstmt.registerOutParameter(4, Types.INTEGER);  
Call CallableStatement's execute to execute the method call.

cstmt.execute();
Call the getInt method of CallableStatement to get the output parameters.

int out = cstmt.getInt(4);  
Example:

create or replace procedure testproc 
(
    psv_in1 in integer,
    psv_in2 in integer,
    psv_inout in out integer
)
as
begin
    psv_inout := psv_in1 + psv_in2 + psv_inout;
end;
/
Call the close method of CallableStatement to close the calling statement.

cstmt.close();
illustrate:

Many database classes such as Connection, Statement, and ResultSet have a close() method, and they should be closed after using the objects. It should be noted that the closing of the Connection will indirectly close all the Statements associated with it, and the closing of the Statement will indirectly close the ResultSet.
Some JDBC drivers also provide named parameter methods to set parameters. The method of naming parameters allows parameters to be set by name rather than order. If the parameter has a default value, the default value of this parameter can be used without specifying the parameter value. Even if the order of parameters in a stored procedure changes, the application does not have to be modified. Currently the JDBC driver of the openGauss database does not support this method.
The openGauss database does not support functions with output parameters, nor does it support stored procedures and function parameter default values.
myConn.prepareCall("{? = CALL TESTPROC(?,?,?)}"), when executing the stored procedure binding parameters, you can bind the parameters according to the order of the placeholders, register the first parameter as the output parameter, and also The parameters can be bound according to the order of the parameters in the stored procedure, and the fourth parameter is registered as an output parameter. For the above use case, the fourth parameter is registered as an output parameter.
Notice:

When a cursor is used as the return value of a stored procedure, if the stored procedure is called using JDBC, the returned cursor will not be available.
Stored procedures cannot be executed in the same statement as ordinary SQL.
The inout type parameter in the stored procedure must be registered as an out parameter.
openGauss JDBC driver supports log management
Published: 2023-03-14 04:01:55

log management
The openGauss JDBC driver supports the use of logging to help troubleshoot issues when using the openGauss JDBC driver in applications. openGauss JDBC supports the following three log management methods:

1. The SLF4J log framework used by docking applications.
2. The JdkLogger logging framework used by the docking application.
SLF4J and JdkLogger are the mainstream frameworks for Java application log management in the industry. It is beyond the scope of this article to describe how applications use these frameworks. Users should refer to the corresponding official documents (SLF4J: http://www.slf4j.org/manual.html, JdkLogger: https://docs.oracle.com/javase/8/docs/technotes/guides/logging/overview.html).

Method 1: Connect to the SLF4J log framework of the application.

When establishing a connection, the url configures logger=Slf4JLogger.

SLF4J can be implemented using Log4j or Log4j2. When using Log4j to implement SLF4J, you need to add the following jar packages: log4j-*.jar, slf4j-api-*.jar, slf4j-log4*-*.jar, (* differentiate versions), and configuration files: log4j.properties. If you use Log4j2 to implement SLF4J, you need to add the following jar packages: log4j-api-*.jar, log4j-core-*.jar, log4j-slf4j18-impl-*.jar, slf4j-api-*-alpha1.jar (* distinguish version), and configuration file: log4j2.xml.

This method supports log control. SLF4J can implement powerful log management and control functions through related configurations in files, and it is recommended to use this method for log management.

Note: This method relies on the general API interface of slf4j, such as org.slf4j.LoggerFactory.getLogger(String name), org.slf4j.Logger.debug(String var1), org.slf4j.Logger.info(String var1), org. slf4j.Logger.warn(String warn), org.slf4j.Logger.warn(String warn), etc. If the above interface changes, the log will not be printed.


Method 2: Connect to the JdkLogger logging framework used by the application.

The default Java logging framework stores its configuration in a file named logging.properties. Java installs global configuration files in folders in the Java installation directory. logging.properties files can also be created and stored with individual projects.
JDBC development application program based on openGauss (common data type usage example)
Published: 2023-03-14 03:54:57

JDBC development application program based on openGauss (common data type usage example)

```
//Example of using the bit type, note that the value range of the bit type here is [0,1]
Statement st = conn.createStatement();
String sqlstr = "create or replace function fun_1()\n" +
"returns bit AS $$ \n" +
"select col_bit from t_bit limit 1;\n" +
"$$\n" +
"LANGUAGE SQL;";
st.execute(sqlstr);
CallableStatement c = conn.prepareCall("{ ? = call fun_1( ) }");
//Register output type, bit string type
c.registerOutParameter(1, Types.BIT);
c.execute();
//Use Boolean type to get the result
System.out.println(c.getBoolean(1) );

// Money type usage example
// The table structure contains usage examples of money type columns.
st.execute("create table t_money(col1 money)");
PreparedStatement pstm = conn.prepareStatement("
// Use PGobject to assign value, value range [-92233720368547758.08, 92233720368547758.07]
PGobject minMoney = new PGobject();
minMoney.setType("money");
minMoney.setValue("-92233720368547758.08set")
ney1, pstm ;
pstm.execute();
// Use PGMoney to assign value, value range [-9999999.99,9999999.99]
pstm.setObject(1,new PGmoney(9999999.99));
pstm.execute();

// The return value of the function is money example.
st.execute("create or replace function func_money() " +
"return money " +
"as declare " +
"var1 money; " +
"begin " +
" select col1 into var1 from t_money limit 1; "

"end;");
CallableStatement cs = conn.prepareCall("{? = call func_money()}");
cs.registerOutParameter(1,Types.DOUBLE);
cs.execute();
cs.getObject(1);
```
Zerando HackerRank ( 13 )
Published: 2023-03-14 03:30:10

E no décimo terceiro desafio desta serie que queima os miolos, vamos abordar um problema que envolve a migração de pássaros.
Iremos receber uma array de id's de pássaros e devemos retornar o menor id que menos se repete.
Por Exemplo:

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

Nessa array recebemos 2 id's que se repetem, o número 1 e o número 2.
Precisamos retornar o número 1 por ele ser o valor menor da array.

Nosso imput será assim:

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

Podemos reparar na imagem acima que o primeiro valor corresponde ao número de casas que representam os pássaros.
Logo não usaremos esse primeiro item da nossa array, podemos fazer isso ao utilizar o item dessa array a partir do index 1, assim esse numero não será utilizado.

Para isso nossa função deve fazer 5 coisas:


1- Cria uma variável vazia "counts" para armazenar as contagens de avistamentos de cada tipo de pássaro.

2- Usa um loop forEach para percorrer a matriz "arr" de contagens de avistamentos de pássaros e atualizar a contagem para cada tipo de pássaro na variável "counts".

3- Usa o método Math.max e o spread operator (...) para encontrar o valor máximo das contagens de avistamentos de pássaros na variável "counts".

4- Usa o método Object.keys e o método find para encontrar a chave (ou seja, o tipo de pássaro) correspondente à contagem máxima na variável "counts".

5- Retorna o tipo de pássaro mais comum na área, com base na contagem de avistamentos.

Nossa função vai ficar assim:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ahruz3kmc3isiqwx243.png)
Getting Started with the .NET MAUI Range Selector
Tags: dotnet, dotnetmaui, csharp
Published: 2023-03-14 03:37:52

Learn how easily you can create and configure the Syncfusion .NET MAUI Range Selector using Visual Studio 2022. I demonstrate how to add content; set minimum and maximum values with intervals; and add labels, tooltips, ticks, and dividers. 

_**Product overview**_: https://www.syncfusion.com/maui-controls/maui-range-selector

_**Download an example from GitHub**_: https://github.com/SyncfusionExamples/getting-started-with-the-dotnet-maui-range-selector

_**Refer to the following documentation**_: https://help.syncfusion.com/maui/range-selector/getting-started

_**Check out this GitHub example**_: https://github.com/syncfusion/maui-demos/tree/master/MAUI/Sliders/SampleBrowser.Maui.Sliders/Samples/RangeSelector

{% youtube LrnvOOjQ7jE %}
Understanding the Differences Between Primitive and Object Data Types in JavaScript
Tags: javascript, beginners, programming
Published: 2023-03-14 03:35:56

**JavaScript** is a dynamically typed language, which means that we don't have to explicitly declare the data type of a variable before using it. Instead, the type of the variable is determined at runtime based on the value it holds.

JavaScript has two main categories of data types: _primitives_ and _objects_.

| Primitive Types      | Object Types      |
|----------------------|-------------------|
| Boolean              | Array             |
| Null                 | Date              |
| Undefined            | RegExp            |
| Number               | Map               |
| String               | Set               |

![Primitive and Object Data Type Humor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73w1er44ilbu4mi6iq2m.png)

#### Differences between Primitive Types and Object Types:
When we create a primitive value, it gets stored directly in memory.

Objects, on the other hand, are more complex data types that can contain multiple values and properties. When we create an object, it gets stored in memory, but what actually gets stored is a reference to the location of the object. This means that when we manipulate an object, we are actually manipulating the reference to that object in memory, not the object itself.

Here is a summary of the differences between primitive types and object types:

| Primitive Types    | Object Types                            |
|--------------------|-------------------------------------------|
| Stores a single value directly in memory | Stores a reference to an object in memory |
| Immutable (cannot be changed)         | Mutable (can be changed) |
| Compared by value (checks if two values are the same) | Compared by reference (checks if two references point to the same object) |
| Passed by value (the value is copied) | Passed by reference (the reference is copied) |