teleren/devto huggingface dataset:
１３章52
Published: 2024-05-01 00:50:38

Javaプログラムの中で`Test`クラスと`Main`クラスの役割を詳しく解説します。コメントアウトを通じて各クラスとメソッドの機能を明確にします。

```java
// Testクラス: 特定の数値(num)を管理し、その数値に対して操作を行うためのクラス
class Test {
    public int num;   // インスタンス変数num、外部からアクセス可能

    // コンストラクタ: Testオブジェクトを作成する際に初期値を設定する
    public Test(int num) {
        this.num = num; // 引数で受け取った値をインスタンス変数numに設定
    }

    // getNumメソッド: 現在のnumの値を返す
    public int getNum() {
        return num;
    }

    // modifyメソッド: 引数で指定された値を現在のnumに加算する
    public void modify(int x) {
        num += x;
    }
}

// Mainクラス: プログラムの実行を開始するためのクラス
public class Main {
    // mainメソッド: Javaプログラムの実行入口
    public static void main(String[] args) {
        Test t = new Test(100);  // Testインスタンスを作成し、numを100で初期化
        System.out.println(t.getNum()); // 初期化直後のnumの値（100）を出力

        // コメントで示された選択肢を実行する場所
        // 例えば、t.num = 0; または t.modify(-t.getNum()); をここに挿入
    }
}
```

### 役割の説明
- **Testクラス**はデータ（この場合は整数`num`）の保持と、そのデータに対する操作（加算など）を提供します。これにより、データの状態を管理しやすくなっています。
- **Mainクラス**はプログラムの実行を開始する役割があります。ここから`Test`クラスのインスタンスを生成し、特定の操作を実行して、その結果を検証または表示します。

この構造により、データ操作のロジックを`Test`クラスにカプセル化することができ、`Main`クラスでは具体的な操作を通じてその動作をテストまたは利用することができます。これにより、コードの再利用性と保守性が向上します。
Introduction to Edge Computing
Tags: webdev, javascript, beginners
Published: 2024-05-01 00:32:58


## Introduction

Edge computing is a rapidly growing technology that has revolutionized the way data is processed and managed. It is a distributed computing paradigm that brings processing power closer to the source of data generation. In simple terms, edge computing involves moving the computation and data storage closer to the data source, rather than relying on a centralized location such as a cloud or data center. This allows for faster data processing, reduced latency, and improved efficiency.

## Advantages of Edge Computing

1. **Reduced Latency:** Edge computing reduces the delay in data transmission by processing data closer to the source. This is particularly beneficial for applications that require real-time processing, such as self-driving cars or virtual reality.

2. **Cost-Effective:** By distributing the computing power, edge computing lowers the cost of data processing and storage. It eliminates the need for expensive server farms and reduces data transfer costs, making it an attractive option for businesses.

3. **Increased Reliability:** Edge computing increases reliability by minimizing the risk of network failures or disruptions. With data being processed locally, even if there is a network outage, critical operations can still continue.

## Disadvantages of Edge Computing

1. **Security Concerns:** With data being processed and stored at the edge, there is an increased risk of cyber-attacks, as there are more points of entry for hackers.

2. **Complexity:** Implementing edge computing requires additional infrastructure and systems, making it a complex process for organizations to adopt.

## Features of Edge Computing

1. **Decentralized Processing:** In edge computing, processing power is spread between different devices, reducing the load on a single device and distributing it among many.

2. **Autonomous Operations:** With edge computing, devices can operate autonomously, even without a constant connection to the cloud or a data center.

## Conclusion

Edge computing has proven to be a game-changer in the world of technology, allowing for faster and more efficient data processing. While it has its advantages and disadvantages, the potential benefits outweigh the concerns. As more and more devices become connected, edge computing will continue to play a crucial role in managing and processing data in the future.
Where this command comes from?
Tags: linux, ubuntu
Published: 2024-05-01 00:08:24

The `which` command gives you the local path of it:

```
$ which redis-cli
/usr/bin/redis-cli
```

And, if you are using a Debian based distro, you can combine it with `dpkg` to figure it out from which package does it comes from:

```
$ dpkg -S `which redis-cli` 
redis-tools: /usr/bin/redis-cli
```
Welcome Thread - v274
Tags: welcome
Published: 2024-05-01 00:00:00

---
published_at : 2024-05-01 00:00 +0000
---
![Robotic hand with text over it that reads "hey"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wg2mikdxhhomxzmpau1g.gif)

---

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

3. Share your wins from this week in our weekly ["What was your win this week?](https://dev.to/t/weeklyretro) thread.
code problem
Published: 2024-04-30 23:25:53

i have a problem with my code when i send to my database no data sent const express = require("express");
const mysql = require("mysql");
const cors = require("cors");

const app = express();
app.use(express.json());
app.use(cors());

db = mysql.createConnection({
  host: "localhost",
  password: "1234Pro",
  database: "logintuto",
});

app.post("/register", (req, res) => {
  const name = req.body.name;
  const password = req.body.password;

  db.query(
    "INSERT INTO login (name, password) VALUES (?, ?)",
    [name, password],
    (err, result) => {
      if (err) {
        console.error(err);
        res.status(500).send("Erreur lors de l'insertion des données.");
      } else {
        res.status(200).send("Données insérées avec succès.");
      }
    }
  );
});

app.listen(3002, () => {
  console.log("running");
});
  import { useState } from "react";
import axios from "axios";

function App() {
  const register = () => {
    axios
      .post("http://localhost:3002/register", {
        name: name,
        password: password,
      })
      .then((response) => {
        console.log(response.data); // Afficher la réponse du serveur
      })
      .catch((error) => {
        console.error(error); // Gérer les erreurs
      });
  };

  const [name, setName] = useState("");
  const [password, setPassword] = useState("");
  return (
    <div className="app">
      <div>
        <h2>Registration</h2>
        <label>name</label>
        <input
          type="text"
          value={name}
          onChange={(e) => {
            setName(e.target.value);
          }}
        />

        <label>password</label>
        <input
          type="password"
          value={password}
          onChange={(e) => {
            setPassword(e.target.value);
          }}
        />
        <button onClick={register}>envoyer</button>
      </div> can someone help
950. Reveal Cards In Increasing Order
Tags: php, leetcode, programming, algorithms
Published: 2024-04-30 22:32:18

950\. Reveal Cards In Increasing Order

Medium

You are given an integer array `deck`. There is a deck of cards where every card has a unique integer. The integer on the <code>i<sup>th</sup></code> card is `deck[i]`.

You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck.

You will do the following steps repeatedly until all cards are revealed:

1. Take the top card of the deck, reveal it, and take it out of the deck.
2. If there are still cards in the deck then put the next top card of the deck at the bottom of the deck.
3. If there are still unrevealed cards, go back to step 1. Otherwise, stop.

Return <i>an ordering of the deck that would reveal the cards in increasing order</i>.

**Note** that the first entry in the answer is considered to be the top of the deck.



**Example 1:**

- **Input:** <code>**deck = [17,13,11,2,3,5,7]**</code>
- **Output:** <code>**[2,13,3,11,5,17,7]**</code>
- **Explanation:**
  - <code>**We get the deck in the order [17,13,11,2,3,5,7] (this order does not matter), and reorder it**</code>.
  - <code>**After reordering, the deck starts as [2,13,3,11,5,17,7], where 2 is the top of the deck**</code>.
  - <code>**We reveal 2, and move 13 to the bottom.  The deck is now [3,11,5,17,7,13]**</code>.
  - <code>**We reveal 3, and move 11 to the bottom.  The deck is now [5,17,7,13,11]**</code>.
  - <code>**We reveal 5, and move 17 to the bottom.  The deck is now [7,13,11,17]**</code>.
  - <code>**We reveal 7, and move 13 to the bottom.  The deck is now [11,17,13]**</code>.
  - <code>**We reveal 11, and move 17 to the bottom.  The deck is now [13,17]**</code>.
  - <code>**We reveal 13, and move 17 to the bottom.  The deck is now [17]**</code>.
  - <code>**We reveal 17**</code>.
  - <code>**Since all the cards revealed are in increasing order, the answer is correct**</code>.

**Example 2:**

- **Input:** <code>**deck = [1,1000]**</code>
- **Output:** <code>**[1,1000]**</code>



**Constraints:**

- `1 <= deck.length <= 1000`
- <code>1 <= deck[i] <= 10<sip>6</sup></code>
- All the values of `deck` are **unique**.


**Solution:**

```
class Solution {

    /**
     * @param Integer[] $deck
     * @return Integer[]
     */
    function deckRevealedIncreasing($deck) {
        $deque_cards = new SplDoublyLinkedList();    
        rsort($deck);
        foreach ($deck as $card) {
            if (!$deque_cards->isEmpty()) {
                $deque_cards->unshift($deque_cards->pop());
            }
            $deque_cards->unshift($card);
        }     
        return iterator_to_array($deque_cards);
    }
}
```


**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
SLOT GACOR MULIAJP
Published: 2024-04-30 22:56:41

MuliaJP Situs Slot Gacor Gampang Menang di Tahun 2024 MuliaJP adalah situs judi online terbaik di Indonesia saat ini , yang menyediakan berbagai jenis permainan judi online, mulai dari judi bola, casino online, poker online, slot online, hingga togel online. MuliaJP telah menjamin keamanan dan perlindungan seluruh data pribadi para pemain. MuliaJP juga menyediakan bonus dan promo menarik yang dapat dimanfaatkan oleh para pemain untuk meningkatkan peluang mereka dalam meraih kemenangan. Ada banyak jenis bonus yang tersedia, seperti bonus deposit, bonus cashback, dan bonus referral yang dapat diperoleh dengan mudah .
MuliaJP sebagai situs judi slot online, MuliaJP menyediakan beragam permainan slot online dengan berbagai tema dan konsep yang menarik dan juga fitur bonus yang menguntungkan. Selain itu, para pemain juga dapat menikmati fitur-fitur seperti jackpot progresif yang memberikan kesempatan untuk memenangkan hadiah yang sangat besar.
678. Valid Parenthesis String
Tags: php, leetcode, algorithms, programming
Published: 2024-04-30 22:37:03

678\. Valid Parenthesis String

Medium

Given a string `s` containing only three types of characters: `'('`, `')'` and `'*'`, return `true` if `s` is **valid**.

The following rules define a **valid** string:

* Any left parenthesis `'('` must have a corresponding right parenthesis `')'`.
* Any right parenthesis `')'` must have a corresponding left parenthesis `'('`.
* Left parenthesis `'('` must go before the corresponding right parenthesis `')'`.
* '*' could be treated as a single right parenthesis `')'` or a single left parenthesis `'('` or an empty string `""`.

**Example 1:**

**Input:** <code>**s = "()"**</code>
**Output:** <code>**true**</code>

**Example 2:**

**Input:** <code>**s = "(*)"**</code>
**Output:** <code>**true**</code>

**Example 3:**

**Input:** <code>**s = "(*))"**</code>
**Output:** <code>**true**</code>

**Constraints:**

* `1 <= s.length <= 100`
* `s[i]` is `'(', ')'` or `'*'`.

**Solution:**

```
class Solution {

    /**
     * @param String $s
     * @return Boolean
     */
    function checkValidString($s) {
        $lower = 0;
        $upper = 0;
        for ($i = 0; $i < strlen($s); $i++) {
            $lower += ($s[$i] == '(') ? 1 : -1;
            $upper -= ($s[$i] == ')') ? 1 : -1;
            if ($upper < 0) break;
            $lower = max($lower, 0);
        }
        return $lower == 0;
    }
}
```


**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
1249. Minimum Remove to Make Valid Parentheses
Tags: php, leetcode, algorithms, programming
Published: 2024-04-30 22:29:00

1249\. Minimum Remove to Make Valid Parentheses

Medium

Given a string s of `'('` , `')'` and lowercase English characters.

Your task is to remove the minimum number of parentheses ( `'('` or `')'`, in any positions ) so that the resulting parentheses string is valid and return **any** valid string.

Formally, a <i>parentheses string</i> is valid if and only if:

* It is the empty string, contains only lowercase characters, or
* It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid strings, or
* It can be written as `(A)`, where `A` is a valid string.



**Example 1:**

- **Input:** s = "lee(t(c)o)de)"
- **Output:** "lee(t(c)o)de"
- **Explanation:** "lee(t(co)de)" , "lee(t(c)ode)" would also be accepted.

**Example 2:**

- **Input:** s = "a)b(c)d"
- **Output:** "ab(c)d"

**Example 3:**

- **Input:** s = "))(("
- **Output:** ""
- **Explanation:** An empty string is also valid.



**Constraints:**

* <code>1 <= s.length <= 10<sup>5</sup></code>
* `s[i]` is either`'('` , `')'`, or lowercase English letter`.`

**Solution:**

```
class Solution {

    /**
     * @param String $s
     * @return String
     */
    function minRemoveToMakeValid($s) {
        $stack = [];
        $openCount = 0;

        for ($i = 0; $i < strlen($s); $i++) {
            $char = $s[$i];
            if ($char == ')' && $openCount == 0) {
                continue;
            }
            
            if ($char == '(') {
                $openCount++;
            } elseif ($char == ')') {
                $openCount--;
            }
            $stack[] = $char;
        }

        $openCount = 0;
        $answer = [];
        for ($i = count($stack) - 1; $i >= 0; $i--) {
            $char = $stack[$i];
            if ($char == '(' && $openCount == 0) {
                continue;
            }
            if ($char == ')') {
                $openCount++;
            } elseif ($char == '(') {
                $openCount--;
            }
            $answer[] = $char;
        }
        return implode('', array_reverse($answer));
    }
}
```


**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
Day 955 : Time to
Tags: hiphop, code, coding, lifelongdev
Published: 2024-04-30 22:25:12

_liner notes_:
- Professional : Started the day off with 3 back to back meetings. Made a couple of small changes to the developer documentation. Then I dived into my project. I fixed an issue I ran into yesterday and made a bunch more progress. Next thing I know, the day is over.

- Personal : Last night, I went through some tracks for the radio show. I added some authorization logic to my current side project. I set up an application on a service that will be providing some of the real time communications I plan on implementing. I got the domain names worked out so they point to the project. I have two because when a person hears the URL, there like 2 ways they could possibly spell it. Don't think I got a chance to watch any episodes of "X-Men: The Animated Series". I had some Google Play credits that were expiring so I picked up a book on how to draw cartoons. I'm looking to get back into drawing. Could be useful for presentations and stuff.

![﻿ The photo shows a rocky shore with large crashing waves. The water is a gradient of deep blue to light blue color. There are some rocks under the water and some rocks closer to shore. The location is Cape Point, South Africa.﻿](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1o4xmyy9cniqeq95lek9.jpg)

Tonight, I'm going to focus on generating the credentials need to do the real time communications for my side project. To test it, I'll need to create a test sample. I may use my project for work since I'll be giving a demo later this week. Let's see how far I can go. I may skip going through tracks for the radio show. I'll see what time is looking like. Speaking of time, time to eat and get to work.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube KynKRojLv6A %}
1915. Number of Wonderful Substrings
Tags: php, leetcode, algorithms, programming
Published: 2024-04-30 22:23:44

1915\. Number of Wonderful Substrings

Medium

A **wonderful** string is a string where at **most one** letter appears an **odd** number of times.

- For example, `"ccjjc"` and `"abab"` are wonderful, but `"ab"` is not.

Given a string `word` that consists of the first ten lowercase English letters (`'a'` through `'j'`), return _the **number of wonderful non-empty substrings** in `word`. If the same substring appears multiple times in `word`, then count **each occurrence** separately_.

A **substring** is a contiguous sequence of characters in a string.

**Example 1:**

- **Input:** word = "aba"
- **Output:** 4
- **Explanation:** The four wonderful substrings are underlined below:
  - "aba" -> "a"
  - "aba" -> "b"
  - "aba" -> "a"
  - "aba" -> "aba"

**Example 2:**

- **Input:** word = "aabb"
- **Output:** 9
- **Explanation:** The nine wonderful substrings are underlined below:
  - "aabb" -> "a"
  - "aabb" -> "aa"
  - "aabb" -> "aab"
  - "aabb" -> "aabb"
  - "aabb" -> "a"
  - "aabb" -> "abb"
  - "aabb" -> "b"
  - "aabb" -> "bb"
  - "aabb" -> "b"
  
**Example 3:**

- **Input:** word = "he"
- **Output:** 2
- **Explanation:** The two wonderful substrings are underlined below:
  - "he" -> "h"
  - "he" -> "e"

**Constraints:**

- <code>1 <= word.length <= 10<sup>5</sup></code>
- `word` consists of lowercase English letters from `'a'` to `'j'`.

**Solution:**

```
class Solution {

    /**
     * @param String $word
     * @return Integer
     */
    function wonderfulSubstrings($word) {
        $ans = 0;
        $prefix = 0;
        $count = array_fill(0, 1024, 0);
        $count[0] = 1;

        foreach(str_split($word) as $c) {
            $prefix ^= 1 << ord($c) - ord('a');
            $ans += $count[$prefix];
            for ($i = 0; $i < 10; ++$i)
                $ans += $count[$prefix ^ 1 << $i];
            ++$count[$prefix];
        }

        return $ans;
    }
}
```


**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
Pathfinding
Tags: devlog, snowfall
Published: 2024-04-30 22:19:41

Working on pathfinding. The below checks the neighborhood of the path (not just the `to` and `from` tiles) to prefer moving in "open space." The idea is to use this to procedurally generate roads and paths between spaces.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sig5gp2035ea8imy3of5.png)
GETTING STARTED WITH HTML EP5
Tags: webdev, programming, beginners, css
Published: 2024-04-30 21:31:21

In the upcoming episode, we'll delve deeper into the world of HTML by exploring some advanced concepts and techniques. Here's what you can expect:

1. **Semantic HTML**: We'll discuss the importance of semantic HTML and how using semantic elements like `header`, `footer`, `nav`, and `section` can improve accessibility and search engine optimization (SEO).

2. **Forms**: We'll learn how to create interactive forms using HTML elements such as `form`, `input`, `select`, and `button`. You'll discover how to collect user input and submit it to a server.

3. **Images and Multimedia**: We'll explore how to embed images and multimedia content, such as videos and audio, into your web pages using HTML tags like 
img`, `video`, and `audio`.

4. **CSS Integration**: We'll touch on the basics of cascading style sheets (CSS) and how to link external CSS files to your HTML document to style and customize the appearance of your web pages.

5. **Responsive Design**: We'll introduce the concept of responsive web design and how to create websites that adapt and display properly on various devices and screen sizes.

Get ready for an exciting episode packed with valuable information and practical examples to take your HTML skills to the next level!

Stay tuned for more updates and don't forget to subscribe. See you in the next episode!
Learn SwiftUI (Day 5/100)
Tags: swift
Published: 2024-04-30 21:16:44

## Swift

* if - else
* if - else if - else
* switch - case - default - fallthrough
* ternary

```swift
import Cocoa

// ## Conditions
// if
var username = ""
if username.count == 0 {
    print("empty")
} else {
    print("not empty")
}
username = "john doe"
if username.isEmpty {
    print("empty")
} else {
    print("not empty")
}

// if - else if - else
let a = false
let b = true
if a {
    print("Code to run if a is true")
} else if b {
    print("Code to run if a is false but b is true")
} else {
    print("Code to run if both a and b are false")
}

// && - and, || - or
/*
 if temp > 20 && temp < 30 {}
 if userAge >= 18 || hasParentalConsent == true {}
 */

// ## switch - case
let place = "Metropolis"

// You must list all outcomes as case statements or use default.
switch place {
case "Gotham":
    print("You're Batman!")
case "Mega-City One":
    print("You're Judge Dredd!")
case "Wakanda":
    print("You're Black Panther!")
default:
    print("Who are you?")
}

/*
 Remember: Swift checks its cases in order and runs the first one that matches. 
 If you place default before any other case, that case is useless
 because it will never be matched and Swift will refuse to build your code.

 Second, if you explicitly want Swift to carry on executing subsequent cases, 
 use `fallthrough`. This is not commonly used.
 */

let day = 5
print("My true love gave to me…")

switch day {
case 5:
    print("5 golden rings")
    fallthrough
case 4:
    print("4 calling birds")
    fallthrough
case 3:
    print("3 French hens")
    fallthrough
case 2:
    print("2 turtle doves")
    fallthrough
default:
    print("A partridge in a pear tree")
}

// ## Ternary
let age = 18
let canVote = age >= 18 ? "Yes" : "No"
print(canVote)
```
REST FUL API
Tags: node, mongodb, javascript
Published: 2024-04-30 21:16:26

(Client to (Server to Database))(req) ----> (Server to Client (res))


A RESTful API allows clients to utilize HTTP methods (GET, POST, PUT, PATCH, DELETE) to interact with the server, fetching data from databases such as MongoDB or SQL. 

Once the server retrieves data from the database, it delivers responses to clients, including browsers and mobile applications, in either HTML or JSON format upon receiving their requests. 

while doing this server must connected to the database .
Learn SwiftUI (Day 4/100)
Tags: swift
Published: 2024-04-30 21:02:05

## Swift

* Type annotations

```swift
import Cocoa

// ## Type annotations

let surname: String = "Lasso"
var score: Int = 0
var isAuthenticated: Bool = true
var albums: [String] = ["Red", "Fearless"]
var user: [String: String] = ["id": "@twostraws"]
var books: Set<String> = Set(["Dune 1", "Dune 2"])
// empty string array
var cities: [String] = []
// or
var clues = [String]()

// it is legit that declare the type to a constant and assign its value later
let username: String
// lots of complex logic
username = "@twostraws"
// lots more complex logic
print(username)

// ## Checkpoint 2
/*
 Create an array of strings,
 then write some code that prints the number of items
 in the array and also the number of unique items in the array.
 */

var names = ["John", "Doe", "John", "Mike"]
print(names.count)
print(Set(names).count)
```