我有一个想调试的汇编程序。如果这个程序是用符号汇编的,我可以直接在那个位置设置一个断点_start
,然后告诉 GDB 运行它,它就会立即中断,因为_start
可执行文件的定义就是从那里开始的。
但是,假设这个程序的符号被剥离了。那么,由于该符号不再存在,就无法设置断点了_start
。虽然我可以仔细检查可执行文件的头文件来找到定义的程序起始位置,但我已经非常熟悉这个操作了,所以我希望 GDB 能提供“以单步模式运行”的选项。然而,我在网上找不到任何关于如何做到这一点的信息。
我有一个想调试的汇编程序。如果这个程序是用符号汇编的,我可以直接在那个位置设置一个断点_start
,然后告诉 GDB 运行它,它就会立即中断,因为_start
可执行文件的定义就是从那里开始的。
但是,假设这个程序的符号被剥离了。那么,由于该符号不再存在,就无法设置断点了_start
。虽然我可以仔细检查可执行文件的头文件来找到定义的程序起始位置,但我已经非常熟悉这个操作了,所以我希望 GDB 能提供“以单步模式运行”的选项。然而,我在网上找不到任何关于如何做到这一点的信息。
在我的 Quarkus Java 21 lambda 函数应用程序中,我遵循Powertools Java 库的安装步骤。
我的应用程序包含一个记录对象:
package com.example;
public record ProductDetails(String labelKey, String productType) {}
但是,我的所有记录都出现 Aspectj 错误:
[ERROR] Failed to execute goal dev.aspectj:aspectj-maven-plugin:1.13.1:compile (default) on project lambda-java-quarkus-template: AJC compiler errors:
[ERROR] error at public record CreateCustomerProductRequest(String externalProductCode) {
[ERROR] /mnt/c/Users/me/IdeaProjects/quarkus-lambda-sample-a/src/main/java/be/company/template/adapter/in/alb/model/ProductDetails.java:7:0::0 Syntax error, insert "aspect Identifier" to complete aspect header
为什么会发生这种情况?
我在这里创建了一个重现该问题的项目。您可以通过运行来重现该问题mvn install
。
POM 如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>quarkus-powertools-mcve</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.14.0</compiler-plugin.version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.21.3</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.5.2</surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.21</version>
</dependency>
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-logging</artifactId>
<version>1.20.1</version>
</dependency>
<dependency>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-tracing</artifactId>
<version>1.20.1</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.1</version>
<configuration>
<source>11</source>
<target>11</target>
<complianceLevel>11</complianceLevel>
<aspectLibraries>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-tracing</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-logging</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
<goal>native-image-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
</profile>
</profiles>
</project>
我在 DockerHub 镜像和 Azure 容器实例上设置速率限制时遇到了问题。我们公司提供 Docker 付费订阅,应该可以解决,但我没有密码,只有单点登录 (SSO)。
我该如何在 Terraform 中配置它?image_registry_credentials
我只看到server, username and password
一些字段,没有看到使用令牌等信息。
我浏览了文档,但找不到任何参考资料。在这里找到了一个针对 AKS 的解决方案,但似乎不适用。
我的地形块:
resource "azurerm_container_group" "clamav" {
depends_on = [ azurerm_virtual_network.vnet1 ]
name = "ci-${var.project}-${var.env}-${var.location}-001"
location = var.location
resource_group_name = var.rg
os_type = "Linux"
ip_address_type = "Private"
// avoid docker ratelimiting issues with paid subscription credentials
image_registry_credential {
server = "index.docker.io"
username = "myusername"
password = "what here??"
}
// official clamav image, listens at tcp 3310 inside container group, resolvable at localhost or "clamav"
container {
memory = "3" // source: https://docs.clamav.net/manual/Installing/Docker.html
cpu = "1"
name = "clamav"
image = "clamav/clamav:1.4.2" // avoid "latest" or "stable" to lock down a supported version
}
// sidecar: rest api that accepts multipart file requests at :3000/api/v1/scan, and scans them with clamav
container {
memory = "1"
cpu = "1"
name = "clamav-restapi"
image = "benzino77/clamav-rest-api:1.5.5"
ports {
port = 3000
protocol = "TCP"
}
environment_variables = {
"APP_PORT" : "3000"
"APP_FORM_KEY" : "FILES"
"APP_MAX_FILE_SIZE" : "10485760" // 10MB
"CLAMD_IP" : "localhost"
"CLAMD_PORT" : "3310"
}
}
subnet_ids = [azurerm_subnet.containers.id]
tags = local.tags
}
我有一列日期格式为 dd-mm-yyyy。
我尝试用“.”替换“-”,这样选定的所有日期看起来都像 01.01.2025,而不是 01-01-2025。
当我在 Excel 表中使用 ctrl+H 时它可以工作,但记录的 VBA 代码不起作用。
Selection.Replace What:="-", Replacement:=".", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
我正在构建一个 ASP.NET Core 9 Minimal API,其中我正在处理的端点正在接收表单数据,但无法绑定其中一个属性的值。该属性是一个强类型 id 结构体(使用 Andrew Lock 的 StronglyTypedId 包)。该包确实生成了 aTypeConverter
和 a JsonConverter
,但似乎都没有用于模型绑定。
过去几个小时我一直在寻找解决方案但一无所获,所以我来这里询问是否应该为最小 API 做一些具体的事情来将模型绑定到结构?
下面是我能写出的最短的代码来解释我的意思。如果我传递一个值,它会正确绑定,但如果我按照模型的定义将其保留为空,则会引发以下异常:
Microsoft.AspNetCore.Http.BadHttpRequestException:值“”对于“Id”无效。
[StronglyTypedId(Template.Int, TypedIds.Int, TypedIds.IntEfCore)]
public readonly partial struct TestId;
public static class DoSomething {
[ValidateNever]
public sealed class Command :
IRequest<CommandResponse> {
public TestId? Id { get; init; }
}
public sealed class CommandResponse;
}
file sealed class CommandHandler :
IRequestHandler<Command, CommandResponse> {
public Task<CommandResponse> Handle(
Command command,
CancellationToken cancellationToken) => Task.FromResult(new CommandResponse());
}
internal static class Endpoints {
private const string _tag = nameof(Optimize);
public static WebApplication MapOptimize(
this WebApplication app) {
app.MapPost("/v1/do-something", DoSomethingAsync)
.Accepts<DoSomethingCommand>("multipart/form-data")
.DisableAntiforgery()
.Produces<DoSomethingCommandResponse>()
.WithTags(_tag);
return app;
}
private static async Task<IResult> DoSomethingAsync(
[FromForm] DoSomethingCommand command,
[FromServices] IMediator mediator,
CancellationToken cancellationToken) {
var response = await mediator.Send(command, cancellationToken).ConfigureAwait(false);
return Results.Ok(response);
}
}
下面是演示我的问题的代码:
from multiprocessing import Process
def worker():
print("Worker running")
if __name__ == "__main__":
p = Process(target=worker)
p.start()
input("1...")
input("2...")
p.join()
注意,在 Python 3.13、Windows x64 上运行。
我得到的输出是(输入Enter
两次后):
1...
2...
Worker running
Process finished with exit code 0
从输出中,我们可以看到该进程实际上在第二次输入后就已初始化并开始运行。我原本以为start()
应该阻塞并保证子进程完全初始化。
这是 Python 多处理的正常行为吗?
因为如果在这里使用线程,这个问题很少发生。我总是让线程在 行之前运行input("1...")
。
请问,如果Process.start()
不能保证进程完全启动,我们应该如何编写代码来确保子进程在父进程中继续运行之前确实正在运行?
假设我们有以下代码:
function test() {
const a = {<HERE>}; // `<HERE>` is the caret position
}
按下时enter
,将按预期添加前导空格:
function test() {
const a = {
<HERE>};
}
enter
当按下下一个键时:
function test() {
const a = {
<HERE>};
}
如何返回上一行而不丢失前导空格?当我按下<C-o>
和 时k
:
function test() {
const a = {
<HERE>
};
}
似乎它与文件类型无关。我在 TypeScript 和 Rust 文件中也遇到了同样的问题(其他类型我还没检查)。
我有如下原始数据:
┌─────────┬────────┬─────────────────────┐
│ price │ size │ timestamp │
│ float │ uint16 │ timestamp │
├─────────┼────────┼─────────────────────┤
│ 1697.0 │ 11 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 5 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 5 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 5 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 5 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 4 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 1 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 1 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 1 │ 2009-09-27 18:00:00 │
│ 1697.5 │ 3 │ 2009-09-27 18:00:00 │
│ 1697.5 │ 2 │ 2009-09-27 18:00:00 │
│ 1697.0 │ 1 │ 2009-09-27 18:00:00 │
│ 1698.0 │ 1 │ 2009-09-27 18:00:01 │
│ 1698.25 │ 1 │ 2009-09-27 18:00:01 │
│ 1698.25 │ 10 │ 2009-09-27 18:00:02 │
│ 1698.25 │ 4 │ 2009-09-27 18:00:02 │
│ 1697.25 │ 6 │ 2009-09-27 18:00:02 │
│ 1697.25 │ 2 │ 2009-09-27 18:00:02 │
│ 1697.0 │ 28 │ 2009-09-27 18:00:02 │
│ 1697.25 │ 6 │ 2009-09-27 18:00:03 │
├─────────┴────────┴─────────────────────┤
│ 20 rows 3 columns │
使用 DuckDB,我想为每个时间戳创建直方图,包括价格和大小。
我的尝试:
vp = conn.query(f"""
SET enable_progress_bar = true;
SELECT
timestamp,
histogram(price)
FROM 'data/tickdata.parquet'
GROUP BY timestamp
ORDER BY timestamp
""")
这将产生以下内容:
┌─────────────────────┬─────────────────────────────────────────────────────────────────┐
│ timestamp │ histogram(price) │
│ timestamp │ map(float, ubigint) │
├─────────────────────┼─────────────────────────────────────────────────────────────────┤
│ 2009-09-27 18:00:00 │ {1697.0=10, 1697.5=2} │
│ 2009-09-27 18:00:01 │ {1698.0=1, 1698.25=1} │
│ 2009-09-27 18:00:02 │ {1697.0=1, 1697.25=2, 1698.25=2} │
│ 2009-09-27 18:00:03 │ {1696.0=2, 1696.5=2, 1697.0=2, 1697.25=1} │
│ 2009-09-27 18:00:04 │ {1696.0=2, 1696.25=2, 1696.75=1, 1697.0=1, 1697.25=3, 1697.5=1}
乍一看,它“似乎正确”,但是,与每个键关联的“值”不是大小的总和,而是大小的计数。我期望看到的内容是:
┌─────────────────────┬─────────────────────────────────────────────────────────────────┐
│ timestamp │ histogram(price) │
│ timestamp │ map(float, ubigint) │
├─────────────────────┼─────────────────────────────────────────────────────────────────┤
│ 2009-09-27 18:00:00 │ {1697.0=39, 1697.5=5} │
│ 2009-09-27 18:00:01 │ {1698.0=1, 1698.25=1} │
│ 2009-09-27 18:00:02 │ {1697.0=28, 1697.25=8, 1698.25=14}
或者:我可以生成下表,但不确定是否有办法将其映射到上面的示例中?
┌─────────────────────┬─────────┬───────────┐
│ timestamp │ price │ sum(size) │
│ timestamp │ float │ int128 │
├─────────────────────┼─────────┼───────────┤
│ 2009-09-27 18:00:00 │ 1697.0 │ 39 │
│ 2009-09-27 18:00:00 │ 1697.5 │ 5 │
│ 2009-09-27 18:00:01 │ 1698.0 │ 1 │
│ 2009-09-27 18:00:01 │ 1698.25 │ 1 │
│ 2009-09-27 18:00:02 │ 1698.25 │ 14 │
│ 2009-09-27 18:00:02 │ 1697.25 │ 8 │
│ 2009-09-27 18:00:02 │ 1697.0 │ 28 │
它在我的屏幕和一些测试人员的屏幕上运行,但对于一些屏幕较小的测试人员来说,它会打开一个新链接而不是弹出窗口
HTML:
<a class="popup-video" href="videos/onequote 1.mp4">
<img src="images/thumb1.png">
</a>
脚本:
$(function() {
$('.popup-video').magnificPopup({
disableOn: 1000,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
});
这是我的 Bash 脚本:
#!/bin/bash
#Colors for terminal
#RED
R="\e[31m"
#GREEN
G="\e[32m"
#YELLOW
Y="\e[33m"
#NORMAL
N="\e[0m"
validation(){
if [ $1 -eq 0 ];
then
echo -e "${G}$2 is successful${N}"
else
echo -e "${R}$2 has Failed${N}"
exit 1;
fi
}
echo -e "${Y}Configuring Cart Service${N}"
cart_config="/etc/systemd/system/cart.service"
cat << EOF >$cart_config
Environment=REDIS_HOST="${redis_ip}" #I want TF to only substitute these
Environment=CATALOGUE_HOST="${app_lb_dns}"
Environment=CATALOGUE_PORT=8082
EOF
validation $? "Configuring Cart Service"
Terraform 创建 Redis-Ip 地址和负载均衡器 DNS 后,我会收到它们,我想将替换这些值的 Bash 脚本作为用户数据传递。问题是 Terraform 试图替换${}
Bash 脚本中的每个变量,但我只想将${redis_ip}
和替换${app_lb_dns}
为用户数据。我尝试使用\${}
和转义所有变量,$${}
但没用。
错误:
20:user_data = base64encode(templatefile(“../userdata/cart.sh”,{redis_ip = data.aws_ssm_parameter.redis_ip.value,app_lb_dns = data.aws_ssm_parameter.app_lb_dns.value}))在调用templatefile(path,vars)时“vars”参数的值无效:vars映射不包含键“G”,在../userdata/cart.sh:16,21-22处引用。
根据错误,TF 正在尝试替换与 bash 脚本相关的变量。
这是我的 Terraform 代码:
user_data = base64encode(templatefile("../userdata/cart.sh", { redis_ip = data.aws_ssm_parameter.redis_ip.value, app_lb_dns = data.aws_ssm_parameter.app_lb_dns.value }))