懵少女

文章 评论 浏览 31

懵少女 2025-02-11 17:51:51

据我所知,没有开箱即用的解决方案,您应该在运行 docker exec的容器上执行自己的API执行命令。 <命令> 并返回输出,Mind逃脱命令。

但是,您应该知道,让用户在Docker内运行命令很危险,因为它可能会影响您的主机。

From what I know there is no out of the box solution, you should make your own api executing command on your container running docker exec <id> <command> and returning the output, mind escape the command.

However you should know that letting a user run commands inside a docker is dangerous as it could impact your host.

如何从Web连接到Docker容器?

懵少女 2025-02-11 09:02:14

我不是打字稿的专家,但是当我尝试使用纯JS时,它也可以使用。

const fs = require("fs");

const readMD = (filePath) => {
    return new Promise((resolve, reject) => {
        fs.readFile(filePath, "utf8", (error, content) => {
            if (error) reject(error);
            resolve(content);
        });
    });
}

readMD("./changelog.md").then(changelog => {
    const result = changelog.match(/^##.*\n([^#]*)/m);
    console.log(result[1]);
});

I am not an expert on TypeScript but when I tried the same with pure JS it worked.

const fs = require("fs");

const readMD = (filePath) => {
    return new Promise((resolve, reject) => {
        fs.readFile(filePath, "utf8", (error, content) => {
            if (error) reject(error);
            resolve(content);
        });
    });
}

readMD("./changelog.md").then(changelog => {
    const result = changelog.match(/^##.*\n([^#]*)/m);
    console.log(result[1]);
});

读取一个.md文件,应用了一些正则是javascript/ts中的null

懵少女 2025-02-11 03:33:07

使用传输状态将数据保存到服务器端。一旦加载浏览器,您就可以从传输状态获取数据。

服务器端接收数据并打印数据,但要将数据放在客户端上,您必须存储它的传输状态。代码应像

constructor(
    @Optional() @Inject('MODEL') private model: string,
    @Inject(PLATFORM_ID) private _platformId: Object,) {
}  

ngOnInit(): void {
    if (isPlatformServer(this._platformId)) {
          this.transferState.set(makeStateKey('model'), this.model);
    } else if (isPlatformBrowser(this._platformId)) {
          this.model= this.transferState.get(makeStateKey('model'), null)
    }
  } 

Save The data to the server end using transfer state. And once you load on the browser you can fetch the data from transfer state.

The server side receives the data and prints it but in order to have that data on the client you must store it transfer state. The code shall be like

constructor(
    @Optional() @Inject('MODEL') private model: string,
    @Inject(PLATFORM_ID) private _platformId: Object,) {
}  

ngOnInit(): void {
    if (isPlatformServer(this._platformId)) {
          this.transferState.set(makeStateKey('model'), this.model);
    } else if (isPlatformBrowser(this._platformId)) {
          this.model= this.transferState.get(makeStateKey('model'), null)
    }
  } 

如何使组件可访问字符串依赖令牌?

懵少女 2025-02-10 22:23:47

简单的解决方案可以将JSON转换为C#对象,然后在操作上迭代并读取其描述属性,如下所示:

Root myDeserializedObject = JsonConvert.DeserializeObject<Root>(myJsonResponse);
foreach(var item in myDeserializedObject.operations)
{
   Console.WriteLine(item.description);
}

从JSON String中生成这些C#对象,来自: https://json2csharp.com/

public class ComCumulocityModel
{
    public string op { get; set; }
    public string param { get; set; }
    public string value { get; set; }
    public int? Mode { get; set; }
    public string StopStationPayload { get; set; }
}

public class Operation
{
    public DateTime creationTime { get; set; }
    public string deviceId { get; set; }
    public string deviceName { get; set; }
    public string status { get; set; }
    public ComCumulocityModel com_cumulocity_model { get; set; }
    public string description { get; set; }
}

public class Root
{
    public List<Operation> operations { get; set; }
    public Statistics statistics { get; set; }
}

public class Statistics
{
    public int currentPage { get; set; }
    public int pageSize { get; set; }
}

Simple solution to do it convert JSON to C# objects and then iterate over Operation and read its Description property, as given below:

Root myDeserializedObject = JsonConvert.DeserializeObject<Root>(myJsonResponse);
foreach(var item in myDeserializedObject.operations)
{
   Console.WriteLine(item.description);
}

Generate these C# object from JSON string from: https://json2csharp.com/

public class ComCumulocityModel
{
    public string op { get; set; }
    public string param { get; set; }
    public string value { get; set; }
    public int? Mode { get; set; }
    public string StopStationPayload { get; set; }
}

public class Operation
{
    public DateTime creationTime { get; set; }
    public string deviceId { get; set; }
    public string deviceName { get; set; }
    public string status { get; set; }
    public ComCumulocityModel com_cumulocity_model { get; set; }
    public string description { get; set; }
}

public class Root
{
    public List<Operation> operations { get; set; }
    public Statistics statistics { get; set; }
}

public class Statistics
{
    public int currentPage { get; set; }
    public int pageSize { get; set; }
}

如何从JSON响应的嵌套对象内的特定键创建列表?

懵少女 2025-02-10 20:09:47

我认为您提到太多文章或视频。当我检查您的存储库时,您编写了2-3种执行相同任务的代码类型。我建议您一次只能提供一个资源。可能这会帮助您。

I think you refer too many articles or videos . When I check your repo there you written 2-3 types of code which does the same task. I suggest you to follwo only one resource at a time. May be this will help you. https://www.thapatechnical.com/2021/04/how-to-deploy-mern-projects-on-heroku.html

我在Heroku上部署了一个快递应用程序,但我有404(找不到)错误

懵少女 2025-02-10 16:15:10

GO不是SQL命令。
只有SQL命令可以需要一个“”;

GO是由SSM而不是SQL Server执行的命令。

Go是批处理命令的分离器。

Go Say to to ssms将命令扔到SQL Server,然后将其返回时,继续抛出命令,直到找到新的GO语句为止。

GO is not a SQL command.
Only SQL command can require a ";"

GO is a command destinate to be executed by SSMS and not by SQL Server.

GO is a separator of batch commands.

Go says to SSMS throw the command to the SQL Server and when it returns, continue to throw the commands until a new GO statement is find.

如何摆脱SQL中的错误语法错误

懵少女 2025-02-10 06:49:09

在Intellij中,当您创建一个类时,它的软件包将自动创建。

只需右键单击 src/java 目录,然后进行“新 - &gt; java类”。输入新类的包装合格名称,并将创建所有缺失的软件包:

“在此处输入图像说明”

例如,假设我没有文件夹a,b,c,c,d,e,除了文件foo.java之外,还将创建所有这些。

In IntellIJ, when you create a class, its packages will automatically be created.

Just right click the src/java directory, and go "New -> Java Class". Enter the package-qualified name of the new class, and all the missing packages will be created:

enter image description here

For example, assuming I don't have the folders a, b, c, d, e, this will create all of them, in addition to the file Foo.java.

在Intellij中创建完整的软件包路径而不是一对一的路径

懵少女 2025-02-07 21:24:29

以下方法有点冗长,但是您可以使用bash Regex提取日期零件,而 case 转换月的开关:

#!/bin/bash

filename='SomeFilename 05 May 2022.zip'

if [[ $filename =~ ([0-9]{2})\ ([A-Z][a-z]{2})\ ([0-9]{4})\.[^.]+$ ]]
then
    d=${BASH_REMATCH[1]}

    case ${BASH_REMATCH[2]} in
    Jan) m=01;; Feb) m=02;; Mar) m=03;;
    Apr) m=04;; May) m=05;; Jun) m=06;;
    Jul) m=07;; Aug) m=08;; Sep) m=09;;
    Oct) m=10;; Nov) m=11;; Dec) m=12;;
    esac

    y=${BASH_REMATCH[3]}

    date=$d$m$y
fi

The following method is a little lengthy but you can use a bash regex for extracting the date parts and a case switch for converting the month:

#!/bin/bash

filename='SomeFilename 05 May 2022.zip'

if [[ $filename =~ ([0-9]{2})\ ([A-Z][a-z]{2})\ ([0-9]{4})\.[^.]+$ ]]
then
    d=${BASH_REMATCH[1]}

    case ${BASH_REMATCH[2]} in
    Jan) m=01;; Feb) m=02;; Mar) m=03;;
    Apr) m=04;; May) m=05;; Jun) m=06;;
    Jul) m=07;; Aug) m=08;; Sep) m=09;;
    Oct) m=10;; Nov) m=11;; Dec) m=12;;
    esac

    y=${BASH_REMATCH[3]}

    date=$d$m$y
fi

从文件名中提取日期并在bash中转换

懵少女 2025-02-07 13:50:37

谢谢大家,

问题是最新版本的microsoft.data.sqlclient。根据下面的文章,我们降低了包裹,我们的问题已解决。

Thanks Everyone,

The issue was with the latest version of Microsoft.Data.SqlClient. As per the article below we downgraded the package and our issue was fixed.

https://weblog.west-wind.com/posts/2021/Dec/07/Connection-Failures-with-MicrosoftDataSqlClient-4-and-later

Azure-应用程序由于堆栈缓冲区Overrun异常而崩溃了&#x2B; HTTP 502错误

懵少女 2025-02-07 09:38:20

如果我正确理解您,您想要的是一个列表,其中包含CSV文件中所有pandas数据范围的列表。因此,是一个列表,逐步将所有dataframes df 附加到。它们可以通过框架[index] 访问它们

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

number_of_files = 10
frames = []
filename = "your_file{number}.csv" # In your case: "Cuerpo Negro {number} Volt.txt"

for i in range(1, number_of_files+1):
    df = pd.read_csv(filename.format(number=i), skiprows=1)
    frames.append(df)

If I understood you correctly what you want is a list with all your pandas DataFrames from your csv file. So frames is a list in which step by step all the DataFrames df are appended to. They are accessible by frames[index]

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

number_of_files = 10
frames = []
filename = "your_file{number}.csv" # In your case: "Cuerpo Negro {number} Volt.txt"

for i in range(1, number_of_files+1):
    df = pd.read_csv(filename.format(number=i), skiprows=1)
    frames.append(df)

有没有办法在jupyter Lab/python中的文件中,我可以在cicle中通过档案操作?

懵少女 2025-02-07 05:39:24

您可以包装另一个查询吗?

喜欢:

select *
from(
    SELECT thedate, thedata FROM table
    GROUP BY strftime("%%Y-%%m", date) 
    ORDER BY max(strftime("%%Y-%%m", date)) DESC 
    LIMIT 3
) details

order by details.thedate

Can you wrap in another query?

like:

select *
from(
    SELECT thedate, thedata FROM table
    GROUP BY strftime("%%Y-%%m", date) 
    ORDER BY max(strftime("%%Y-%%m", date)) DESC 
    LIMIT 3
) details

order by details.thedate

如何更改sqlite结果的顺序?

懵少女 2025-02-07 04:34:25

useaxios 正如您所设计的,是一个钩子。钩子应遵循一些规则,称为挂钩规则,这里是概述:

它应该只能被称为a反应组件的级别或钩子的顶层,而不是像您一样在钩子或组件内的功能中,而不是在任何其他块中,例如if-else。 ..

它 为您的情况征收可能是这样的:

import { useContext, useState, useEffect } from 'react';
import './login.scss';
import { useNavigate } from 'react-router-dom';
import { useAxios } from '../../api/use-axios';
import ApiConfig from '../../api/api-config';
import { AuthContext } from '../../context/AuthContext';

const LOGIN_AXIOS_CONFIG = ApiConfig.AUTH.LOGIN;

const Login = () => {
  const [loginAxioConfig, setLogicAxiosConfig]=useState(null);
  const [loginError, setLoginError] = useState('');
  const [phone, setPhone] = useState('');
  const [password, setPassword] = useState('');
  const { response: loginData, error } = useAxios(loginAxioConfig);
  
  const navigate = useNavigate();
  const { dispatch } = useContext(AuthContext);

  const handleLogin = (e) => {
    e.preventDefault();
    setLogicAxiosConfig({...LOGIN_AXIOS_CONFIG, data = {
      phone,
      password,
    } });
    
  };
  
  useEffect(()=>{
   if (error) {
      setLoginError(error);
   } 
  },[error]);

   useEffect(()=>{
     if (loginData) {
      dispatch({ type: 'LOGIN', payload: loginData });
      navigate('/');
     }
  },[loginData])
  return (
    <div className="login">
      <div className="logo">
        <h1>LOGO</h1>
        <h3>LOGO DESCRIPTION</h3>
      </div>
      <form onSubmit={handleLogin}>
        <input type="number" placeholder="phone" onChange={(e) => setPhone(e.target.value)} />
        <input type="password" placeholder="password" onChange={(e) => setPassword(e.target.value)} />
        <button type="submit">Submit</button>
        {loginError && <span>{loginError}</span>}
      </form>
    </div>
  );
};

export default Login;
import { useState, useEffect } from 'react';
import axios from 'axios';

export const useAxios = (axiosParams) => {
  const [response, setResponse] = useState(undefined);
  const [error, setError] = useState('');
  const [loading, setLoading] = useState(true);

  const fetchData = async (params) => {
    try {
      const result = await axios.request({
        ...params,
        method: params.method || 'GET',
        headers: {
          accept: 'application/json',
          authorization:
            'Bearer my-token',
        },
      });
      console.log(result.data);
      setResponse(result.data);
    } catch (error) {
      setError(error);
    } finally {
      setLoading(false);
    }
  };

  useEffect(() => {
    if(!axiosParams) return;
    fetchData(axiosParams);
  }, [axiosParams]);

  return { response, error, loading };
};

useAxios, as you designed it, is a hook. And a hook, should follow some rules, known as Rules of Hooks, and here is an overview:

It should only get called a the to level of a React component or at the top level of a hook, not in a function inside a hook or a component like you did, not inside any other block, like if-else...

An approche for your case may be something like this:

import { useContext, useState, useEffect } from 'react';
import './login.scss';
import { useNavigate } from 'react-router-dom';
import { useAxios } from '../../api/use-axios';
import ApiConfig from '../../api/api-config';
import { AuthContext } from '../../context/AuthContext';

const LOGIN_AXIOS_CONFIG = ApiConfig.AUTH.LOGIN;

const Login = () => {
  const [loginAxioConfig, setLogicAxiosConfig]=useState(null);
  const [loginError, setLoginError] = useState('');
  const [phone, setPhone] = useState('');
  const [password, setPassword] = useState('');
  const { response: loginData, error } = useAxios(loginAxioConfig);
  
  const navigate = useNavigate();
  const { dispatch } = useContext(AuthContext);

  const handleLogin = (e) => {
    e.preventDefault();
    setLogicAxiosConfig({...LOGIN_AXIOS_CONFIG, data = {
      phone,
      password,
    } });
    
  };
  
  useEffect(()=>{
   if (error) {
      setLoginError(error);
   } 
  },[error]);

   useEffect(()=>{
     if (loginData) {
      dispatch({ type: 'LOGIN', payload: loginData });
      navigate('/');
     }
  },[loginData])
  return (
    <div className="login">
      <div className="logo">
        <h1>LOGO</h1>
        <h3>LOGO DESCRIPTION</h3>
      </div>
      <form onSubmit={handleLogin}>
        <input type="number" placeholder="phone" onChange={(e) => setPhone(e.target.value)} />
        <input type="password" placeholder="password" onChange={(e) => setPassword(e.target.value)} />
        <button type="submit">Submit</button>
        {loginError && <span>{loginError}</span>}
      </form>
    </div>
  );
};

export default Login;
import { useState, useEffect } from 'react';
import axios from 'axios';

export const useAxios = (axiosParams) => {
  const [response, setResponse] = useState(undefined);
  const [error, setError] = useState('');
  const [loading, setLoading] = useState(true);

  const fetchData = async (params) => {
    try {
      const result = await axios.request({
        ...params,
        method: params.method || 'GET',
        headers: {
          accept: 'application/json',
          authorization:
            'Bearer my-token',
        },
      });
      console.log(result.data);
      setResponse(result.data);
    } catch (error) {
      setError(error);
    } finally {
      setLoading(false);
    }
  };

  useEffect(() => {
    if(!axiosParams) return;
    fetchData(axiosParams);
  }, [axiosParams]);

  return { response, error, loading };
};

React Hook'useAxios'被称为既不是React函数组件也不是自定义React Hook函数的函数

懵少女 2025-02-06 07:48:55

我们可以尝试使用子查询来计算 sum 窗口功能之前的每个月销售。

SELECT t1.*,sum(total_sales) over(order by month) as cum_sum
FROM (
  select month, sum(sales) total_sales
  from sales
  group by month
) t1

We can try to use a subquery to calculate total sales each month before sum window function.

SELECT t1.*,sum(total_sales) over(order by month) as cum_sum
FROM (
  select month, sum(sales) total_sales
  from sales
  group by month
) t1

SQL中的一组累积总和

懵少女 2025-02-06 06:04:23

lowestPrice = min(allproducts.items(),key = lambda x:x [1])正在返回元组(product_name,product_price) lowestPrice = min(allproducts.items(),key = lambda x:x [1])[1] 将仅返回价格,然后一切正常。

lowestprice = min(allproducts.items(), key=lambda x: x[1]) is returning a tuple (product_name, product_price). lowestprice = min(allproducts.items(), key=lambda x: x[1])[1] will return just the price and then everything works.

将字符串转换为int,从另一个数字中减去。 Python

懵少女 2025-02-06 04:26:18

基本上总是以8

的长度返回

这是格式字符串所做的:

>>> print(f"{'C30':>08s}")
00000C30

作为旁注,以将任何数字输出为8位十六进制:

>>> print(f"{100:>08X}")
00000064
>>> print(f"{1024:>08X}")
00000400

请参阅文档:

Basically always returning it with a length of 8

That's what format strings do:

>>> print(f"{'C30':>08s}")
00000C30

As a sidenote, to output any number as 8-digit hex:

>>> print(f"{100:>08X}")
00000064
>>> print(f"{1024:>08X}")
00000400

See the documentation:

如何格式化Python代码始终返回此特定长度

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文