RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-216412

Dima Kuzmin's questions

Martin Hope
Dima
Asked: 2025-03-24 20:11:46 +0000 UTC

Rust - u64 中的新变量值没有改变,错误是什么?

  • 5

这可能是一个愚蠢的错误,但我不明白这意味着什么。我请求帮助。为什么不应用条件运算符内部获得的新值(let oldfiles:u64 = 6666;),而是使用旧值(let oldfiles:u64 = 5555;)?条件if true已满足。

   let oldfiles:u64 = 5555;  
          
   if true {
       let oldfiles:u64 = 6666;
       dbg!(oldfiles); // oldfiles = 6666
   }

   //почему здесь значение oldfiles не изменилось и равно 5555 ?
   dbg!(oldfiles); // oldfiles = 5555
rust
  • 1 个回答
  • 23 Views
Martin Hope
Dima
Asked: 2025-02-26 17:52:38 +0000 UTC

PostgreSQL - 如何根据数组元素的条件从 json 数组中执行选择?

  • 6

有一个表,其列类型为 jsonb。

    {
        "key1": 
     [
   {"file": "U2323.DAT", "tt_date": "2023-12-03 22:22:12"}, 
   {"file": "V000.DAT", "tt_date": "2025-12-03 22:22:12"}
    ]
    }

有一个获取某些元素的所有数据的请求。

select
jsonb_array_elements(status->'key1')->>'file' as file,
jsonb_array_elements(status->'key1')->>'tt_date' as tt_date
from  status;

如何添加条件来获取file值以“U2”开头的元素?不清楚如何访问条件中的特定数组元素并设置条件。

sql
  • 1 个回答
  • 24 Views
Martin Hope
Dima
Asked: 2025-02-25 16:27:14 +0000 UTC

Rust - Postgresql 客户端的匹配错误是什么?

  • 5

告诉我错误是什么或者从哪里寻找原因?为什么在这种情况下我们会得到不同的类型?

   let client = Client::connect("postgresql://user:pass@localhost:5432/base", NoTls).unwrap(); 

    match client {
        Ok(mut client) => {
            let stmt = client.prepare("INSERT INTO status (status) VALUES ($1)").unwrap();
      
            client
                .execute(&stmt, &[&json_data])
                .expect("Failed to execute statement");
      
            println!("JSON data inserted successfully");
        }
        Err(err) => println!("Error: {}", err),
    }

给出消息:

error[E0308]: mismatched types
   --> src/main.rs:252:9
    |
251 |     match client {
    |           ------ this expression has type `postgres::Client`
252 |         Ok(mut client) => {
    |         ^^^^^^^^^^^^^^ expected `Client`, found `Result<_, _>`
    |
    = note: expected struct `postgres::Client`
                 found enum `Result<_, _>`
rust
  • 2 个回答
  • 40 Views
Martin Hope
Dima
Asked: 2024-12-05 02:21:11 +0000 UTC

Rust - 如何在 http 请求中指定自定义 LIST 方法?

  • 6

我正在使用reqwest来执行请求。

这是curl 中的一个请求:

curl --request POST --data '{"role_id":"222","secret_id":"444"}' https://vault.main.ru/v1/auth/approle/login

它的外观和工作方式如下:

let url_login = "https://vault.main.ru/v1/auth/approle/login";
let client = reqwest::Client::new();
    
    let json_data = r#"{"role_id":"222","secret_id":"444"}"#;
    let response = client
        .post(url_login)
        .header("Content-Type", "application/json")
        .body(json_data.to_owned())
        .send()
        .await?;

如何使用reqwest执行这样的curl 请求?

curl --header "X-Vault-Token: sdf33422323" --request LIST https://vault.main.ru/v1/secretsstream/metadata

LIST - 据我了解,这是一种自定义方法。怎么传送呢?

rust
  • 1 个回答
  • 34 Views
Martin Hope
Dima
Asked: 2024-11-28 13:25:10 +0000 UTC

Linux - 为什么 visudo: /etc/sudoers: 不允许操作?

  • 5

我需要使 telegraf 用户能够在没有密码的情况下从 sudo 运行fail2ban 这是一个示例

我通过 visudo 执行此操作,直接看来他们不建议编辑 /etc/sudoers.d/ 中的用户文件,以免破坏 sudo。

sudo su -
[sudo] password for user1:
root@host1:~# whoami
root
root@host1:~# groups
root
root@host1:~# id
uid=0(root) gid=0(root) groups=0(root)
root@host1:~# visudo
visudo: /etc/sudoers: Operation not permitted

root@host1:~# ls -la /etc/sudoers.d/
drwxr-x---   2 root root  4096 Dec 20  2023 .
drwxr-xr-x 138 root root 12288 Nov 27 11:49 ..
-r--r-----   1 root root   106 Mar 10  2022 telegraf
linux
  • 1 个回答
  • 43 Views
Martin Hope
Dima
Asked: 2024-07-31 02:37:27 +0000 UTC

Rust - 如何获取本周的所有日期?

  • 6

通过本周的now开始日期 ( ) 和结束日期 ( )收到。如何获取本周从开始到结束的完整日期列表?beginning_of_week()end_of_week()

дата
  • 1 个回答
  • 52 Views
Martin Hope
Dima
Asked: 2024-03-04 02:27:57 +0000 UTC

Rust:如何在线程之间传递哈希图?

  • 5

刚刚开始使用 Rust 中的线程。我无法在两个线程之间传递哈希表。如何正确地做到这一点以及我的错误在哪里?任务是在一个线程中收集哈希表并在另一个线程中打印它。

use std::thread;
use std::time::Duration;
use std::fs;
use std::io::{stdin, Read};
use std::collections::HashMap;


fn main() {
    
    let mut hello = String::from("Hello, ");
    let mut influx_data:HashMap<String, i32> = HashMap::new();

//second thread
    thread::spawn(move || {
        let mut character = [0];
        hello = String::from("sasasas ");
        while let Ok(_) = stdin().read(&mut character) {
            
if character[0] == b'\n' {
        influx_data.entry(hello).and_modify(|count| *count += 1).or_insert(1);  
            println!("counter_bss cnt=7\n");
            }
        }

            thread::sleep(Duration::from_secs(1));
    });

//main thread    
    loop {
        let data = "Some data!";
        fs::write("/tmp/foo", data).expect("Unable to write file");

        for (key, value) in &influx_data {
        println!("{} {}", key, value);
        }

        thread::sleep(Duration::from_secs(10));
   }

}

错误

   |
23 |                 influx_data.entry(hello).and_modify(|count| *count += 1).or_insert(1);  
   |                                   ^^^^^ value moved here, in previous iteration of loop
rust
  • 1 个回答
  • 32 Views
Martin Hope
Dima
Asked: 2023-10-27 01:01:57 +0000 UTC

正则表达式:如何从字符串中选择真实路径?

  • 5

直到最后我都无法赢得常规赛。您需要从字符串中选择组:日期时间、方括号内的文本以及子字符串中的路径(不包括文件名)。

示例行:

2023-10-26 03:06:55,136 WARN  [TSSS_NSSS-SIB] done ip 10.33.22.22 f '/mnt/data/DD/DD/A/sds/tdf/DDdf-fdfd-dfdf_dfdf_3433343.txt' t '/DDdf-fdfd-dfdf_dfdf_3433343.txt' sz 3507

以下是常规时间表:(.*)(\sWARN\s{2}\[)(.*)(\]\s)(done[^\']+\')

不可能说我们需要进一步选择路径子字符串中从第一次出现的“/”到最后一次出现的“/”的所有内容。因此,您需要从这一行中分组选择:

2023-10-26 03:06:55
TSSS_NSSS-SIB
/mnt/data/DD/DD/A/sds/tdf/
регулярные-выражения
  • 2 个回答
  • 38 Views
Martin Hope
Dima
Asked: 2023-06-23 02:04:30 +0000 UTC

SQL:如何选择属于表中不同记录范围内的记录?

  • 5

PostgreSQL 14上有一个数据库。表中有字段numb(BIGINT)、id(Varchar)、date_from(TIMESTAMP),它包含以下形式的记录:

numb;id;date_from;
124455;5820;2022-07-20 08:01:29; 
124455;5820;2022-07-24 08:01:29;    
124455;5402;2022-07-27 00:01:31;
124455;1020;2022-07-28 00:06:01;

numb我们有一个日期(在条件中)'2022-07-26 21:03:23',我们需要构建一个查询,以便在一个查询中我们选择= 124455的上一条记录,并且date_from小于记录中的'2022-07-27 00:01:31'

因此,我们应该只选择条目: ' 124455;5820;2022-07-24 08:01:29; ',因为它的日期大于下一条记录的日期:'2022-07-27 00:01:31'并且大于日期为'2022-07-20 08:01:29'的记录。

因此,事实证明,我们应该始终仅选择一个且仅选择date_from小于“2022-07-26 21:03:23”的条目中的上一个条目,但不大于下一个条目date_from“2022-07-27 00” :01' :31'。

mysql
  • 1 个回答
  • 34 Views
Martin Hope
Dima Kuzmin
Asked: 2022-05-01 00:45:38 +0000 UTC

C - 如何计算出现的字符数?

  • 0

您需要计算一串字母的频率。最好没有宏。如果你在一个循环中读取一个字符数组,但是如何计算已经读取字符的频率。读取一个字符数组并在其中收集另一个数组,每次传递一个新字符并以某种方式增加时都通过该数组 - 还记得计数器吗?或者有其他方法可以解决吗?

我开始写作,但我不知道如何计算那些已经遇到的字符。

#include <stdio.h>
#include <string.h>
int main (void)
{
    char * s = "This is the test string.";
    int size = strlen(s), i;  
    for(i = 0; i < size; i++){
        
    if(s[i] != ' '){
        printf("%c", s[i]);
        }
    } 
    return 0;
}
c
  • 1 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2022-04-11 00:18:50 +0000 UTC

如何理解数字以相同的数字开头和结尾?

  • 0

请给我一个想法。我对这个任务有点困惑:给定一个自然数。它以相同的数字开头和结尾是真的吗?首先我尝试读入一个数组,然后计算数组中的元素以找到第一个和最后一个数字,然后进行比较。但是我无法用数组完成它,在我看来这是数组的复杂性。

决策中应该遵循什么逻辑?

c
  • 1 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2022-04-09 00:52:03 +0000 UTC

C中的rand如何在区间内取负值?

  • 0

如何理解设计的意义

rand() % 21 + (-10)

值(-10)不清楚,即 这里的间隔值最大为 21,但为什么括号中是 -10 并且 rand 是否适用于该范围内的负数?

c
  • 3 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2022-09-17 20:09:43 +0000 UTC

如何正确格式化C中的时间?

  • 0

有这段代码:

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

void listdir(const char *name, int indent)
{
    DIR *dir;
    struct dirent *entry;
    struct stat buff;


    if (!(dir = opendir(name))){
        return;
      }

    while ((entry = readdir(dir)) != NULL) {
        if (entry->d_type == DT_DIR) {
            //char path[1024];

            if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0){
                continue;
              }
              //
              stat(entry->d_name, &buff);

              time_t times = buff.st_ctim.tv_sec;

              printf("%s %s", entry->d_name, ctime(&times)); //

              listdir(entry->d_name, indent + 1);



        }
    }
    closedir(dir);
}

int main(void) {
    listdir(".", 0);
    return 0;
}

执行时,它给出的 ctime 时间不正确,自 1970 年以来一切都在进行。结果是这样的: Thu Jan 1 05:03:14 1970 时间格式问题?

c
  • 1 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2021-10-24 22:18:19 +0000 UTC

Bitrix - 如何使产品属性多样化?

  • 0

在产品属性中,我选中了多个复选框。结果,在显示此属性的产品卡本身中,写入 Array。1C-Bitrix:站点管理 20.0.0。他如何在页面上将此列表显示为产品的下拉列表?

битрикс
  • 1 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2020-05-13 18:35:57 +0000 UTC

PHP - 按数组中元素的值组合

  • 0

和数组一样

array(4) { 
[0]=> string(21) "itd-sd|100.99.22.12" 
[1]=> string(32) "itd-sd.site.ru|100.99.22.12" 
[2]=> string(21) "mt-sd|192.168.0.1" 
[3]=> string(32) "mt-sd|192.168.0.22"
}

按元素值组合得到以下结果:

array(2) { 
    [0]=> string(21) "itd-sd|100.99.22.12|itd-sd.site.ru"  
    [1]=> string(21) "mt-sd|192.168.0.1|192.168.0.22"
    }

即,如果元素的值具有共同的值,我需要 - 然后通过分隔符将这些元素“粘合”成一个。在第一种情况下,我们通过值“100.99.22.12”进行组合,在第二种情况下,我们使用“mt-sd”进行组合。单击解决方案。

php
  • 1 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2020-03-29 03:34:18 +0000 UTC

PHP - 如何通过键+值合并?

  • 2

大批:

    array(2) {
        [0]=> array(2) {
            ["2020-03-27"]=> int(8)
            ["tags"]=> string(17) "STS; сервис" } 
        [1]=> array(2) {
            ["2020-03-27"]=> int(3)
            ["tags"]=> string(17) "PTP; сервис; тест" }
    } 

收集新数组的最佳方法是什么,如果这样的键已经存在(例如['2020-03-27']),那么

  1. 将数组元素与 key 组合["tags"],但如果它的值相同,则执行它merge,如果不是,则添加新值。
  2. 带有键的元素的值["2020-03-27"]设置为 last。

我会这样做:检查是否有这样的键,如果有,我们更新值,但我["tags"]不明白如何做得更好。

也就是说,你应该得到这样一个数组:

    array(1) { 
        [0]=> array(2) {
            ["2020-03-27"]=> int(3)
            ["tags"]=> string(17) "STS; PTP; сервис; тест" }
    } 
php
  • 3 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2020-01-28 03:14:36 +0000 UTC

PHP - 如何正确使用类?

  • 0

类 class.send_mail_func.php

class phpmailer {

        public function sendMail($message, $subject){

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require_once  ('./PHPMailer/vendor/phpmailer/phpmailer/src/Exception.php');
require_once  ('./PHPMailer/vendor/phpmailer/phpmailer/src/PHPMailer.php');
require_once  ('./PHPMailer/vendor/phpmailer/phpmailer/src/SMTP.php');

  //отправляем почту
  $mail = new PHPMailer;
  //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  $mail->setLanguage('ru', './PHPMailer/language/');
  $mail->CharSet = 'utf-8';
  $mail->isSMTP();                                      // Set mailer to use SMTP
  $mail->Host = 'host';  // Specify main and backup SMTP servers
  $mail->SMTPAuth = true;                               // Enable SMTP authentication
  $mail->Username = 'mail@mailru';                 // SMTP username
  $mail->Password = '123';                           // SMTP password
  $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
  $mail->Port = 465;                                    // TCP port to connect to

  $mail->setFrom('m@m.ru', 'Text');
  $mail->addAddress('user@user.ru', 'User');     // Add a recipient
  $mail->isHTML(true);                                  // Set email format to HTML

  $mail->Subject = $subject;
  $mail->msgHTML($message);

  if(!$mail->send()) {
      echo 'Message could not be sent.';
      echo 'Mailer Error: ' . $mail->ErrorInfo;
  } else {
      echo 'Message has been sent';
  }

}
}

我这样用

  include './class.send_mail_func.php';
 $email_send = new phpmailer();
 $email_send->sendMail($message,$subject);

我收到以下错误:Parse error: syntax error, unexpected 'use' (T_USE) in /home/class.send_mail_func.php on line 7

如何在类中正确使用 use?

php
  • 1 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2020-01-04 02:21:39 +0000 UTC

PHP - 什么是 json 编码?

  • 0

我不知道如何转换为纯文本。我的结果是一个 json 字符串,这是一个片段。通过解码,我不能把它变成可读的形式。

string(8533) ""{\"text_unique\":\"0.00\",\"result_json\":\"{\\\"date_check\\\":\\\"03.01.2020 20:12:39\\\",\\\"unique\\\":0,\\\"clear_text\\\":\\\"\\\\u041a\\\\u0435\\\\u0440\\\\u0430\\\\u043c\\\\u0438\\\\u0447\\\\u0435\\\\u0441\\\\u043a\\\\u0438\\\\u0439 \\\\u043a\\\\u0438\\\\u0440\\\\u043f\\\\u0438\\\\u0447 \\\\u0438\\\\u0437\\\\u0433\\\\u043e\\\\u0442\\\\u043e\\\\u0432\\\\u043b\\\\u0435\\\\u043d \\\\u0438\\\\u0437 \\\\u044d\\\\u043a\\\\u043e\\\\u043b\\\\u043e\\\\u0433\\\\u0438\\\\u0447\\\\u0435\\\\u0441\\\\u043a\\\\u0438 \\\\u0447\\\\u0438\\\\u0441\\\\u0442\\\\u043e\\\\u0433\\\\u043e \\\\u043d\\\\u0430\\\\u0442\\\\u0443\\\\u0440\\\\u0430\\\\u043b\\\\u044c\\\\u043d\\\\u043e\\\\u0433\\\\u043e \\\\u0441\\\\u044b\\\\u0440\\\\u044c\\\\u044f \\\\u043e\\\
php
  • 1 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2020-12-03 02:42:20 +0000 UTC

RUST - 循环读取文件

  • 1

请戳你的鼻子。我开始使用 Rust。我不知道如何在循环中使用变量。

fn main() {
    for e in glob("./*.json").expect("Failed to read glob pattern") {

       let mut file = File::open(e).unwrap();

    }
}

我还不明白语法 let mut file = File::open(e).unwrap();

如果我这样做,我发誓:

让 mut 文件 = File::open(e).unwrap(); | ^ 该特征std::convert::AsRef<std::path::Path>未实现 std::result::Result<std::path::PathBuf, glob::GlobError>

rust
  • 2 个回答
  • 10 Views
Martin Hope
Dima Kuzmin
Asked: 2020-10-24 16:20:57 +0000 UTC

如何在 jquery 中为另一个文本字段设置 maxlength?

  • 1

您需要读取第一个输入类型="text" 中的长度,并在第二个输入类型="text" 中将其设置为最大长度。

到目前为止,我能够在第一个中实现,您可以计算并显示长度并通过单击显示长度值。但是,不点击就无法设置 maxlength,而是在填充(或通过计时器)第一个输入 type="text" 并将该值设置为第二个的 maxlength 长度值时。因此,它不是由事件完成,而是由计时器完成,例如,这样用户就不会点击或按下任何东西。

在这里,他们用笨拙的双手迄今取得的成就

function f1() {
  $('#cartag').on('click', function() {
    var input = $(this);
    var input_lenght = input.val().length;
    input.next("span").text(input_lenght + " chars");
    //console.log(input_lenght);
    return input_lenght;
  });
}

//f1();


$('#cartag222').on('click', function() {
  var limitvalue = f1();
  console.log(limitvalue);
  limitText(this, limitvalue);
});

function limitText(field, maxChar) {
  var ref = $(field),
    val = ref.val();
  if (val.length >= maxChar) {
    ref.val(function() {
      //console.log(val.substr(0, maxChar))
      return val.substr(0, maxChar);
    });
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="cartag" type="text" name="car"><span></span>

<input id="cartag222" type="text" name="car222">

javascript
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5