所有问题

0 投票
4 回答
142 浏览

c++ - A const & refers to a nonvolatile variable. The variable changes. Does the change invalidate the const &?

In C++, can the value of a const & change?

Well, of course it cannot change, can it? That's what const means. Moreover, listen to Stroustrup:

A const lvalue reference refers to a constant, which is immutable from the point of view of the user of the reference.

But what about this?

On my machine, this outputs, old_r == 0 but new_r == 1.

That gets to my real question. In the above code, look at the line

Insofar as

  • the address &new_r is extracted neither on this line nor elsewhere in the code and
  • the code has nothing volatile,

does anything prevent an optimizing compiler from merging old_r and new_r into a single constant object, treating the line as though it read as follows?

I ask because, as far as I know, if the compiler did so optimize, that might alter the behavior. The program might output, old_r == 0 but new_r == 0.

RELATED QUESTIONS

The most nearly related existing question I find is this one:

The following are also related but, unlike the present question, involve casts:

See also N4659 (draft C++17 standard), sect. 10.1.7.1, "The cv-qualifiers."

The quote of Stroustrup at the top of the question comes from sect. 7.7.2 of The C++ Programming Language, 4th ed. Of course, no author can write every sentence perfectly in a thousand-page book; yet perhaps Stroustrup is clear and I have merely read him wrong. Nevertheless, you might see why the sentence has confused me. This is why I have asked.

0 投票
1 回答
454 浏览

ruby-on-rails - 仅在合适的条件下执行工作

我正在使用带有 sidekiq 适配器的活动作业,并且我只想在满足某些条件时才执行作业,例如。我追加到队列,但我不想执行队列中的任何项目,除非设置了特定的 redis 标志。我怎样才能做到这一点?如果在触发器之前,我会检查是否设置了标志并抛出异常,我想它会起作用,但它看起来并不优雅。

0 投票
3 回答
2780 浏览

apache-spark - 将 RDD 转换为 Dataframe 后的错误:“java.lang.String 不是 int 架构的有效外部类型”

我正在尝试在不使用案例类的情况下将 RDD 转换为 Dataframe。csv 文件如下所示:

一切都很顺利,直到我尝试做一个 playerDF.show

我能做些什么?

0 投票
1 回答
112 浏览

node.js - Negating a backreference in regex

I have written such regular expression:

but it doesn't work because of backreferencing inside [^]. I looked for solution on this thread and wrote this:

however it still doesn't work.

What am I doing wrong?

I want to extract all keys with values from strings like:

regex101 - online preview

0 投票
1 回答
66 浏览

git - Bare and non-bare repo at the server

I want to track directories and files stored at the server. The initial idea was to set up a bare repository at the server and then push/pull from local machines (where non-bare repos are stored). The problem is that updated files must be present at the server.

Initially I focused on setting up a non-bare repo on the server and pulling from the bare repo but it would require someone to git pull every time a push is made from a local machine. My question is: is it possible to set up bare and non-bare repos in a way that allows me to make changes to the code on a local machine, push those changes and have them at the server automatically. If a non-bare repo at the server side is needed, is it possible to block pushing from it?

0 投票
2 回答
165 浏览

c# - 在 C# 中将 3 个混洗字节转换为两个 12 位整数

我正在尝试使用 C# 从串行端口读取数据。

整数或浮点数和布尔值的普通字节不是问题。但是,有一个 3 个字节的序列被打乱了,我无法正确解析它。

这 3 个字节代表 2 个无符号 12 位整数,一个用于 MainSupplyDC,一个用于 Motor Power。它们以需要在解析之前重新排序的方式进行混洗。

我的最后一次尝试以这样的方式结束,但现在我再次意识到这不可能是正确的。

我不知道如何以正确的方式转移它。

这是字节序列布局:

在此处输入图像描述

在文本中相同:

字节序列示例:

从现在开始 2 天以来一直在敲我的头,只是无法让它工作......

编辑

似乎有两种方法可以解释给定的表格。在我的情况下@canton7 有正确的答案,但我认为如果供应商/制造商以另一种方式编码,@dumetrulo 将有正确的答案。

0 投票
0 回答
77 浏览

json - 如何在数据服务中保存来自 httpclient 的数据以及如何循环通过我的 json 对象

我有一个生成的 json 对象槽

看起来像:

我正在使用 Angular App Http Service 导入数据

效果很好。

如何将上述 json 对象存储在我的 http 服务或数据服务中?

有没有类似的东西

保存数据和

取回数据?或者如何将 json 对象保存在 http 服务或数据服务中?我需要额外的数据服务还是 http 服务适合保存这个 json 对象?

以及如何循环通过 json 对象?

有没有类似的东西

? 但是我怎样才能访问键值以循环遍历每一行呢?

0 投票
0 回答
358 浏览

c# - 无需本地管理员即可运行 WCF 服务 TCP

我正在尝试启动 WCF 服务,在没有管理员权限的情况下侦听 net.tcp(出于客户端安全原因)。

我尝试了不同的端口,808、5000,但没有任何效果。

.NET 错误是:

内部异常:

我试图编辑我的 SMSvcHost.exe.config。我在 Windows 10 服务中使用了 net“tcp 端口共享”使用的那个,我使用了正确的 SID 并重新启动了服务。

现在我的配置文件是这样的:

谢谢

0 投票
7 回答
88 浏览

php - Create new array from two separate arrays by counting duplicates php

I have an array called Array1. This contains names such as Array1 = "John, Ali, Ali, Mark, Susan, Susan, Susan, Ali, Julie, John" etc.

I would like to: 1st - count how many times each name appears in Array1 2nd - create a separate array removing duplicates from Array1 3rd - add to second array the count of duplicates.

Thus my final array would look like as such:

How would i go about this? Any pointers in the right direction will be appreciated. Thanks

0 投票
1 回答
895 浏览

javascript - Vue FilePond中的文件大小调整不起作用

我使用 Vue FilePond 来管理我的图像。我想在上传后调整/裁剪我的图像。遵循此处的文档:FilePond

这是我的代码:

在方法中,我在 FilePond 中捕获文件以将其传输到对象。在 FilePond 中,图像被正确裁剪,但传输的文件不是。似乎我正在捕获源文件。

在方法中:

这是 Filepond Preview 中的裁剪图像 在此处输入图像描述

我的问题:结果我得到了原始文件,而不是预览中的裁剪/调整大小的图像。

0 投票
2 回答
48 浏览

laravel - Ordering by foreign key field count

I have three tables a product, user and purchases table. I am trying to return a list of the category of products that the user has most frequently purchased. So the list should look like : Garden 4, Food 3, Sport 2 etc.

Here are my tables:

products: id, name, categories_id, price categories: id, category users: id, name
purchases: id, users_id, products_id

I am struggling to work out how to do this, this is what i have so far

0 投票
1 回答
106 浏览

machine-learning - 如果我的分类变量数量不固定,则无法为我的模型准备训练数据

我正在尝试解决工厂合并订单中包含的产品的回归问题。

我有合并工厂合并一个订单所花费的总时间。现在问题来了。

当两个不同数量的产品合并在一起时,它们需要一定的时间才能合并。但有时两个不同数量的产品会在一个订单中出现,并且合并工厂正在合并它。

我有工厂为它合并的每个订单所花费的总时间。在合并中心要合并的产品数量可以是 1 到 n 之间的任意值。

如何为我的模型准备训练数据以理解这一点?

上面的例子用了 143 小时

上面的例子现在花了 200 个小时。

现在在第一个示例中,合并中心需要 143 个小时,其中有两个不同数量的产品,在第二个示例中,三个产品参与,需要 200 个小时。

我如何准备训练数据,以便我的模型能够理解它并且我可以预测工厂需要多长时间?

我还有很多其他功能,但这是特定于订单的,但我知道如何处理。

0 投票
2 回答
24 浏览

sql - T-SQL - Update list of customers CustomerID (Alphanumeric) with next in sequence

I have a table of new customers in an old legacy system which I need to calculate and update the CustomerID of which is Alphanumeric (5 letters 3 numbers). The legacy system already has a list of customerIDs. I want to update the new customersIDs in line with the existing sequence.

There may also be a 5 letter id which doesn't already exist in the list and would therefore start at 001.

I have the 5 letters for each new customer within a field. I just need to update with the next in sequence.

For example:

ExistingCustomerIDs

New Customers Table only contains the beginning 5 letters.

0 投票
2 回答
162 浏览

python - 如何从停止的地方恢复 Scrapy spider?

我有一个非常大的网站,其中包含很多我想抓取的 URL。有没有办法告诉 Scrapy 忽略 URL 列表?

现在我将所有 URL 存储在一个 DB 列中,我希望能够重新启动蜘蛛,但将长列表(24k 行)传递给 Scrapy,以便它知道跳过它已经看到的那些。

有没有办法做到这一点?

0 投票
1 回答
629 浏览

java - How to filter JWT authentication authorities based on http header

Basically I want to implement a filter after the JWT token is parsed and before the method is called with the ability to modify the authentication object based on an http header

Context

In our application we have (among others) three entities related to authentication/authorization: Users, Permissions and Groups. Permissions can be directly assigned to an user or could be assigned to one of the groups a user belongs to.

Given this a JWT token looks like this:

The JWT flow is setup extending AuthorizationServerConfigurerAdapter and ResourceServerConfigurerAdapter, and the permissions are extracted from the map of JWT claims by extending DefaultUserAuthenticationConverter

By using @EnableGlobalMethodSecurity(prePostEnabled = true) in the configuration I am able to annotate methods with @PreAuthorize

For example:

This works with permissions directly assigned to the user.

However I want to receive an http header e.g: 'x-group' and add permissions from that group (if any) to the authentication object

Then, given the above 'jwt' with the http header set to swimmer I want to be able to invoke the following method:

0 投票
0 回答
117 浏览

javascript - 如何使用 JS 模板中的 TypeScript 添加指令?

我想添加一个按钮来展开或折叠侧边菜单。这是此模板的一部分:http ://webapplayers.com/inspinia_admin-v2.9.1/ (带有 3 条的按钮)/

他们来自模板(角度版本)的代码在 JS 中,但我的项目在 TS 中。我想使用一个绘制按钮的指令,单击时会折叠菜单或展开它。

到目前为止,代码绘制了按钮,但点击时没有任何反应。我的猜测是我需要将 minimumize() 添加到范围。我不确定如何。

JS:(来自模板)

TS:

0 投票
1 回答
24 浏览

checkbox - How to check a checkbox without unchecking?

I am trying to make a script which somehow will check a checkbox (but not uncheck it if it is already checked). Is there a button / shortcut which will check a checkbox? (Clicking will uncheck it if it is checked, so will tab + space) Is there a way of only checking it (does nothing if it is already checked)

I hope this is clear enough, I need a way of checking a checkbox which won't uncheck it if it is already checked.

0 投票
1 回答
451 浏览

python - Tensorflow Advanced Indexing: Assign a smaller tensor into a bigger one into a position based on two index tensors

I would like to create a zeros tensor with shape (3,4,2,2) and insert a (3,4) tensor into that at the position given by two (3,1) tensors.

Sample code: The equivalent numpy operation on arrays would be as follows:

How can I do something similar with Tensorflow?

NOTE: I actually want to work with a tensor of size (32,125,32,32). The above is a simple code for reproduction

0 投票
1 回答
137 浏览

html - MouseLeave event not firing for anchor and other inline elements

I have a link to a codepen and the problem is best observed in Chrome:

https://codepen.io/pkroupoderov/pen/jdRowv

The mouseLeave event does not fire sometimes when a user quickly moves the mouse over multiple images, meaning that some images will still have the grayscale filter applied. How to fix that? If I use a div instead of an anchor element it works totally fine. Should I slightly change the markup or apply certain styles to the anchor element?

I'm trying to create an overlay effect on an image when a user hovers over one just like on Instagram. I will add the content to the overlay later I just need to solve that mouseLeave event issue. CSS pseudo styles is not going to work since the overlay needs to have content in it.

0 投票
2 回答
9357 浏览

python - Why am I getting a ModuleNotFoundError when using googletrans

I have pip installed googletrans and more or less copied this code off a video but for some reason it cannot find the module.

Any help will be greatly appreciated because I am struggling

0 投票
0 回答
2198 浏览

elasticsearch - Logstash 到 elasticsearch ssl 配置

从logstash 到elasticsearch 的ssl 连接出现错误。在弹性搜索中,我看到了这个:

在logstash我看到这个:

logstash.conf

日志存储.yml

弹性搜索.yml

这些键曾经可以工作...我刚刚从 6.0.0 升级到 6.6.1。

我愿意从证书重新开始,我应该对文档中的密钥库和信任库做些什么吗?有什么想法吗??谢谢,克里斯

0 投票
2 回答
193 浏览

for-loop - Sorted for-each loop in XSLT can not reference nodes to XPath query outside of loop

I am attempting to loop through a set of nodes to build a menu of distinct, sorted values. All the possible values are known, but which and how many are included in the XML is not known at run time. The known list changes from time to time, so including the full list would require maintenance control I would rather avoid.

The error text is Required item type of the context item for the parent axis is node(); supplied value has item type xs:anyAtomicType.

I am using XSLT 2.0 from Xerces embedded in Solr 7.6.

I think I understand why, because I am contextually at a text value and not at a node, but I do not know a way around it.

Here is an example XML...

And the XSL transform with the errors causing lines are commented out...

And finally, the result with the placeholders for unavailable data...

0 投票
1 回答
45 浏览

sql - 垂直报告标题

我创建了一个垂直报表,我想在此报表显示的每一页上添加页眉。我该怎么做?我希望报告和标题是垂直的。如果它是水平的:

在此处输入图像描述

我可以添加页眉,但如果是垂直的,我该怎么办?在图片中,我希望在每一页中重复前 3 行。如何获得垂直报告的标题?

0 投票
2 回答
816 浏览

javascript - Changing classList results in an Uncaught TypeError Failed to set an indexed property

I'm trying to change the classes of multiple siblings upon a click event, some of them might have multiple classes to each, but the class that I intend to change is always the first one, so that is what I came with

This worked when I was working with a single class and using className instead of classList, and the function worked fine, but when I switched it to classList, it didn't work and threw the following error

Uncaught TypeError: Failed to set an indexed property on 'DOMTokenList': Index property setter is not supported.

0 投票
2 回答
385 浏览

java - How to break out of while loop after taking in all the inputs?

I have a while loop which detects if sc.hasNext() is true and takes in the list of inputs typed, adding it to the list textEditor one by one.

However, when I type in a list of strings e.g.

the loop does not stop and the method printAll() is not called. How do I break out of the while loop?