teleren/devto huggingface dataset:
SELECT Statement
Tags: opengauss
Published: 2023-03-28 01:27:14

The SELECT statement can be executed to retrieve data from a table or view. The result is stored in a result table, which is called a result set.

Serving as an overlaid filter for a database table, the SELECT statement filters required data from the table using SQL keywords.

Syntax

```
SELECT 
{ * | [column, ...] }
[ FROM from_item [, ...] ];
```
Parameter Description
SELECT list

Specifies the name of a column in the table to be queried. The value can be a part of the column name or all of the column names. The wildcard (*) is used to represent all column names.

Column names can be expressed in the following formats:

Manually input column names which are separated by commas (,)
Columns computed in the FROM clause
FROM clause

Specifies one or more source tables for the SELECT statement. The FROM clause involves multiple elements. The common elements are as follows:

table_name

Specifies the name of a table or view. The schema name can be added before the table name or view name, for example, schema_name.table_name. The table name is the most common element.

subquery

Performs a subquery in the FROM clause. A temporary table is created to save subquery results. For details, see Subqueries.

alias

Gives a temporary alias to a table to facilitate the reference by other queries. For details, see Aliases.

join_type

There are five types. For details, see JOIN.

Examples
Read all data from the customer_t1 table.

```
openGauss=# SELECT * FROM customer_t1;
c_customer_sk | c_customer_id | c_first_name | c_last_name | amount
---------------+---------------+--------------+-------------+--------
          3869 | hello         | Grace        |             |   1000
          3869 | hello         | Grace        |             |   1000
          3869 |               | Grace        |             |
          3869 | hello         |              |             |
          3869 | hello         |              |             |
               |               |              |             |
          6985 | maps          | Joes         |             |   2200
          9976 | world         | James        |             |   5000
          4421 | Admin         | Local        |             |   3000
(9 rows)
```

Read the c_customer_sk and c_customer_id columns from the customer_t1 table.

```
openGauss=# SELECT c_customer_sk,c_customer_id FROM customer_t1;
c_customer_sk | c_customer_id
---------------+---------------
          3869 | hello
          3869 | hello
          3869 |
          3869 | hello
          3869 | hello
               |
          6985 | maps
          9976 | world
          4421 | Admin
(9 rows)
```
Coding using AI
Tags: webdev, beginners, tutorial, ai
Published: 2023-03-28 03:12:19

[![image alt text here](http://img.youtube.com/vi/nmbe8tXyHcM/0.jpg)](http://www.youtube.com/watch?v=nmbe8tXyHcM)

5 AI Tools That Can Generate Code To Help Programmers

1. OpenAI Codex OpenAI Codex is the model based on GPT-3 that powers GitHub Copilot - a tool from GitHub to generate code within mainstream development environments including VS Code, Neovim, JetBrains, and even in the cloud with GitHub Codespaces. ...
2. Tabnine ...
3. CodeT5 ...
4. Polycoder ...
5. Cogram ...
Kubernetes API
Published: 2023-03-28 03:07:10

[![image alt text here](http://img.youtube.com/vi/YvF0-eNROfA/0.jpg)](http://www.youtube.com/watch?v=YvF0-eNROfA)

Kubernetes works with containerd and CRI-O.[6] Its suitability for running and managing large cloud-native workloads has led to widespread adoption of it in the data center. There are multiple distributions of this platform – from ISVs as well as hosted-on cloud offerings from all the major public cloud vendors.
Kubernetes Objects
Tags: webdev, beginners, tutorial, kubernetes
Published: 2023-03-28 03:04:42

[![image alt text here](http://img.youtube.com/vi/luCtnFH7qj8/0.jpg)](http://www.youtube.com/watch?v=luCtnFH7qj8)

Kubernetes Objects are persistent entities in the Kubernetes system that represent state of your cluster. By creating an object, you’re effectively telling the Kubernetes system what you want your cluster’s workload to look like; this is your cluster’s desired state.
983. Leetcode Solution in cpp
Tags: cpp
Published: 2023-03-28 02:57:48

```cpp
class Solution {
 public:
  int mincostTickets(vector<int>& days, vector<int>& costs) {
    int ans = 0;
    queue<pair<int, int>> last7;
    queue<pair<int, int>> last30;

    for (int day : days) {
      while (!last7.empty() && last7.front().first + 7 <= day)
        last7.pop();
      while (!last30.empty() && last30.front().first + 30 <= day)
        last30.pop();
      last7.emplace(day, ans + costs[1]);
      last30.emplace(day, ans + costs[2]);
      ans = min({ans + costs[0], last7.front().second, last30.front().second});
    }

    return ans;
  }
};

```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/minimum-cost-for-tickets
Python IF-ElSE Statement
Tags: webdev, beginners, tutorial, python
Published: 2023-03-28 02:53:01

[![image alt text here](http://img.youtube.com/vi/gkriTqubeiM/0.jpg)](http://www.youtube.com/watch?v=gkriTqubeiM)

In computer programming, we use the if statement to run a block code only when a certain condition is met.

For example, assigning grades (A, B, C) based on marks obtained by a student.

if the percentage is above 90, assign grade A
if the percentage is above 75, assign grade B
if the percentage is above 65, assign grade C
In Python, there are three forms of the if...else statement.

if statement
if...else statement
if...elif...else statement
1. Python if statement
The syntax of if statement in Python is:

if condition:
    # body of if statement
The if statement evaluates condition.

If condition is evaluated to True, the code inside the body of if is executed.
If condition is evaluated to False, the code inside the body of if is skipped.
How if statement works in Python
Working of if Statement
Loops in Python
Tags: webdev, beginners, tutorial
Published: 2023-03-28 02:49:09

[![image alt text here](http://img.youtube.com/vi/jaiYi4GyxO0/0.jpg)](http://www.youtube.com/watch?v=jaiYi4GyxO0)

In computer science a for-loop or for loop is a control flow statement for specifying iteration. Specifically, a for loop functions by running a section of code repeatedly until a certain condition has been satisfied.

For-loops have two parts: a header and a body. The header defines the iteration and the body is the code that is executed once per iteration. The header often declares an explicit loop counter or loop variable. This allows the body to know which iteration is being executed. For-loops are typically used when the number of iterations is known before entering the loop. For-loops can be thought of as shorthands for while-loops which increment and test a loop variable.

Various keywords are used to indicate the usage of a for loop: descendants of ALGOL use "for", while descendants of Fortran use "do". There are other possibilities, for example COBOL which uses "PERFORM VARYING".

The name for-loop comes from the word for. For is used as the keyword in many programming languages to introduce a for-loop. The term in English dates to ALGOL 58 and was popularized in ALGOL 60. It is the direct translation of the earlier German für and was used in Superplan (1949–1951) by Heinz Rutishauser. Rutishauser was involved in defining ALGOL 58 and ALGOL 60.[citation needed] The loop body is executed "for" the given values of the loop variable. This is more explicit in ALGOL versions of the for statement where a list of possible values and increments can be specified.

In Fortran and PL/I, the keyword DO is used for the same thing and it is called a do-loop; this is different from a do-while loop.
3 Scratch Smoothness tips
Published: 2023-03-28 02:14:30


Hey,
Here I'll show you how to make your Scratch projects very smooth and crisp. I'm really obsessed with smoothness and I hope this tutorial will help you a lot. Note that I am using Scratch addons so my screen looks different from yours, but that's okay.

## The Smooth Size Algorithm
![The smooth size change algorithm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzf3ta8znsib1ss9mlfa.png)

This is the first algorithm I'd like to show you, what it does is basically it makes the size of an object smoothly change to a target-size so that it doesn't do it immediately. In the example of this algorithm's use above the sprite with this code inside it will smoothly grow when it is hovered over by the mouse cursor. the "targetsize" input is the normal size of the sprite which you can set to anything you like.

## The Smooth Flying Algorithm
![The flying over algorithm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8iyqzi580w2q3co5s0dt.png)

This is an algorithm so that an object smoothly zooms to your mouse cursor and doesn't just stick to it. The "Polish" variable is there so that you see that this isn't a value you have to copy from me, but modify according to your needs.

## ALWAYS ROUND CORNERS
![Squares with rounded corners](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6btltzg5w6t5g6oiyuyh.png)
In UI/UX there is a rule, round corners whenever possible and so that it fits with the theme. If your theme is blocky keep it, but blockiness just doesn't fit with all the fancy algorithms you've learned here so stick to the rule and round your corners.
"An Introduction to Types in TypeScript: Built-In Types, Type Annotations, Interfaces, and Classes"
Published: 2023-03-28 02:12:35


TypeScript is a statically typed superset of JavaScript that adds optional type annotations to the language. In TypeScript, you can specify types for variables, function parameters, function return types, and object properties. TypeScript provides a number of built-in types, as well as the ability to create custom types using interfaces and classes.

Here are some of the built-in types in TypeScript:

- `number`: represents numeric values, including integers and floating-point numbers.

- `string`: represents string values.
- `boolean`: represents boolean values (true/false).
- `null`: represents the absence of a value.
- `undefined`: represents a value that has not been defined.
- `void`: represents the absence of a return value from a function.
- `any`: represents any type of value, and can be used to opt out of 
type checking for a specific value.
- `never`: represents a value that will never occur, such as a function that always throws an error.
To specify a type for a variable, function parameter, or function return type, you can use a colon followed by the type. For example:

```
let myNumber: number = 42;
let myString: string = 'hello';
let myBoolean: boolean = true;

function addNumbers(a: number, b: number): number {
  return a + b;
}

```
In the example above, we've used type annotations to specify the types of the `myNumber`, `myString`, and `myBoolean` variables, as well as the `a`, `b`, and return types of the `addNumbers` function.

You can also create custom types in TypeScript using interfaces and classes. Interfaces define a shape for an object, specifying the names and types of its properties. For example:

```
interface Person {
  firstName: string;
  lastName: string;
  age: number;
}

let person: Person = {
  firstName: 'John',
  lastName: 'Doe',
  age: 42,
};

```
In the example above, we've defined an interface `Person` with three properties: `firstName`, `lastName`, and `age`. We've then created an object that conforms to this interface and assigned it to the `person` variable.

Classes in TypeScript are similar to classes in other object-oriented languages, and can include properties and methods with specified types. For example:

```
class Animal {
  name: string;

  constructor(name: string) {
    this.name = name;
  }

  speak(): void {
    console.log(`${this.name} makes a noise.`);
  }
}

class Dog extends Animal {
  breed: string;

  constructor(name: string, breed: string) {
    super(name);
    this.breed = breed;
  }

  speak(): void {
    console.log(`${this.name} barks.`);
  }
}

let myDog: Dog = new Dog('Fido', 'Labrador');
myDog.speak(); // output: "Fido barks."

```
In the example above, we've defined a class `Animal` with a `name` property and a `speak` method. We've then defined a `Dog` class that extends `Animal` and adds a `breed` property and a custom `speak` method. We've created a new instance of `Dog` and assigned it to the `myDog` variable, and called the `speak` method on it.

I hope this gives you a good introduction to types in TypeScript.
Planned structure for link in bio page
Published: 2023-03-28 02:08:18

RyanMertz3.github.io/
│
├─ .gitignore
├─ README.md
├─ index.html
│
├─ pages/
|   ├─ home/links
|   |        ├─ Linkedin
|   |        ├─ Github
|   |        ├─ GitLab
|   |        └─ Drop Down [exercism, treehouse, codeacadamy]
│   ├─ about.html
│   ├─ contact.html
│   └─ blog/
│       ├─ post-1.html
│       └─ post-2.html
│
├─ assets/
│   ├─ css/
│   │   ├─ main.css
│   │   └─ responsive.css
│   │
│   ├─ images/
│   │   ├─ logo.png
│   │   ├─ banner.jpg
│   │   ├─ profile_picture.jpg
│   │   └─ blog/
│   │       ├─ blog-post-1.jpg
│   │       └─ blog-post-2.jpg
│   │
│   └─ js/
│       └─ main.js
│
└─ templates/
    ├─ header.html
    └─ footer.html
Testing useNavigate
Tags: jest, testing, javascript, beginners
Published: 2023-03-28 01:29:12

This will be a short post where i will show you how to test useNavigate the right way when used in a react component.

First we will mock the react-router-dom, and then inside the mock, we will define useNavigate with the 'mockedUsedNavigate' variable.

```js
const mockedUsedNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
    ...(jest.requireActual('react-router-dom')),
    useNavigate: () => mockedUsedNavigate,
}))
```

After mocking it we will describe the test and actually doing the testing


We will render the component which in this case is 'Test', afet this we will call the divElement and afterwards we will fire an event simulating an onClick event to the divElement.
Finally we will check if mockedUsedNavigate is actually being called.
```js
describe('Test component', () => {

    it('should render the navigate of it', () => {
       
        const setUp = () => {
            const {getAllByTestId} = render(
                    <Test/>
            )
            const divElement = getAllByTestId('navigateCart')[0];
            return {
                divElement,
            }
        }
    
        const {divElement} = setUp();
        fireEvent.click(divElement)
        expect(mockedUsedNavigate).toBeCalled()
        mockedUsedNavigate.mockRestore();
```


Hope someone found it useFul.

Lautaro
Creating a Table
Tags: opengauss
Published: 2023-03-28 01:24:05

Create an empty table in the current database. The table will be owned by the creator. The same table can be stored in different databases. You can execute the CREATE TABLE statement to create a table.

**Syntax**

```
CREATE TABLE table_name 
    (column_name data_type [, ... ]);
```

**Parameter Description**

- table_name

Specifies the name of the table to be created.

- column_name

Specifies the name of the column to be created in the new table.

- data_type

Specifies the data type of the column.

**Examples**

Run the following commands to create a table named customer_t1. The table columns are c_customer_sk, c_customer_id, c_first_name, and c_last_name. The data types of the table columns are integer, char (5), char (6), and char (8), respectively.

openGauss=# CREATE TABLE customer_t1
(
    c_customer_sk             integer,
    c_customer_id             char(5),
    c_first_name              char(6),
    c_last_name               char(8),
    Amount                    integer
);

If the following information is displayed, the table has been created:

```
 CREATE TABLE
```
LGTM - why it's scary
Tags: lgtm, codereviewvillains, programming, productivity
Published: 2023-03-28 01:17:51

Why is LGTM scary?  We don't know if the reviewer reviewed it, spent time to understand the code change, know what the code is supposed to do, etc.  As a senior eng, sometimes I wanted to steer the review to be thorough, but inspection doesn't scale...enter GPT.
Blog post about recreating website badges querying system- week 11
Tags: webdev, beginners, programming, javascript
Published: 2023-03-28 01:12:59


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

This screenshot is the current state of the project to recreate the badges page that Liz and I are working on, only frontend developed

1- How did you start?

We started trying to recreate the template by going to the home website and using a tool called SnipCSS (chrome extension) that allows us to click on an element and copy it's style/html. We did this for all the necessary elements, put it in our own code, and trimmed a lot of "fat" off of the copied code because most of it did nothing.

2- What did you decide to attack first?

The frontend looks, because without that we cannot have any coherent basis. Liz worked on the badges as I worked on the search bar.

3- What issues have you had?

Most of our current issues stem from looking at the ocean of copied code from the base website, there really was a lot of material that was completely unnecessary and only served to make understanding the site/element layout confusing.

Then with the useful bits that we had left, we had to reverse engineer each element/class/thing to look at what needed to be done to then fit it into the standard of how we wanted it to look. We encountered some dependency problems along the way.

4- What concepts translated from Project 1's card?

Project 1's card really helped with basic understanding of workflow and syntax, and where to find things. Certain concepts that translated over were mostly debugging related, like how efficiently find why an element wasn't doing what it was asked because of dependencies.

5- What's your next priority?

To flesh out the overall presentation of the frontend and polish any quirks, and then to tackle the backend when we are ready.

6- What problems are you unsure of how to solve?

Too many to name, but one would be why certain CSS attributes don't apply to certain classes in a div but others in the same div work just fine.

The backend will also be tough and we might need some direction on how to navigate it.
Installation of One Primary and One Standby Nodes
Tags: opengauss
Published: 2023-03-28 01:06:19

Procedure
1.Create a user group dbgroup.

```
groupadd dbgroup

```
Create a common user omm in the dbgroup user group and set the password to Gauss_234.

```
useradd -g dbgroup omm
passwd Gauss_234
```

3.Log in to the host where the package is installed as user omm and decompress the openGauss package to the installation directory (for example, /opt/software/openGauss).

```
tar -jxf openGauss-x.x.x-openEuler-64bit.tar.bz2 -C /opt/software/openGauss
```

4.Assume that the decompressed package is stored in the /opt/software/openGauss directory. Go to the simpleInstall directory.

```
cd /opt/software/openGauss/simpleInstall

```
5.Run the install.sh script to install openGauss.

```
sh install.sh  -w xxxx  --multinode

```
In the preceding command, -w indicates the initial database password (specified by gs_initdb). This parameter is mandatory for security purposes.

6.After the installation is complete, check whether the process is normal by using ps and gs_ctl.

```
ps ux | grep gaussdb
gs_ctl query -D /opt/software/openGauss/data/master
```

Run the ps command to display information similar to the following:

```
omm  4879 11.8 1.1 2082452 373832 pts/0  Sl   14:26   8:29 /opt/software/openGauss/bin/gaussdb -D /opt/software/openGauss/data/master -M primary

omm  5083  1.1  0.9 1819988 327200 pts/0  Sl   14:26   0:49 /opt/software/openGauss/bin/gaussdb -D /opt/software/openGauss/data/slave -M standby

omm      20377  0.0  0.0 119880  1216 pts/0    S+   15:37   0:00 grep --color=auto gaussdb
```

Run the gs_ctl command to display information similar to the following:


```
gs_ctl query ,datadir is /opt/software/openGauss/data/master
HA state:
    local_role                     : Primary
    static_connections             : 1
    db_state                       : Normal
    detail_information             : Normal

Senders info:
    sender_pid                     : 5165
    local_role                     : Primary
    peer_role                      : Standby
    peer_state                     : Normal
    state                          : Streaming
    sender_sent_location           : 0/4005148
    sender_write_location          : 0/4005148
    sender_flush_location          : 0/4005148
    sender_replay_location         : 0/4005148
    receiver_received_location     : 0/4005148
    receiver_write_location        : 0/4005148
    receiver_flush_location        : 0/4005148
    receiver_replay_location       : 0/4005148
    sync_percent                   : 100%
    sync_state                     : Sync
    sync_priority                  : 1
    sync_most_available            : Off
    channel                        : 10.244.44.52:27001-->10.244.44.52:35912

 Receiver info:
No information 
```
gsql Connection and Usage
Tags: opengauss
Published: 2023-03-28 00:54:24

gsql Connection and Usage
gsql provided by openGauss is a database connection tool running in the CLI. gsql provides basic and advanced functions of databases to facilitate user operations. This section describes how to use gsql to connect to a local database. You need to provide a database name and a port number of the primary database node.

1.Log in as the OS user omm to the primary node of the database.

2.Connect to a database.

After the database is installed, a database named postgres is generated by default. When connecting to a database for the first time, you can connect to this database.

Run the following command to connect to the postgres database:


```
gsql -d postgres -p 8000
```

postgres is the name of the database to be connected, and 8000 is the port number of the database primary node. Replace the values as required.

If information similar to the following is displayed, the connection succeeds:


```
gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# 
```
User omm is the administrator, and DBNAME=# is displayed. If you log in to and connect to the database as a common user, DBNAME=> is displayed, prompting you to enter SQL statements.

Non-SSL connection indicates that the database is not connected in SSL mode.

3.You are advised to change the password upon the first login to improve security. The command is as follows:


```
openGauss=# ALTER ROLE omm IDENTIFIED BY 'XXXXXXXX' REPLACE 'XXXXXXXX';
```

_ NOTE:

Contain at least eight characters.
Cannot be the same as the username, the current password, or the current password in an inverted sequence.
Contain at least three of the following: uppercase characters (A to Z), lowercase characters (a to z), digits (0 to 9), and other characters (limited to ~!@#$%^&*()-_=+|[{}];:,<.>/?).
The SSL certificate is generated during the installation. The certificate is stored in {gaussdbAppPath}/share/sslcert/om, where {gaussdbAppPath} is the program installation directory specified in the openGauss configuration file of the cluster._

4.gsql provides advanced functions for you to use the database.

The gsql program has some meta-commands that are not SQL commands. They begin with a backslash (\). For example:

(1).You can run the following command to query the openGauss version and copyright information:

```
openGauss=# \copyright
```
(2).You can run the following command to obtain the help syntax of various openGauss SQL commands:

```
openGauss=# \h
```
(3).You can run the following command to query all data and description information in the openGauss:

```

openGauss=# \l
```
5.Exit the database.

""

```
openGauss=# \q
```
By default, a client is automatically disconnected if it remains idle for a period longer than 10 minutes (the default value of session_timeout) after connecting to the database.