蓦然回首

文章 评论 浏览 30

蓦然回首 2025-02-21 00:11:53

您没有得到所需的结果,因为您将值直接设置为构造函数中的变量“ myCost”。用this.cost =成本;

you are not getting the desired result because you are setting the value directly into the variable "mycost" in the constructor. Replace it with this.cost = cost;

属性设置器可以通过构造函数进行AcitVate吗?

蓦然回首 2025-02-20 00:33:37

如果永远不会重复使用猎人,pois和障碍,那么拥有单独的桌子似乎很浪费。

markers (id, name, latitude, longitude, type, description,
         title -- optional,
         radius -- only for type='Hunter'
        )

是的,我仍然有两个无效的列。但是它们在这里比您拥有的层次结构更合乎逻辑。

您是否需要迭代“所有猎人”?扫描此统一的表其中可能是可以的,其中type ='hunter'

SQL,尤其是MySQL,在层次结构上表现不佳。尝试避免它。

If Hunters, POIs, and Obstacles are never reused, it seems quite wasteful to have separate tables.

markers (id, name, latitude, longitude, type, description,
         title -- optional,
         radius -- only for type='Hunter'
        )

Yes, I still have two NULLable columns. But they are more logical here than in the hierarchy design you had.

Do you ever need to iterate over "all Hunters"? Probably it would be fine to scan this unified table WHERE type='Hunter'.

SQL, especially MySQL, does not play well with hierarchical structure; try to avoid it.

建模数据库;用户,标记,类别,字段

蓦然回首 2025-02-19 22:30:31

我做了自己的解决方案。 (对我有用)

DECLARE @var VARCHAR(MAX)  
DECLARE @var2 VARCHAR(MAX)  
DECLARE @tb as TABLE(       
       VALORES VARCHAR(MAX) )
    
    SET @var = 'AA,NF' 
    SET @var2 = ''
    
    INSERT INTO @tb 
    SELECT value FROM string_split(@var,',')
    
    WHILE EXISTS(SELECT *  FROM @tb) 
            BEGIN
            IF (SELECT COUNT(*)FROM @tb)>1  
               BEGIN    
               SET @var2 = @var2 + (''''+(SELECT TOP 1 * FROM @tb)+'''')+''','''     
               DELETE TOP(1) FROM @tb   
               END      
                  ELSE          
                      BEGIN             
                          SET @var2 = @var2 + (''''+(SELECT TOP 1 * FROM @tb)+'''')                       
                          DELETE TOP(1) FROM @tb            END     END

    
    SELECT @var2

OpenQuery看起来像这样:

OPENQUERY(ORACLEPD, 'SELECT * FROM Ledger where typeLedger in (''+@var2+'')')

结果 @var2返回:'aa'',''nf'

我共享,以防万一有人需要。

I made my own solution. (it worked for me)

DECLARE @var VARCHAR(MAX)  
DECLARE @var2 VARCHAR(MAX)  
DECLARE @tb as TABLE(       
       VALORES VARCHAR(MAX) )
    
    SET @var = 'AA,NF' 
    SET @var2 = ''
    
    INSERT INTO @tb 
    SELECT value FROM string_split(@var,',')
    
    WHILE EXISTS(SELECT *  FROM @tb) 
            BEGIN
            IF (SELECT COUNT(*)FROM @tb)>1  
               BEGIN    
               SET @var2 = @var2 + (''''+(SELECT TOP 1 * FROM @tb)+'''')+''','''     
               DELETE TOP(1) FROM @tb   
               END      
                  ELSE          
                      BEGIN             
                          SET @var2 = @var2 + (''''+(SELECT TOP 1 * FROM @tb)+'''')                       
                          DELETE TOP(1) FROM @tb            END     END

    
    SELECT @var2

The openquery would look like this:

OPENQUERY(ORACLEPD, 'SELECT * FROM Ledger where typeLedger in (''+@var2+'')')

The result @var2 returns: 'AA'',''NF'

I share it in case someone needs it.

将多值​发送到OpenQuery

蓦然回首 2025-02-19 19:06:11

我认为问题是由于 stack_push()使用时使用的表达式容量 + 容量/2的值 _realloc()始终等于1。

请注意,由于 apcatigt int ,并且具有初始值1,因此表达式<的值< em>容量/2为0。

即使调用 _RealLoc(),初始堆栈容量也永远不会增加,因此function stack_push()访问尚未正确分配的内存区域。

I think the problem is due to the fact that the value of the expression capacity + capacity/2, used by stack_push() when it calls _realloc(), is always equal to 1.

Notice that, since capacity is int and has initial value 1, the value of the expression capacity/2 is 0.

The initial stack capacity never increases, even after calling _realloc(), so function stack_push() accesses areas of memory that have not been properly allocated.

c程序在调试时出错-ntdll!

蓦然回首 2025-02-19 11:56:02

您真的不要想要制作 x 参数可选。在您的 Logger 类中,您将将字符串参数传递到 logger 回调中。

您要说的是, logger 回调应该可以随意忽略 String 参数(如果需要)。这会自动支持。因此,只需声明该函数接受单个 String 参数,而不是使参数可选。考虑零-ARG函数

请参阅有关额外函数参数的常见问题条目有关更多信息。

因此,这意味着您应该将代码更改为类似的内容:

type FunctionAcceptingStringArg = ((x: string) => void)

class Logger {
  logger: FunctionAcceptingStringArg
  constructor(logger: FunctionAcceptingStringArg) {
    this.logger = logger;
  }

  log = (x: string) => {
    this.logger(x)
  }

}

我还将日志更改为 String 参数。如果您实际上调用 Logger()使用未定义的为其参数的,可能会发生坏事,因为 logger 可能是(x:string) =&gt; console.log(x.touppercase())在这种情况下会出现运行时错误。您始终使用字符串参数的始终调用 logger ,而不是想要一个可选的参数。


现在,您可以根据需要验证它是否工作:

const logString = (x: string) => console.log(x.toUpperCase())
const logDate = () => console.log(Date.now());
const logStuff = (x: string, y: number) => console.log(x.toUpperCase() + y.toFixed(2))

const stringLogger = new Logger(logString) // okay
const dateLogger = new Logger(logDate) // okay
const nope = new Logger(logStuff); // error!  
// -------------------> ~~~~~~~~
// Argument of type '(x: string, y: number) => void' is not assignable to
// parameter of type 'FunctionAcceptingStringArg'

logString logdate 回调被接受,因为它们每个都可以安全地使用 string 参数。但是 logStuff 被拒绝,因为它需要第二个参数,该参数不会传递。

playground链接到代码

You really don't want to make the x parameter optional. Inside your Logger class you are going to pass a string argument into the logger callback.

What you're trying to say is that the logger callback should feel free to ignore that string parameter if it wants. And this is automatically supported. So, instead of making the parameter optional, just declare that the function accepts a single string parameter. A zero-arg function is considered compatible with that also, because it is (usually) safe to call a function with extra arguments because such a function will just ignore them.

See the FAQ entry on extra function arguments for more information.

So that means you should change your code to something like:

type FunctionAcceptingStringArg = ((x: string) => void)

class Logger {
  logger: FunctionAcceptingStringArg
  constructor(logger: FunctionAcceptingStringArg) {
    this.logger = logger;
  }

  log = (x: string) => {
    this.logger(x)
  }

}

I also changed log to require a string argument. Bad things can happen if you actually call logger() with undefined for its argument, since logger might be (x: string) => console.log(x.toUpperCase()) which would give a runtime error in such cases. It is far more likely that you will always call logger with a string argument than it is for you to want an optional argument.


Now you can verify that it works as desired:

const logString = (x: string) => console.log(x.toUpperCase())
const logDate = () => console.log(Date.now());
const logStuff = (x: string, y: number) => console.log(x.toUpperCase() + y.toFixed(2))

const stringLogger = new Logger(logString) // okay
const dateLogger = new Logger(logDate) // okay
const nope = new Logger(logStuff); // error!  
// -------------------> ~~~~~~~~
// Argument of type '(x: string, y: number) => void' is not assignable to
// parameter of type 'FunctionAcceptingStringArg'

The logString and logDate callbacks are accepted, since each of them are safe to call with just a string argument. But logStuff is rejected because it requires a second argument that will not be passed in.

Playground link to code

用可选参数声明打字稿中的高阶功能

蓦然回首 2025-02-18 18:42:28

您忘了将道具解构

const ReplyReview = (name,replyDrawer,setReplyDrawer,first,setFirst) => {

const ReplyReview = ({name,replyDrawer,setReplyDrawer,first,setFirst}) => {

“ name.name”现在应该是“名称”

You forgot to deconstruct the props

const ReplyReview = (name,replyDrawer,setReplyDrawer,first,setFirst) => {

to

const ReplyReview = ({name,replyDrawer,setReplyDrawer,first,setFirst}) => {

"name.name" should now be just "name"

将USESTATE SETETER功能传递给单击事件的子组件,但获得SetState不是一个函数

蓦然回首 2025-02-18 13:03:10

我建议您查看此Lambda功能的最新CloudWatch日志。该代码正在记录接收的事件(这可以是2种类型之一:创建和更新)。尝试找到每种事件类型的日志。然后从这些日志中制造一些测试事件。

并且不要依靠lambda功能测试事件,因为它们不持久(如您所见)。创建自己的“真实”测试,并像代码一样对其进行修订控制。

I would recommend that you look at recent CloudWatch Logs for this Lambda function. The code is logging the received event (which can be one of 2 types: Create and Update). Try to find a log for each event type. Then fabricate some test events from those logs.

And don't rely on Lambda function test events because they are not persistent (as you have seen). Create your own 'real' tests and revision-control them like code.

需要帮助配置AWS lambda功能的测试事件

蓦然回首 2025-02-17 19:21:28

版本 2022-6-26 不正确最新版本17 。

Version 2022-6-26 is incorrect. The latest version available is 2012-10-17.

EC2实例连接 - IAM策略:畸形的PolicyDocument:策略中的语法错误

蓦然回首 2025-02-17 17:48:08

您在正确的轨道上。将和一些合并使用,您可以导入整个文件。我看不出需要一个创建SET s.name = line.submenu_name - Merge 无论如何如果不存在,则会将其设置为

LOAD CSV WITH HEADERS FROM FROM "https://docs.google.com/spreadsheets/d/e/2PACX-1vS--l-vqnnczvbr8gJnU4MlDwNB0LAsSnOvpsq4Zh0c6Ynyy8JHcpxQc7FEcpTXLSq3-DoQ688a3_/pub?gid=1169333354&single=true&output=csv" AS line
MERGE (m:Module {name: line.`Module`}) 
WITH m, line
MERGE (m)-[:SUB_MODULE]->(s:SubModule {name: line.`Sub-Module`})
WITH s, line
MERGE (s)-[:MENU]->(menu:Menu {name: line.`Menu`})
WITH menu, line
MERGE (menu)-[:SUB_MENU]->(submenu:SubMenu{id: TOINTEGER(line.nodeid), name:line.`Sub Menu`})

You are on the right track. Using WITH and some MERGE you can import the entire file. I don't see the need for the ONE CREATE SET s.name = line.SubMenu_Name - the MERGE will anyway set it if it doesn't exist

LOAD CSV WITH HEADERS FROM FROM "https://docs.google.com/spreadsheets/d/e/2PACX-1vS--l-vqnnczvbr8gJnU4MlDwNB0LAsSnOvpsq4Zh0c6Ynyy8JHcpxQc7FEcpTXLSq3-DoQ688a3_/pub?gid=1169333354&single=true&output=csv" AS line
MERGE (m:Module {name: line.`Module`}) 
WITH m, line
MERGE (m)-[:SUB_MODULE]->(s:SubModule {name: line.`Sub-Module`})
WITH s, line
MERGE (s)-[:MENU]->(menu:Menu {name: line.`Menu`})
WITH menu, line
MERGE (menu)-[:SUB_MENU]->(submenu:SubMenu{id: TOINTEGER(line.nodeid), name:line.`Sub Menu`})

是否可以将这些数据结构的电子表格导入Neo4J来创建节点和关系?

蓦然回首 2025-02-17 15:35:13

您可以通过首先在params中并将其添加在params中,然后在服务器解析中检索它以使对象恢复对象,从而传递对象。

const object = {'itemA':1, 'itemB':1};
query = `field=${JSON.stringify(fieldToReturn)}`

let field = req.query.field;
console.log(field) //will log stringified object
console.log(JSON.parse(field)) // will log it as object

You can pass an object in request params by first stringifying and adding it in params and after retrieving it in server parse it to get object back.

const object = {'itemA':1, 'itemB':1};
query = `field=${JSON.stringify(fieldToReturn)}`

let field = req.query.field;
console.log(field) //will log stringified object
console.log(JSON.parse(field)) // will log it as object

在请求中传递的对象返回为字符串([对象对象])

蓦然回首 2025-02-17 10:17:17

这似乎是正常的,因为可能的国际象棋位置的数量随深度呈指数增长。

国际象棋AI通常具有2个瓶颈:找到所有可能的动作并评估位置。您需要弄清楚瓶颈在哪里,然后尝试从那里进行优化。

您还可以在

实施的一些简单的事情可以大大加快您的代码:

  • 具有良好的董事会表示。最好的是位板,第二好的1D数组,最慢的2D数组表示。
  • 考虑到您正在使用的董事会表示,优化移动生成功能。
  • 使用迭代加深,可以
  • 在找到所有可能的动作后可以更好地分类( https> https://wwww.chessprogramming。 org/move_ordering
  • 仅评估静态位置。这可以逐步完成,并取消移动功能,然后您每次都不必在板上循环。

还有更多的技术,有些比其他技术更先进。要实现这些以及上面的技术,如果您使用Negamax算法,则将更容易。它与minimax相同,它删除了所有重复的代码,从而更容易调试。

This seems normal since the number of possible chess positions increases exponentially with depth.

A Chess AI usually have 2 bottlenecks: Finding all possible moves and evaluating the position. You need to figure out where your bottle neck is and try and optimize from there.

You can also read a lot about different optimization techniques and other general chess programming information at https://www.chessprogramming.org/Main_Page.

A few easy things to implement that would speed up your code significantly:

  • Have a good board representation. Best is Bitboard, second best 1D array, and slowest a 2D array representation.
  • Optimize your move generation functions given the board representation you are using.
  • Use iterative deepening which enables better sorting
  • After you have found all possible moves, sort them (https://www.chessprogramming.org/Move_Ordering)
  • Start by only evaluating the static position. This can be done incrementally in the Make and Unmake move functions, then you won't have to loop over the board each time.

There are plenty of more techniques, some more advanced than others. To implement these, and the techniques above, it will be much easier for you if you use the Negamax algorithm instead. It is the same as Minimax, it removes all duplicate code which makes it easier to debug.

用αβ修剪的minimax算法在深度4处需要超过2分钟

蓦然回首 2025-02-16 21:34:03

来自 documentation> documentation

您还可以使用此方法,然后使用 endupdates()方法来动画行高的更改而无需重新加载单元格。

如果它与动画行高度无关,则没有效果。

From the documentation:

You can also use this method followed by the endUpdates() method to animate the change in the row heights without reloading the cell.

If it's not related to animating row heights then it has no effect.

uitableview beginupdates/endupates在它们之间没有什么效果?

蓦然回首 2025-02-16 20:24:27

在这种情况下,reexport.hs出口到底是什么?

type构造函数,因此您可以使用 ymedata 作为类型:

import ReExport

x :: SomeData
x = undefined

如果定义类型:

data SomeType = SomeData

因此,您正在导出 worder stype

如果您也想导出数据构造函数,则可以使用:

module ReExport (SomeData(SomeData)) where

import SomeData

然后可以使用:

import ReExport

x :: SomeData
x = SomeData

What exactly is ReExport.hs exporting in this case?

The type constructor, so you can use SomeData as type:

import ReExport

x :: SomeData
x = undefined

If you defined a type:

data SomeType = SomeData

you are thus exporting SomeType.

If you want to export the data constructor as well, you use:

module ReExport (SomeData(SomeData)) where

import SomeData

and then you can thus use:

import ReExport

x :: SomeData
x = SomeData

Haskell中的单个实体如何重新出口

蓦然回首 2025-02-16 14:26:17

请参阅使用矩阵来工作< /a>配置您的github操作以部署到3个环境。

然后您选择:

  1. 多个 app.yaml 's(一个每个环境)
    • 优势:简单
    • 缺点:要求您确保其他值保持不变。
  2. 一个 app.yaml
    • 优势:更准确(!?)反映了意图
    • 缺点:要求您添加yaml处理(例如 yq )对您的行为

See Using a matrix for your jobs to configure your GitHub Action to deploy to your 3 environments.

Then you've choices:

  1. Multiple app.yaml's (one per environment)
    • Advantage: simple
    • Disadvantage: requires you to ensure the other values remain unchanged.
  2. One app.yaml
    • Advantage: more accurately (!?) reflects the intent
    • Disadvantage: requires you to add YAML processing (e.g. yq) to your actions

如何在github Action/GPC上设置app.yaml变量

蓦然回首 2025-02-15 17:52:55

您需要让节点知道您要在项目中使用这些文件。或者,您必须获得从节点中使用这些文件的权限。

  1. 为此,在项目的根路径中创建一个名为“ public”的目录

  2. 的根路径中创建一个名为“公共”的目录,并在项目的主文件中使用以下代码

      const path = require('path');
    
     const express = require('express');
    
     app.use(express.static(path.join(__ dirname,'public'))))))
     

代码意味着允许允许公共文件夹中的任何文件(例如JS CSS IMG)访问和使用

You need to let the node know that you want to use these files in your project. Or you have to get permission to use these files from the node.

  1. To do this, create a directory called 'public' in the root path of your project

  2. And use the following code in the main file of your project

     const path = require('path');
    
     const express = require('express');
    
     app.use(express.static(path.join(__dirname, 'public')))
    

The above code means that any file in the public folder (such as js css img) is allowed to access and use

用CSS和JS代码页将HTML转换为节点JS应用程序

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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