一桥轻雨一伞开

文章 评论 浏览 33

一桥轻雨一伞开 2025-02-11 10:39:28

您的数据是:
响应。data
{_ ID:“ Ubum36vm5”,标签:array(1),内容:“请记住,友谊的手势,无论多么小,总是受到赞赏。”,作者:“ H. Jackson Brown Jr. :“ h-jackson-brown-jr”…}

但是您(破坏“ Quote”)不存在。

const {quote} = response.data.content; const quote = wendesp.data.content;

your data is:
response.data
{_id: "UBum36vM5", tags: Array(1), content: "Remember that a gesture of friendship, no matter how small, is always appreciated.", author: "H. Jackson Brown Jr.", authorSlug: "h-jackson-brown-jr"…}

But you (Destructuring "quote") what does not exist.

const {quote} = response.data.content; const quote = response.data.content;

构建第一反应组件/应用程序,Axios返回重复响应的问题

一桥轻雨一伞开 2025-02-11 05:19:05

在您的html文件

<ion-card-header>
    <ion-img class="logo-flag-greece" alt="mylogo" ></ion-img>
    <span (click)="show_result()" dataHere="France" class="text">France</span>
  </ion-card-header>

and in your ts file

 import {Router} from "@angular/router";
  ...
  ...
  constructor(private router:Router){}

show_result(){
this.router.navigate(["/tabs/result"],{
  queryParams: {
    data: your_data
  }
}); 
}

和您的结果中

 import {ActivatedRoute} from "@angular/router";
   ...
   ...
   constructor(private activatedRoute:ActivatedRoute){}
ionViewDidEnter(){
this.activatedRoute.queryParams.subscribe(params => {
    this.country_data = params['data'];
  });

}

。而是使用“服务”。您可以通过这样的方式将数据传递到另一页。在

in you html file

<ion-card-header>
    <ion-img class="logo-flag-greece" alt="mylogo" ></ion-img>
    <span (click)="show_result()" dataHere="France" class="text">France</span>
  </ion-card-header>

and in your ts file

 import {Router} from "@angular/router";
  ...
  ...
  constructor(private router:Router){}

show_result(){
this.router.navigate(["/tabs/result"],{
  queryParams: {
    data: your_data
  }
}); 
}

and in your result.page.ts file

 import {ActivatedRoute} from "@angular/router";
   ...
   ...
   constructor(private activatedRoute:ActivatedRoute){}
ionViewDidEnter(){
this.activatedRoute.queryParams.subscribe(params => {
    this.country_data = params['data'];
  });

}

But I don't recommend this work around. Instead use "service". Your can pass data from one page to another this way. Learn more about service in https://edupala.com/ionic-service/

通过IONIC中的Routerlink将值传递给其他综合词

一桥轻雨一伞开 2025-02-10 16:06:36

一种方法是编写不同的模式以产生不同的自定义消息。

例如,此模式与 @ 说明之后的逗号匹配

^[^@\s]+@[^@\s,]*,

  • ^字符串启动
  • [^ @ \ s]+ 匹配1+ chars以外whitespace char或 @
  • @匹配
  • [^ @\ s,]*,匹配whitespace char或 @以外的其他可选字符,然后匹配逗号,

此模式与电子邮件之类的格式。它也可以匹配逗号,但是已经检查了该模式的特定模式。

^[^\s@]+@[^\s@]+\.[^\s@]+$

const getMessage = s => {
  if (s.startsWith("@")) {
    return `${s} -->Invalid, string starts with @`;
  }
  if (/^[^@\s]+$/.test(s)) {
    return `${s} --> Invalid, string does not contain @`;
  }
  if (/^[^@\s]+@[^@\s,]*,/.test(s)) {
    return `${s} --> Invalid, string has , after @`;
  }
  if (/^[^@\s]+@[^@\s.]+$/.test(s)) {
    return `${s} --> Invalid, string has no . after @`;
  }
  if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)) {
    return `${s} --> Valid format`;
  }
  return `${s} --> Invalid format`;
};
[
  "@test.com",
  "abc@gmailcom",
  "def.com",
  "abc@gmail,com",
  "[email protected]",
  "test@@"
].forEach(s => console.log(getMessage(s)));

One way is to write different patterns to yield different custom messages.

For example, this pattern matches a comma after the @

^[^@\s]+@[^@\s,]*,

Explanation

  • ^ Start of string
  • [^@\s]+ Match 1+ chars other than a whitespace char or @
  • @ Match literally
  • [^@\s,]*, Match optional chars other than a whitespace char or @, then match the comma

This pattern matches an email like format. It can also match a comma, but that pattern specific pattern is already being checked for.

^[^\s@]+@[^\s@]+\.[^\s@]+$

const getMessage = s => {
  if (s.startsWith("@")) {
    return `${s} -->Invalid, string starts with @`;
  }
  if (/^[^@\s]+$/.test(s)) {
    return `${s} --> Invalid, string does not contain @`;
  }
  if (/^[^@\s]+@[^@\s,]*,/.test(s)) {
    return `${s} --> Invalid, string has , after @`;
  }
  if (/^[^@\s]+@[^@\s.]+$/.test(s)) {
    return `${s} --> Invalid, string has no . after @`;
  }
  if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)) {
    return `${s} --> Valid format`;
  }
  return `${s} --> Invalid format`;
};
[
  "@test.com",
  "abc@gmailcom",
  "def.com",
  "abc@gmail,com",
  "[email protected]",
  "test@@"
].forEach(s => console.log(getMessage(s)));

yup验证一个字符,然后使用其他角色使用正则表达式

一桥轻雨一伞开 2025-02-10 03:17:40

该测试代码可以解决问题。如果您要从头开始构建AR项目(通过选择简单的iOS应用模板,而不是ARKIT模板),请确保添加私密性 - 相机用法描述所需的设备功能(项目0 = ARKIT) ) in info.plist 文件。

import RealityKit
import UIKit

class ViewController: UIViewController {
    
    var arView: ARView = {
        let arView = ARView(frame: .zero)
        let boxAnchor = try! Experience.loadBox()
        arView.scene.anchors.append(boxAnchor)
        return arView
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .red
        
        self.view.addSubview(self.arView)
            
        NSLayoutConstraint.activate([
            arView.topAnchor.constraint(equalTo: self.view.topAnchor),
            arView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            arView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
            arView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor)
        ])
        self.view.subviews.forEach {
            $0.translatesAutoresizingMaskIntoConstraints = false
        }
    }
}

另外,我注意到您添加了两次 casteview

This test code does the trick. If you're building AR project from scratch (by choosing simple iOS App template, not ARKit template), make sure you added Privacy - Camera Usage Description and Required device capabilities (Item 0 = ARKit) in info.plist file.

import RealityKit
import UIKit

class ViewController: UIViewController {
    
    var arView: ARView = {
        let arView = ARView(frame: .zero)
        let boxAnchor = try! Experience.loadBox()
        arView.scene.anchors.append(boxAnchor)
        return arView
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .red
        
        self.view.addSubview(self.arView)
            
        NSLayoutConstraint.activate([
            arView.topAnchor.constraint(equalTo: self.view.topAnchor),
            arView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            arView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
            arView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor)
        ])
        self.view.subviews.forEach {
            $0.translatesAutoresizingMaskIntoConstraints = false
        }
    }
}

Also I've noticed you added sceneView twice.

RealityKit&#x2013;无法加载Arview(找到无)

一桥轻雨一伞开 2025-02-09 20:35:58

spyder维护者在此处)此功能已在我们的 master 分支中可用,这意味着它将是Spyder 6的一部分,将于2023年发布。我们添加了一个新的调试器窗格有一个按钮可以中断当前计算,以便输入调试器并检查为什么要花这么长时间。

要之后,要恢复执行,您需要在 ipdb 中写入命令!继续

(Spyder maintainer here) This functionality is already available in our master branch, which means it'll be part of Spyder 6, to be released in 2023. We added a new Debugger pane which has a button to interrupt the current computation in order to enter the debugger and check why it's taking so long.

To resume execution afterwards, you'd need to write in the IPdb prompt the command !continue.

Python调试 - Spyder-执行期间停止

一桥轻雨一伞开 2025-02-09 15:09:58

调用菜单导航|选择... alt + f1 ,然后在出现的弹出窗口中选择项目视图。您还可以将键盘捷径分配给在Project View 操作中选择文件,以在单个击键中获得相同的结果。

Invoke the menu Navigate | Select In...Alt+F1 and select Project View in the popup that appears. You can also assign a keyboard short cut to the Select File in Project View action, to get the same result in a single keystroke.

Intellij:如何在编辑器中的项目树中快速导航到文件?

一桥轻雨一伞开 2025-02-09 05:50:07
  1. 创建一个临时对象以保存更新的信息。
  2. 在数组上循环,每个对象都会从 product_name status 创建一个定制密钥。
  3. 如果临时对象上不存在密钥,则从当前的对象创建一个新对象,并添加值属性。
  4. 将值增加一个。
  5. 最后,您可以使用 从临时数组中获取新对象。
const data=[{project_name:"test",status:"High"},{project_name:"test",status:"Critical"},{project_name:"test",status:"Critical"}];

const temp = {};

for (const obj of data) {
  const { project_name, status } = obj;
  const key = `${project_name}-${status}`;
  temp[key] ??= { ...obj, value: 0 };
  temp[key].value += 1;
}

console.log(Object.values(temp));

附加文档


您也可以使用 降低 。相同的原理适用(但是在这里,您只是在累加器初始初始化一个空对象,并将其传递到阵列的下一个迭代中),尽管循环可能会更简单地理解您是JS的新手。

const data=[{project_name:"test",status:"High"},{project_name:"test",status:"Critical"},{project_name:"test",status:"Critical"}];

const out = data.reduce((acc, obj) => {
  const { project_name, status } = obj;
  const key = `${project_name}-${status}`;
  acc[key] ??= { ...obj, value: 0 };
  acc[key].value += 1;
  return acc;
}, {});

console.log(Object.values(out));

  1. Create a temporary object to hold the updated information.
  2. Loop over the array, and for each object create a bespoke key from the product_name and the status.
  3. If the key doesn't exist on the temporary object create a new object from the current one, and add a value property.
  4. Increase the value by one.
  5. Finally you can use Object.values to get at the new objects from the temporary array.

const data=[{project_name:"test",status:"High"},{project_name:"test",status:"Critical"},{project_name:"test",status:"Critical"}];

const temp = {};

for (const obj of data) {
  const { project_name, status } = obj;
  const key = `${project_name}-${status}`;
  temp[key] ??= { ...obj, value: 0 };
  temp[key].value += 1;
}

console.log(Object.values(temp));

Additional documentation


You can also use reduce. The same principles apply (but here you're just initialising an empty object for the accumulator, and passing that through to the next iteration of the array) though the loop might be simpler to understand if you're new to JS.

const data=[{project_name:"test",status:"High"},{project_name:"test",status:"Critical"},{project_name:"test",status:"Critical"}];

const out = data.reduce((acc, obj) => {
  const { project_name, status } = obj;
  const key = `${project_name}-${status}`;
  acc[key] ??= { ...obj, value: 0 };
  acc[key].value += 1;
  return acc;
}, {});

console.log(Object.values(out));

如何在数组中计算相同的值&#x200b;并创建一个不同的数组?

一桥轻雨一伞开 2025-02-08 22:51:27

在显示问题时,您可以使用方法后使用方法来启动计时器,并在用户未及时响应时扣除分数。如果用户及时响应,则可以用 的返回值调用 取消作业。

例如,当您想启动计时器时,您将执行类似的操作:

def start_timer():
    global after_id
    root.after(20000, times_up)

这是您具有名为 root 的全局变量,该变量指的是root窗口。不过,您可以使用任何小部件。它的作用是指示tkinter在20秒内(20,000毫秒)

在该功能中调用函数 times_up 您可以将分数降低一个,例如:

def times_up():
    global score
    score += 1

然后,在处理用户选择一个的代码中答案,您可以停止计时器并防止分数下降:

def user_picked_an_answer():
    global after_id
    root.after_cancel(after_id)

如果用户选择答案时调用此功能,则它将计算新的分数并防止计时器触发。

You can use the after method of tkinter to start a timer when a question is shown, and deduct a score if the user hasn't responded in time. If the user responds in time you can call after_cancel with the return value of after to cancel the job.

For example, when you want to start the timer you would do something like this:

def start_timer():
    global after_id
    root.after(20000, times_up)

This assumes you have a global variable named root which refers to the root window. Though, you can use any widget for this. What it does is instruct tkinter to call the function times_up in 20 seconds (20,000 milliseconds)

In that function you can reduce the score by one, for example:

def times_up():
    global score
    score += 1

Then, in the code that processes the user picking an answer, you can stop the timer and prevent the score from doing down:

def user_picked_an_answer():
    global after_id
    root.after_cancel(after_id)

If this function is called when the user picks an answer, it will compute the new score as well as prevent the timer from ever triggering.

测验游戏的线程计时器

一桥轻雨一伞开 2025-02-08 19:03:54

有没有办法以function_v1的样式编写函数,但仍然有编译器进行不同的实例?

如果我们将您的示例扩展一点以更好地揭示编译器的行为:

enum class Foo : char {
    A = 'A',
    B = 'B'
};

struct A_t {
    constexpr operator Foo() const { return Foo::A; }
};

void foo();
void bar();

void function_v1(Foo s){
   if(s == Foo::A){
      foo();
   } else {
      bar();
   }
}

template<class foo_t>
void function_v2(foo_t s){
   if(s == Foo::A){
      foo();
   } else {
      bar();
   }
}

void test1(){
   function_v1(Foo::A);
}

void test2(){
   function_v2(Foo::A);
}

void test3(){
   const A_t a; 
   function_v2(a);
}

并使用 -O3 进行编译,我们得到:

test1(): # @test1()
  jmp foo() # TAILCALL
test2(): # @test2()
  jmp foo() # TAILCALL
test3(): # @test3()
  jmp foo() # TAILCALL

请参见Godbolt.org: https://gcc.godbolt.org/z/443tqcczw

test1(),, test2() test3()完全相同!这是怎么回事?

如果 function_v2()中进行了优化,与它是模板无关,而是在标题中定义的事实(这是必要的模板),并且在呼叫站点中可见完整的实现。

为了获得 function_v1()获得相同好处的所有您所要做的就是定义标题中的功能并将其标记为 inline 以避免违规。您将有效地获得与 function_v2()中所发生的完全相同的优化。

不过,所有这些给您的是等效性。如果您想要保证,则应在编译时(作为模板参数)有力地提供该值:

template<Foo s>
void function_v3() {
    if constexpr (s == Foo::A) {
        foo();
    }
    else {
        bar();
    }
}

// usage:

function_v3<Foo::A>();

如果您仍然需要该函数的运行时进行评估的版本,则可以按照以下行进行操作:

decltype(auto) function_v3(Foo s) {
    switch(s) {
        case Foo::A: 
            return function_v3<Foo::A>();
        case Foo::B: 
            return function_v3<Foo::B>();
    }
}

// Forced compile-time switch
function_v3<Foo::A>();

// At the mercy of the optimizer.
function_v3(some_val);

Is there a way to write a function in the style of function_v1, but still have the compiler make different instantiations?

If we expand your example a bit to better reveal the compiler's behavior:

enum class Foo : char {
    A = 'A',
    B = 'B'
};

struct A_t {
    constexpr operator Foo() const { return Foo::A; }
};

void foo();
void bar();

void function_v1(Foo s){
   if(s == Foo::A){
      foo();
   } else {
      bar();
   }
}

template<class foo_t>
void function_v2(foo_t s){
   if(s == Foo::A){
      foo();
   } else {
      bar();
   }
}

void test1(){
   function_v1(Foo::A);
}

void test2(){
   function_v2(Foo::A);
}

void test3(){
   const A_t a; 
   function_v2(a);
}

And compile with -O3, we get:

test1(): # @test1()
  jmp foo() # TAILCALL
test2(): # @test2()
  jmp foo() # TAILCALL
test3(): # @test3()
  jmp foo() # TAILCALL

See on godbolt.org: https://gcc.godbolt.org/z/443TqcczW

The resulting assembly for test1(), test2() and test3() are the exact same! What's going on here?

The if being optimized out in function_v2() has nothing to do with it being a template, but rather the fact that it is defined in a header (which is a necessity for templates), and the full implementation is visible at call sites.

All you have to do to get the same benefits for function_v1() is to define the function in a header and mark it as inline to avoid ODR violations. You will effectively get the exact same optimizations as are happening in function_v2().

All this gives you is equivalence though. If you want guarantees, you should forcefully provide the value at compile time, as a template parameter:

template<Foo s>
void function_v3() {
    if constexpr (s == Foo::A) {
        foo();
    }
    else {
        bar();
    }
}

// usage:

function_v3<Foo::A>();

If you still need a runtime-evaluated version of the function, you could do something along these lines:

decltype(auto) function_v3(Foo s) {
    switch(s) {
        case Foo::A: 
            return function_v3<Foo::A>();
        case Foo::B: 
            return function_v3<Foo::B>();
    }
}

// Forced compile-time switch
function_v3<Foo::A>();

// At the mercy of the optimizer.
function_v3(some_val);

对没有模板的特定参数的优化

一桥轻雨一伞开 2025-02-08 08:43:28

为了确保明智的浏览器调试,必须在记录数据之前克隆数据。

console.log()的此置换替换仅此操作 - 并支持多个参数。

function logSnapshot() {
  let snapshot = []
  ;[...arguments].forEach(a => snapshot.push(structuredClone(a)))
  console.log.apply(null, snapshot)
}

在内部,它使用 nofollow noreferrer“ >捕获每个参数的时间点快照。

To ensure sensible in-browser debugging, it's necessary to clone the data before logging it.

This drop-in replacement for console.log() does just that -- and supports multiple arguments.

function logSnapshot() {
  let snapshot = []
  ;[...arguments].forEach(a => snapshot.push(structuredClone(a)))
  console.log.apply(null, snapshot)
}

Internally, it uses the structuredClone() global function to capture a point-in-time snapshot of each argument.

console.log()显示了该值实际更改之前变量的更改值

一桥轻雨一伞开 2025-02-07 22:41:43

FDTable组件主要用于BDE兼容性。

fdquery带有“从table1”选择 *与使用fdtable完全相同,但是您可以在服务器端过滤结果集。

100k+记录是很多要传输的数据,Blobs添加了额外的开销,因为它们通常是单独获取的。
我建议您重新考虑功能设计。

FDTable component is there mainly for BDE compatibility.

FDQuery with "select * from Table1" is exactly the same thing as using FDTable, but you can filter resultset on server side.

100k+ records is a lot of data to transfer, blobs add additional overhead, as they're usually fetched separately.
I suggest you rethink the functionality design.

firedac fdtable延迟打开/获取记录

一桥轻雨一伞开 2025-02-07 17:09:15

根据问题的评论,这个答案主要是关于将身份验证添加到该lambda URL上...

我认为Lambda URL不会从Firehose调用。原因是,如果您使用IAM授权(由于安全要求而暗示),则要求客户访问签署API请求。 Firehose不支持这一点。

我不确定FireHose的原因,但我认为您可以删除它,然后直接从EventBridge致电Lambda,或者将API Gateway放在Eventbridge和Lambda之间。

直接调用lambda可能会更简单,但是您失去了拥有Web API的灵活性。但是安全很容易,它由IAM角色处理。

API网关不应该更加困难,我认为您的lambda已经处理有效载荷(因为这是lambda函数URL发送的内容)。看起来这样:

EventBridge -> API Gateway -> Lambda

API网关需要IAM或Cognito授权:

  1. Iam最简单; EventBridge规则可以直接定位API网关,然后该规则只需要使用适当的IAM角色即可。
  2. Cognito会更复杂,但是这里的想法是设置使用 client_credential Flow的用户池客户端。在EventBridge中,您将目标设置为“ EventBridge API目标”,并使用“ OAuth客户端凭据”的授权类型。

您还提到了Clickhouse API,我想这会更简单,具体取决于您在lambda中的逻辑。看起来像他们具有接口,所以您只需要使用“ EventBridge API目标”并发送给该。您的EC2主机要么需要公开访问,要么您可以通过API网关或其他内容来代理请求。

Based on the question's comments, this answer is mostly about adding authentication to that Lambda URL...

I don't think the Lambda URL will work being called from Firehose. The reason is if you're using IAM authorization (implied due to the security requirement) calling it requires the client to sign the API request. Firehose doesn't support that.

I'm not sure of the reason for Firehose, but I think you can remove that and then either call the Lambda directly from EventBridge, or put API Gateway in between EventBridge and the Lambda.

Calling the Lambda directly might be simpler, but then you lose the flexibility of having a web API. But security is easy, its handled by IAM roles.

API Gateway shouldn't be much more difficult, and I assume your Lambda already handles the payload (since that's what the Lambda function URL sends). That looks like this:

EventBridge -> API Gateway -> Lambda

The API Gateway would need either IAM or Cognito authorization:

  1. IAM would be easiest; the EventBridge rule can target the API Gateway directly and then the rule just needs to use the proper IAM role.
  2. Cognito would be more complicated, but the idea here would be to set up a user pool client that uses the client_credential flow. In EventBridge, you'd set up your target as a "EventBridge API destination" and use an authorization type of "OAuth Client Credentials".

You also mention the ClickHouse API, I imagine looking into that would be even simpler, depending on how much logic you have in the Lambda. It looks like they have an interface, so you'd then just need to use the "EventBridge API destination" and send to that. Your EC2 hosts would either need to be publicly accessible, or you might be able to proxy the request through API Gateway or something else.

将Kinesis Firehose的数据发送到Lambda HTTP端点

一桥轻雨一伞开 2025-02-07 10:53:57

您可以尝试运行 Composer install Composer Update 首先安装所有库

You can try to run composer install or composer update to install all libraries first

我在尝试运行以下命令(PHP Artisan服务)时收到了此错误? (顺便说一句,从github克隆了它)

一桥轻雨一伞开 2025-02-06 08:06:11

您的状态不会更新,因为Usestate Hooks的效果不佳。
意味着更新需要花费一些时间,使用异步等待它,希望它能起作用。
BEASR更新useeffect()挂钩中状态的方法,只需在Usefect上更新您的状态即可。

Your state is not updating becasue of useState hooks works as a asyncronously.
Means it takes take some time for update , use async await for it hope it will work.
the beasr way to update state in useEffect() hook, just update your state on useEfect.

单位测试在回调中调用SetState时未更新状态

一桥轻雨一伞开 2025-02-06 03:24:57

您必须通过Roumentodule或RouterTestingModule提供路线。

RouterTestingModule.withRoutes(
      [
        {path: 'home', component: HomeComponent}
      ]
    )

如果您只想识别路线而不调用组件,则可以使用“ redirectto”:

{path: 'home', redirectTo: ''}

You must provide the route via RouterModule or RouterTestingModule.

RouterTestingModule.withRoutes(
      [
        {path: 'home', component: HomeComponent}
      ]
    )

If you only want it to recognize the route and not call the component, you can use "redirectTo":

{path: 'home', redirectTo: ''}

角度单位测试:未被发现的错误:未被发现(在承诺中):错误:无法匹配任何路线

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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