清音悠歌

文章 评论 浏览 28

清音悠歌 2025-02-21 01:06:14

将json解析到一个物体中,然后设置他的属性

const myJSON = '{}';
const myObj = JSON.parse(myJSON);
myObj['first'] = [{'1':'test'}];

console.log(myObj);
newdata = {
       'first': [ {'1': 'test'} ]
}

Parse the json into an object, then set his properties

const myJSON = '{}';
const myObj = JSON.parse(myJSON);
myObj['first'] = [{'1':'test'}];

console.log(myObj);
newdata = {
       'first': [ {'1': 'test'} ]
}

如何在JavaScript中创建和空的JSON并动态添加键和其他JSON对象?

清音悠歌 2025-02-20 10:08:29

我认为您需要做的就是添加一些设置,并在您的项目类中包含一个

字段

class ScrapyExercisesItem(scrapy.Item):
    images = scrapy.Field()
    results = scrapy.Field()

结果

IMAGES_URLS_FIELD = 'images'
IMAGES_RESULT_FIELD = 'results'

I think all you need to do is add a few settings and include a results field in your item class

In your items.py file add this:

class ScrapyExercisesItem(scrapy.Item):
    images = scrapy.Field()
    results = scrapy.Field()

then in your settings.py file add this:

IMAGES_URLS_FIELD = 'images'
IMAGES_RESULT_FIELD = 'results'

Then try it again.

有下载图像问题

清音悠歌 2025-02-20 09:29:54

对于所有Docker用户,只需从php容器内部运行 Docker-Php-ext-install Mysqli 即可。

更新:有关 https://hub.docker.com/_/php 的更多信息“如何安装更多PHP扩展”。

For all docker users, just run docker-php-ext-install mysqli from inside your php container.

Update: More information on https://hub.docker.com/_/php in the section "How to install more PHP extensions".

如何在PHP 7中启用MySQLI扩展名?

清音悠歌 2025-02-20 03:13:19

由于content_vector已经是TSSVECTOR,因此只需在其上构建索引即可。 to_tsvector不会将TSSVECTOR作为第二个论点,而不是有意义的。

As content_vector is already a tsvector, just build the index on it. to_tsvector doesnt take a tsvector as it's second argument, not would it make sense to.

创建杜松子酒索引抛出“函数不存在”错误

清音悠歌 2025-02-18 18:14:04

双重“排除”可以充当。

首先,如果您使用排除,则创建要排除的所有项目的列表。

type GreekAlphabet = Exclude<AlphabetLike, 'a' | 'b' | 'c'>

这将导致一组:
'Zeta'| 'beta'| '伽玛'| 'Mu'
我们可以将该集合不排除在内,以使我们还需要我们想要的值:

type Alphabet = Exclude<AlphabetLike, GreekAlphabet>

此结果在:
'a'| 'B'| 'C'
有效地包括&lt; alphabetlike,'a'|'b'|'c'&gt; ,如果从“ alphabetlike”中删除了使用的选项,将保护您。

A double "exclude" can act as an include.

First, create a list of all of the items you want to exclude if you were using exclude.

type GreekAlphabet = Exclude<AlphabetLike, 'a' | 'b' | 'c'>

This results in a set that is:
'zeta' | 'beta' | 'gamma' | 'mu'
We can use that set with Exclude to give us back the values we want:

type Alphabet = Exclude<AlphabetLike, GreekAlphabet>

This results in:
'a' | 'b' | 'c'
which is effectively Include<AlphabetLike, 'a'|'b'|'c'> and will protect you if an option in use is removed from "AlphabetLike".

打字稿中有没有办法说“ include” (排除)?

清音悠歌 2025-02-18 08:05:04

您可以做正确的事情,只需在字符串之前添加 f 。然后,它将接受 date 变量:

.csv(f"abfss://[email protected]/{date}.csv")

You do everything right, just add an f before the string. Then it will accept the date variable:

.csv(f"abfss://[email protected]/{date}.csv")

如何在Pyspark中使用当前日期和时间保存文件名?

清音悠歌 2025-02-18 05:45:23

您也可以在中使用

let data = {
  "groupA": [
    {data: 'foo'},
    {data: 'bar'}
  ],
  "groupB": [
    {data: 'hi'},
    {data: 'mom'}
  ]
}

for (const key in data) {
  data[key] = data[key].map(item => ({...item, set: key}))
}

console.log(data);

You can use for...in as well

let data = {
  "groupA": [
    {data: 'foo'},
    {data: 'bar'}
  ],
  "groupB": [
    {data: 'hi'},
    {data: 'mom'}
  ]
}

for (const key in data) {
  data[key] = data[key].map(item => ({...item, set: key}))
}

console.log(data);

将对象父键附加到孩子

清音悠歌 2025-02-17 23:41:43

创建一个用于替换HTML文件中标记的值类。

public class TemplateItem
{
    public string User { get; set; }
    public string AppCom { get; set; }
    public List<string> AppUser { get; set; }
    public DateTime ResignDate { get; set; }
}

创建一个用于执行标记/代币替换的类。

public class TemplateOperations
{
    public static string Populate(string fileName, TemplateItem templateItem)
    {
        string contents = File.ReadAllText(fileName);
        
        contents = contents.Replace("##User##", templateItem.User);
        contents = contents.Replace("##AppCom##", templateItem.AppCom);
        contents = contents.Replace("##AppUser##", string.Join(",", templateItem.AppUser));
        contents = contents.Replace("##ResignDate##", templateItem.ResignDate.ToString("d"));

        return contents;

    }
}

在主方法上以上运行

partial class Program
{
    static void Main(string[] args)
    {
        TemplateItem templateItem = new TemplateItem
        {
            AppCom = "ABC",
            AppUser = new List<string>() { "Mike", "Jane", "Fran" },
            ResignDate = DateTime.Now,
            User = "Adam"
        };

        string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, 
            "MailTemplate", "Resignnotify.html");

        var body = TemplateOperations.Populate(fileName, templateItem);

        Console.WriteLine(body);
        Console.ReadLine();
    }
}

“在此处输入图像描述”

Create a class for values for replacing markers in the HTML file.

public class TemplateItem
{
    public string User { get; set; }
    public string AppCom { get; set; }
    public List<string> AppUser { get; set; }
    public DateTime ResignDate { get; set; }
}

Create a class for performing marker/token replacements.

public class TemplateOperations
{
    public static string Populate(string fileName, TemplateItem templateItem)
    {
        string contents = File.ReadAllText(fileName);
        
        contents = contents.Replace("##User##", templateItem.User);
        contents = contents.Replace("##AppCom##", templateItem.AppCom);
        contents = contents.Replace("##AppUser##", string.Join(",", templateItem.AppUser));
        contents = contents.Replace("##ResignDate##", templateItem.ResignDate.ToString("d"));

        return contents;

    }
}

Run above in Main method

partial class Program
{
    static void Main(string[] args)
    {
        TemplateItem templateItem = new TemplateItem
        {
            AppCom = "ABC",
            AppUser = new List<string>() { "Mike", "Jane", "Fran" },
            ResignDate = DateTime.Now,
            User = "Adam"
        };

        string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, 
            "MailTemplate", "Resignnotify.html");

        var body = TemplateOperations.Populate(fileName, templateItem);

        Console.WriteLine(body);
        Console.ReadLine();
    }
}

enter image description here

如何使用C#在Windows控制台中使用邮件模板?

清音悠歌 2025-02-17 03:26:45

您可能需要考虑将要启动的功能放在ngoninit()函数中,因此

ngOnInit(): void {
 this.timerService.start_countdown();
}

请尝试使用startTimer()函数,

var timer = duration, minutes, seconds;
var x = setInterval(() => { 
    minutes = (timer / 60) | 0;
    seconds = (timer % 60) | 0;
    if(timer>=0){
        timer=timer-1
        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;
        var second_left = minutes + ":" + seconds;

        console.log(second_left);

        if(timer==0){
            console.log("cleared");
            clearInterval(x)
        }
    }
},1000)

因为构造函数仅调用一次,您只会有一个00:00秒秒钟的控制台log。

编辑

一种方法是在testomponent.ts本身中使用startTimer(),而不是timerutilservice,如果您想使用服务,则需要可观察的方式 ,但是这种方式可能会引起性能问题,而不是很大的想法持续的反馈。

You might want to consider putting the functions you want to init in to ngOnInit() function like so

ngOnInit(): void {
 this.timerService.start_countdown();
}

Try this in side your startTimer() function,

var timer = duration, minutes, seconds;
var x = setInterval(() => { 
    minutes = (timer / 60) | 0;
    seconds = (timer % 60) | 0;
    if(timer>=0){
        timer=timer-1
        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;
        var second_left = minutes + ":" + seconds;

        console.log(second_left);

        if(timer==0){
            console.log("cleared");
            clearInterval(x)
        }
    }
},1000)

As the constructor only call once , you will only have one 00:00 seconds console log.

Edited

One way is to use the startTimer() in the TestComponent.ts itself not the TimerUtilService , if u want to use a service you will need the observable way but this way may cause performance issues and not very idea for constant feedback.

计时器使用服务未被拨打的服务

清音悠歌 2025-02-16 18:46:21

很难没有详细的错误回溯。它很含糊,但提供的信息是,某个地方正在检测张量,并试图将其转换为numpy阵列不正确。我的直觉告诉我,它来自您的可视化步骤中的matplotlib代码。我相信它正在尝试转换您的损失条款。

您应该将它们转换为 list s返回传播...

y_loss[phase].append(epoch_loss.item())
y_acc[phase].append(epoch_acc.item())

It's hard to say without a detailed error backtrace. It is vague but the information it gives is that something somewhere is detecting a tensor and trying to convert it to numpy array not properly. My intuition tells me it comes from the matplotlib code in your visualization step. I believe it is trying to convert your loss terms.

You should convert them to lists after having performed back propagation...

y_loss[phase].append(epoch_loss.item())
y_acc[phase].append(epoch_acc.item())

如何求解TypeError:可以将CUDA张量转换为Numpy。使用Tensor.cpu()将张量复制到主机内存

清音悠歌 2025-02-16 16:37:17
---
title: "Personnel Reports"
output:
  pdf_document:
    keep_tex: true
header-includes:
  - \usepackage{pdfpages}
---

```{r global_options, include=FALSE}
test <- "example-image-duck.pdf"
```

\includepdf[pages=-,pagecommand={}]{`r test`}
---
title: "Personnel Reports"
output:
  pdf_document:
    keep_tex: true
header-includes:
  - \usepackage{pdfpages}
---

```{r global_options, include=FALSE}
test <- "example-image-duck.pdf"
```

\includepdf[pages=-,pagecommand={}]{`r test`}

如何使用动态路径在rmarkDown中包括一个乘法PDF?

清音悠歌 2025-02-16 16:28:55

问题的根源是NPM,它是该项目的包装管理器。

该项目本身是a lerna monorepo 带有两个套餐,两包都依赖于bn.js,一个依赖一个包裹在包裹中,从另一个包装中导入了一些类。但是,每个软件包都有自己的BN.JS版本,当不同版本的BN.JS开始在一个包装中混合时,怪异的事情开始发生。

该解决方案无需介绍许多细节,而是从两个软件包中删除了BN.JS,而是在项目根级别上安装特定版本。

The root of the issue turned out be NPM, which was the package manager for the project.

The project itself was a lerna monorepo with two packages, both of which relied on BN.js, and where one of the packages imported some classes from the other. However, each package had its own version of BN.js and when different versions of BN.js began to mingle in a single package, weird things began happening.

Without going into many details, the solution was removing BN.js from both packages and instead installing a specific version at the project root level.

TS2322:type&#x27; bn&#x27;不能分配到类型&#x27; String |数字| bn&#x27;在Docker Build中

清音悠歌 2025-02-16 15:59:26

另一种方法:

TOKEN = "..."
GITHUB_CLIENT_ID = "..."
GITHUB_CLIENT_SECRET = "..."
try {
        const credentials = `${GITHUB_CLIENT_ID}:${GITHUB_CLIENT_SECRET}`;
        const encodedCredentials = btoa(credentials);

        const response = await fetch(`https://api.github.com/applications/${GITHUB_CLIENT_ID}/token`, {
            method: 'DELETE',
            headers: {
                Authorization: `Basic ${encodedCredentials}`,
                Accept: 'application/vnd.github+json',
                'X-GitHub-Api-Version': '2022-11-28',
            },
            body: JSON.stringify({
                access_token: TOKEN
            })
        });

        if (response.ok) {
            console.log('Successfully revoked Github token');
            return "Successfully revoked Github token";
        } else {
            console.error('Failed to revoke Github token', response.statusText);
            return "ERROR";
        }
} catch (error) {
    console.error('Error revoking Github token:', error);
    return "ERROR";
}

Another Way:

TOKEN = "..."
GITHUB_CLIENT_ID = "..."
GITHUB_CLIENT_SECRET = "..."
try {
        const credentials = `${GITHUB_CLIENT_ID}:${GITHUB_CLIENT_SECRET}`;
        const encodedCredentials = btoa(credentials);

        const response = await fetch(`https://api.github.com/applications/${GITHUB_CLIENT_ID}/token`, {
            method: 'DELETE',
            headers: {
                Authorization: `Basic ${encodedCredentials}`,
                Accept: 'application/vnd.github+json',
                'X-GitHub-Api-Version': '2022-11-28',
            },
            body: JSON.stringify({
                access_token: TOKEN
            })
        });

        if (response.ok) {
            console.log('Successfully revoked Github token');
            return "Successfully revoked Github token";
        } else {
            console.error('Failed to revoke Github token', response.statusText);
            return "ERROR";
        }
} catch (error) {
    console.error('Error revoking Github token:', error);
    return "ERROR";
}

如何使用GitHub API撤销OAuth身份验证?

清音悠歌 2025-02-16 10:54:32

基于opensea文档 testnets.opensea.io 仅在Rinkeby区块链上工作。

来源: https://docs.opensea.io/reference/Rinkeby-api-Api-Overview < /a>

Based on the OpenSea documentation testnets.opensea.io works only on the Rinkeby Blockchain.

Source: https://docs.opensea.io/reference/rinkeby-api-overview

NFT在Goerli Testnet下没有在Opensea上显示

清音悠歌 2025-02-16 06:29:00

1。 在此处解决的所有文本都

在此处解决:
根据其他单元格的字体颜色更改单元格的值

2。查找带有红色的文本的单元格

您在此处找到的起点我如何在excel vba中的单元格中找到一个单词并为红色染色(只有整个单词不是整个单词使用VBA代码?
在此处完成了每个字符的检查:

3。创建用户定义的功能

如果您创建一个用户定义的函数以搜索所需的格式,则可以过滤这些特定行。 (请参阅上面的nr1。link)
例如,它看起来像 = ifcoloredCells(a2:e2,“”,“ no Change”)

4。将更改应用于过滤的数据

过滤后的更改数据后,您可以根据您的whishes修改格式或数据。

1. Find cells which have all the text colored in red

Similar question solved here:
Change the value of the cell according to the font colour of the other cell

2. Find cells which have text partially colored in red

A starting point you find here How can I find a word in a cell in Excel VBA and color it red (only the word not the entire cell) using VBA code?
A check for every single character was done here: https://answers.microsoft.com/en-us/msoffice/forum/all/need-help-to-find-text-with-partial-font-color/b8e58634-b114-42fa-8f5f-fb83d9d3746d

3. create a user defined function

If you create a user defined function to search for the desired formatting you can filter for these specific rows. (see link at nr 1. above)
e.g. it could look like =ifColoredCells(A2:E2," ","no changes")

4. apply changes to filtered data

After filtering for the changed data you can either modify the format or the data according to your whishes.

enter image description here

如果该行中的一个单元格有红色文本,则为单元格着色

更多

推荐作者

眼泪淡了忧伤

文章 0 评论 0

corot39

文章 0 评论 0

守护在此方

文章 0 评论 0

github_3h15MP3i7

文章 0 评论 0

相思故

文章 0 评论 0

滥情空心

文章 0 评论 0

更多

友情链接

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