鹿!

文章 评论 浏览 30

鹿! 2025-02-20 23:23:18

没有脚本,您需要为每种颜色进行预编程。 for example...

red:

=(A1="John")*($D$2="red")

green:

=(A1="John")*($D$2="green")

without script, you would need to pre-program it for each color. for example...

red:

=(A1="John")*($D$2="red")

green:

=(A1="John")*($D$2="green")

enter image description here

Google表格 - 有条件格式化多个文本值

鹿! 2025-02-20 18:04:32

问题在这里定义一个空容器:

widget.initialItem == 0
              ? Container()
              : Positioned(

如果您将其删除并保持所有预期的所有内容,则您没有空间。由于您使用的是 wrap 窗口小部件,因此空容器还充当了主轴上一个与先前孩子相邻的儿童,由方向给出,在介于两者之间的间距空间。

来自文档:

如果没有足够的空间适合孩子,则包裹会创建新的运行
毗邻横轴中现有儿童。

在您的代码中删除此行,您没有任何空白空间作为UI中的行为。 在这里阅读更多

The problem is here where you define an empty container:

widget.initialItem == 0
              ? Container()
              : Positioned(

If you remove this and keep everything as expected you dont have the space. Since you are using Wrap Widget the empty container also acts as child adjacent to the previous child in the main axis, given by direction, leaving spacing space in between.

enter image description hereFrom the documentation:

If there is not enough space to fit the child, Wrap creates a new run
adjacent to the existing children in the cross axis.

removing this line in your code you don't have any empty space as behavior in your UI. Read more here

为什么要在弹奏中添加包装小部件的小部件时离开空间?

鹿! 2025-02-20 10:11:14

复制Charlieface评论,这是答案。

事件意味着内部方法,例如add_yourevent和Remove_yourevent,因此存在命名冲突。

查看带有事件的保留名称的规格
https://learn.microsoft.com/en-us/dotnet/csharp/csharp/language-reference/language-specification/classes#143103-member-names-names-forever-for-events

Copying Charlieface comment, which is the answer.

An event implies internal methods such as add_YourEvent and remove_YourEvent so there is a naming clash.

See the spec with reserved names for events
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/classes#143103-member-names-reserved-for-events

.NET已经包含以add_开头的事件变量的定义

鹿! 2025-02-19 23:46:22

您的代码中有一个错误。当您将数据写入PANDAS DataFrame时,每次被最后值覆盖时,您将获得最后一个值作为输出,并且较早的值不会持久。我建议的是将3个值保存到列表中,然后使用此列表列表创建一个数据框架。查看下面的代码:

import random
import pandas as pd
list_of_columns = []

def result(a,b):
    return a+b

for i in range(10):
    a = random.randint(1,100)
    b = random.randint(1,100)
    res = result(a,b)
    list_of_columns.append([a,b,res])
    
data = pd.DataFrame(list_of_columns)
data.columns = ['num1', 'num2','result']
data.to_excel('output.xlsx', sheet_name='sheet1', index=False)

希望这会有所帮助!

There is one mistake in your code. As you are writing the data into the pandas dataframe, everytime its getting overwritten by the last value, hence you are getting last value as output, and earlier values are not persisting. What i suggest, is to save the 3 values into a list and then creating a dataframe with this list of lists. Check out the code below:

import random
import pandas as pd
list_of_columns = []

def result(a,b):
    return a+b

for i in range(10):
    a = random.randint(1,100)
    b = random.randint(1,100)
    res = result(a,b)
    list_of_columns.append([a,b,res])
    
data = pd.DataFrame(list_of_columns)
data.columns = ['num1', 'num2','result']
data.to_excel('output.xlsx', sheet_name='sheet1', index=False)

Hope this helps !

如何使用pandas将多个数据保存到Excel中

鹿! 2025-02-19 20:51:35

我猜,找到 all byentity2isnull会使弹簧数据混淆,因此请尝试使用名称的方法

List<Entity1> findByEntity2IsNull()

I guess, findAllByEntity2IsNull confuses Spring Data, so try using method with name

List<Entity1> findByEntity2IsNull()

派生查询与JPA和Spring Data的无效@OnetoOne关系

鹿! 2025-02-19 14:25:22

您可以 Unbind 单击事件, bind 再次使其正常工作:

$('.dropdown-menu').find('.dropdown-submenu').not('.disabled').find('.dropdown-toggle').unbind('click').bind('click', function (e) {
    // yourCode
});

You can unbind click event and bind it again to make it work properly:

$('.dropdown-menu').find('.dropdown-submenu').not('.disabled').find('.dropdown-toggle').unbind('click').bind('click', function (e) {
    // yourCode
});

Angular jQuery点击事件应双击要工作

鹿! 2025-02-18 16:52:29

使用库pymupdf: -

  1. 使用页面块的坐标
    page.get_text('dict')
  2. 您将获得所需文本的坐标---&gt; RECT
  3. 现在用于提取文本 page.get_text(clip = rect,sort = false)。在这里, rect 是要提取的矩形框(文本)的坐标。

Using the library PyMuPDF:-

  1. Find the coordinates of the blocks of the page using
    Page.get_text('dict')
  2. You will get the coordinates of the required text---> rect.
  3. Now for extracting the text Page.get_text(clip=rect,sort=False). Here, the rect is the coordinates of the rectangle box(text) that you want to extract.

使用Python从PDF中提取特定文本

鹿! 2025-02-18 06:42:35

我已经通过在$查找后添加另一个$匹配来实现这一目标

parentCollection.aggregate([ 
        { 
            '$match': { 
                userId: '62810c69e880ed667073add1',
                type: 'data' 
            } 
        }, 
        { 
            '$lookup': { 
                from: 'childCollection', 
                let: { typeId: { '$toObjectId': '$typeId' } }, 
                pipeline: [ { 
                    '$match': { 
                        '$expr': { '$eq': [ '$_id', '$typeId' ] }, 
                        '$or': [ { 
                            'field1': { '$regex': '737', '$options': 'i' } 
                        }, 
                        { 
                            'field2': { '$regex': '737', '$options': 'i' } 
                        }] 
                    }
                }], 
                as: 'child' 
            } 
        },{
            $match: {
                $expr: {
                    $gt: [{
                        $size: '$child'
                    }, 0]
                }
            }
        },
        { '$limit': 10 }, { '$skip': 0 }], 
{});

I have achieved this by adding an additional $match on child after $lookup

parentCollection.aggregate([ 
        { 
            '$match': { 
                userId: '62810c69e880ed667073add1',
                type: 'data' 
            } 
        }, 
        { 
            '$lookup': { 
                from: 'childCollection', 
                let: { typeId: { '$toObjectId': '$typeId' } }, 
                pipeline: [ { 
                    '$match': { 
                        '$expr': { '$eq': [ '$_id', '$typeId' ] }, 
                        '$or': [ { 
                            'field1': { '$regex': '737', '$options': 'i' } 
                        }, 
                        { 
                            'field2': { '$regex': '737', '$options': 'i' } 
                        }] 
                    }
                }], 
                as: 'child' 
            } 
        },{
            $match: {
                $expr: {
                    $gt: [{
                        $size: '$child'
                    }, 0]
                }
            }
        },
        { '$limit': 10 }, { '$skip': 0 }], 
{});

mongoose不要选择与任何相关的记录

鹿! 2025-02-16 19:00:56

据我所知,您无需解析任何“复杂”(例如任意S-表达)等的任何“复杂” - 您感兴趣的只是消除((((foo))))>和(((bar))(它们具有相同数量的打开/关闭parens),但要保留((((foo))bar)完整的内容。

如果此假设是正确的,则非常简单 gsub 可以完成工作:

def delete_parentheses(str)
  str.gsub(/(\(+)\w+(\)+)/) do |match|
    $1.size == $2.size ? "" : match
  end
end

delete_parentheses("Here ((be)) dragons") # => Here dragons
delete_parentheses("Here ((be) dragons") # Here ((be) dragons

As far as I understand, you don't need to parse anything "complex" like arbitrary S-expressions etc - all you're interested in is just to eliminate things like (((foo))) and ((bar)) (they have the same number of opening/closing parens) but keep things like (((foo)) bar) intact.

If this assumption is correct then quite simple gsub can do the job:

def delete_parentheses(str)
  str.gsub(/(\(+)\w+(\)+)/) do |match|
    $1.size == $2.size ? "" : match
  end
end

delete_parentheses("Here ((be)) dragons") # => Here dragons
delete_parentheses("Here ((be) dragons") # Here ((be) dragons

去除括号的亚表达

鹿! 2025-02-16 17:16:38

进行了大量挖掘之后

      kinesis_settings = {
        #  service_access_role_arn        = aws_iam_role.dms_write_to_rating_data_sync.arn
        stream_arn                     = data.aws_kinesis_stream.rating_replication_stream.arn
        partition_include_schema_table = true
        include_partition_value        = true
      }

昨天 nofollow noreferrer“> https://github.com/hashicorp/terraform/issues/30937

最终导致此Terraform设置

      kinesis_settings = {
        service_access_role_arn        = "arn:aws:iam::${module.defaults.aws_account_id}:role/${var.env_name}-dms-assume-kinesis-write-role
        stream_arn                     = data.aws_kinesis_stream.rating_replication_stream.arn
        partition_include_schema_table = true
        include_partition_value        = true
      }

After a lot of digging yesterday a co-worker and I found a modification that built a plan correctly

      kinesis_settings = {
        #  service_access_role_arn        = aws_iam_role.dms_write_to_rating_data_sync.arn
        stream_arn                     = data.aws_kinesis_stream.rating_replication_stream.arn
        partition_include_schema_table = true
        include_partition_value        = true
      }

Which lead to this github ticket https://github.com/hashicorp/terraform/issues/30937

and finally lead to this terraform setup

      kinesis_settings = {
        service_access_role_arn        = "arn:aws:iam::${module.defaults.aws_account_id}:role/${var.env_name}-dms-assume-kinesis-write-role
        stream_arn                     = data.aws_kinesis_stream.rating_replication_stream.arn
        partition_include_schema_table = true
        include_partition_value        = true
      }

AWS DMS Terraform模块不拾取运动式设置?

鹿! 2025-02-16 13:55:11

我尝试了您的布局字符串生成器脚本,但发现了一些小问题(输入号不正确,不支持不同的X/Y网格计数)
这是解决这些问题的脚本:

x = 2
y = 3

layout_col = ["h0"]
for i in range(y-2):
    current_col = "h" + str(i+1)
    current_col = layout_col[-1]+"+"+current_col
    layout_col.append(current_col)
layout_col.insert(0,"0")

layout_row = ["w0"] 
for i in range(x-2):
    current_row = "w"+str((i+1)*x)
    current_row = layout_row[-1]+"+"+current_row
    layout_row.append(current_row)
layout_row.insert(0,"0")

layout = []
for i in range(min(x,y)):
    for j in range(max(x,y)):
        comb =   layout_row[i] + "_" + layout_col[j] 
        layout.append(comb)
layout = "|".join(layout)
layout = "xstack=inputs="+str(x*y)+":layout="+layout

print (layout)

I tried your layout string generator script but found some minor issues (inputs number was incorrect, no support for different X/Y grid count)
Here's the script with those issues fixed:

x = 2
y = 3

layout_col = ["h0"]
for i in range(y-2):
    current_col = "h" + str(i+1)
    current_col = layout_col[-1]+"+"+current_col
    layout_col.append(current_col)
layout_col.insert(0,"0")

layout_row = ["w0"] 
for i in range(x-2):
    current_row = "w"+str((i+1)*x)
    current_row = layout_row[-1]+"+"+current_row
    layout_row.append(current_row)
layout_row.insert(0,"0")

layout = []
for i in range(min(x,y)):
    for j in range(max(x,y)):
        comb =   layout_row[i] + "_" + layout_col[j] 
        layout.append(comb)
layout = "|".join(layout)
layout = "xstack=inputs="+str(x*y)+":layout="+layout

print (layout)

python中的FFMPEG XSTACK布局

鹿! 2025-02-15 18:18:23

我可以尝试帮助您开始解决这个问题,但是听起来像是一个家庭作业问题,所以我不会给您一个完整的答案(per 指南)。

如果我是,您将从小案例开始,然后从那里开始积累。让我们首先:

w = "ab"
w2 = "ba"

此功能可能看起来像:

def function(w,w2):
    prefix = ""
    # Does the first letter of w equal the last letter of w2?
    if w[0] == w2[-1]:
        prefix += w[0]
        
    # What about the second letter?
    if w[1] == w2[-2]:
        prefix += w[1]

    return prefix

然后运行 print(function(w,w2))您获得 ab

该代码应该适用于两个字母单词,但是如果单词更长,该怎么办?这是我们引入循环的时候。

def function(w,w2):
    prefix = ""
    
    for i in range(0, len(w)):
        if w[i] == w2[(i+1)*-1]:
            prefix+= w[i]
        else:
            return prefix
            
    return prefix

希望此代码将为您提供一个不错的起点!我写的一个问题是,如果W2比w短。然后,您将获得索引错误!有几种方法可以解决这个问题,但是一种方法是确保W始终是较短的词。祝您好运,如果您还有其他疑问,请随时为我辩解。

I can try and help get you started on this problem, but it sort of sounds like a homework question so I won't give you a complete answer (per these guidelines).

If I were you I'd start with a small case and build up from there. Lets start with:

w = "ab"
w2 = "ba"

The function for this might look like:

def function(w,w2):
    prefix = ""
    # Does the first letter of w equal the last letter of w2?
    if w[0] == w2[-1]:
        prefix += w[0]
        
    # What about the second letter?
    if w[1] == w2[-2]:
        prefix += w[1]

    return prefix

Then when you run print(function(w,w2)) you get ab.

This code should work for 2 letter words, but what if the words are longer? This is when we would introduce a loop.

def function(w,w2):
    prefix = ""
    
    for i in range(0, len(w)):
        if w[i] == w2[(i+1)*-1]:
            prefix+= w[i]
        else:
            return prefix
            
    return prefix

Hopefully this code will offer a good starting place for you! One issue with what I have written is what if w2 is shorter than w. Then you will get an index error! There are a few ways to solve this, but one way is to make sure that w is always the shorter word. Best of luck, and feel free to DM me if you have other questions.

最长的前缀也是两个列表的后缀

鹿! 2025-02-15 11:08:37

为什么要使用此软件包?

您可以直接使用Stripe的软件包: https://stripe.com/docs/docs/api

Why would you use this package?

You can directly use Stripe's package: https://www.npmjs.com/package/stripe which is very well documented here: https://stripe.com/docs/api

找不到换条错误模块:可以分辨&#x27; ./ dist/client&#x27;

鹿! 2025-02-15 09:43:47

我想为解决方案做出贡献,用于上述答案中未提及的特殊情况,如果您在WKWebView中使用自定义字体,则可能发生这种情况。

我尝试了这里解释的所有解决方案,以及其他Stackoverflow问题中提到的许多解决方案。没有什么可以正常工作的。我总是遇到同样的问题:返回的高度总是比WKWebView的实际高度小一点。我尝试了WKNAvigationDelegate的方式,并试图通过将JS注射到HTML渲染的HTML渲染但没有成功的情况下来聆听自我生成的事件,在所有情况下,高度总是错误的。

我学到的第一件事是:在加载HTML并等待完成的事件之前,必须将网络浏览量添加到布局中。如果您尝试以隔离的方式渲染WebView而不将其添加到布局之前,则高度将非常错误。

奇怪的是,我发现在渲染HTML之后设置一个断点,然后在调用高度评估方法之前,返回的高度是正确的。测量哪个高度(卷轴或越野)并不重要,两者总是正确的。

那指向我朝正确的方向指出。结论是显而易见的(尽管我需要很多天才能实现调试才能实现):收到了finishnavigation事件之后,或者如果您使用自定义JS并收听窗口。但不是完全因为渲染尚未完成。

如解释在这里,在将字体脸式应用于文档之前,Safari触发了domcontenloaded事件(也许在将CSS应用于文档之前?)。就我而言,我正在使用应用程序中嵌入的自定义字体,并以经典方式在HTML中引用:

 <style>
    @font-face {
        font-family: 'CustomFont';
        src: url('montserrat.ttf');
        format('truetype');
    }

    body{
        font-family: 'CustomFont';
        font-size: 12px;
    }

解决方案? 您必须收听event document.fonts.ready,这是在事件窗口之后发生的。在HTML中启动以下JS,您正在加载WKWebView:

    document.fonts.ready.then(function() {
 window.webkit.messageHandlers.iosEventListener.postMessage('custom_event_fonts_ready');
  
});

然后在您的iOS应用中,与接收到事件

  self.webView.configuration.userContentController.add(self, name: "iosEventListener")

时,

        public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
            if let body = message.body as? String {
                if (body == "custom_event_fonts_ready") {
                        self.evaluateBodyHeight()
    }
            }
        }

 private func evaluateBodyHeight() {
        self.webView.evaluateJavaScript("document.readyState", completionHandler: { (complete, error) in
            if complete != nil {
                self.webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { (height, error) in
                    let webViewHeight = height as! CGFloat
//Do something with the height.


                })

            }
        })

    }

我不确定,但是我认为使用此解决方案,所有不同的方法来测量高度的高度Web视图将返回正确的视图。经过将近一个月的调试和绝望之后,我不想

为他们的英语不好而道歉。

I want to contribute with the solution for a special case that is not mentioned in the answers above and that may happen to you if you are using custom fonts in your WKWebView.

I tried ALL the solutions explained here, and many others mentioned in other StackOverflow questions. Nothing was working 100% correctly for me. I had always the same problem: the height returned was always a little smaller than the real height of the WkWebView. I tried WKNavigationDelegate way, and I tried to listen to self-generated events by injecting js into the HTML rendered, without success, the height was always wrong in all cases.

The first thing I learned: the webview has to be added to the layout before loading the html and waiting for the finished event. If you try to render the webview in an isolated way without adding it before to the layout, then the height will be very wrong.

Curiously, I found out that setting a breakpoint after the html was rendered, and before calling the height evaluation method, then the returned height was correct. It was not important which height was measured (scrollHeight or offsetheight), both were always correct.

That pointed me in the right direction. The conclusion was obvious (although I needed a lot of days making debug to realize it): after the didFinishNavigation event is received, or if you are using custom js and listening to the window.onload event or similar, the height returned is almost correct but not completely because the rendering is not finished yet.

As explained here, Firefox, Chrome, and Safari trigger the DomContenLoaded event before the font-face is applied to the document (and maybe, before the css is applied to the document too?). In my case, I was using a custom font embedded in my app and referenced in the HTML in the classical way:

 <style>
    @font-face {
        font-family: 'CustomFont';
        src: url('montserrat.ttf');
        format('truetype');
    }

    body{
        font-family: 'CustomFont';
        font-size: 12px;
    }

Solution? You have to listen to the event document.fonts.ready, that happens after the event window.onload and the like. Embeed the following js in the html you are loading in the WkWebView:

    document.fonts.ready.then(function() {
 window.webkit.messageHandlers.iosEventListener.postMessage('custom_event_fonts_ready');
  
});

Then in your iOS app, listen to the event with

  self.webView.configuration.userContentController.add(self, name: "iosEventListener")

and when received

        public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
            if let body = message.body as? String {
                if (body == "custom_event_fonts_ready") {
                        self.evaluateBodyHeight()
    }
            }
        }

 private func evaluateBodyHeight() {
        self.webView.evaluateJavaScript("document.readyState", completionHandler: { (complete, error) in
            if complete != nil {
                self.webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { (height, error) in
                    let webViewHeight = height as! CGFloat
//Do something with the height.


                })

            }
        })

    }

I'm not sure, but I think that with this solution, all the different ways to measure the height of web view will return the correct one. After almost one month of debugging and being desperate, I have no desire to test them

Apologizes for my bad English.

如何确定WKWebView的内容大小?

鹿! 2025-02-15 09:25:32

这不是您将一系列结构从托管代码到本机代码的方式。

在您的P/Invoke声明中:

[DllImport("a.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void test_data(ref DATA pData, int length);

参考数据pdata 元帅,指向单个 data 对象的指针。不能保证其余的数组将与之一起发送。如果您的结构为 blittable ,因为随后编组它只会涉及固定数组,然后将其地址按照C函数传递。但是,las,该结构包含一个数组,该数组是参考类型。当您将其传递到C函数时,元帅必须进行副本以获得具有正确布局的结构。因此,当您通过 ref arr [0] 时,您只会发送一个副本,然后您的C代码立即走出缓冲区末端,然后击中未定义的行为。而且,从更加哲学的角度来看, pdata 应该是一个数组,也很清楚。

因此,相反,要发送整个批次,只需将您的参数声明为数组,

[DllImport("a.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void test_data(DATA[] pData, int length);

That's not how you marshal an array of structures from managed code to native code.

In your P/Invoke declaration:

[DllImport("a.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void test_data(ref DATA pData, int length);

ref DATA pData marshals to a pointer to a single DATA object. There is no guarantee that the rest of the array will be sent along with it. It could have worked if your structure was blittable, because then marshalling it would simply have involved pinning the array and then passing its address as is to the C function. But, alas, the structure contains an array, which is a reference type. When you pass it to the C function, the marshaler has to do a copy to get a struct with the right layout. So, when you pass ref arr[0], you're only sending one copy, and then your C code walks right off the end of the buffer and you hit undefined behaviour. And, on a more philosophical level, it's also less clear that pData is supposed to be an array.

So instead, to send the whole batch, just declare your argument as an array, as explained in the documentation, and the marshaler will do the rest:

[DllImport("a.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void test_data(DATA[] pData, int length);

将struct阵列从c#通过struct指针传递到c#

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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