倾城花音

文章 评论 浏览 30

倾城花音 2025-02-20 23:04:06

在颤抖中

约束下降,大小上升

请参见此文档

Flutter使用a 单个Pass AlgorithM 渲染您的申请。这是确保性能的技术选择,但它具有限制。

其中之一是,当您构建小部件树时,您只能访问父级的约束,而不访问任何小部件的大小(因为它们尚未渲染)。

因此,对您的问题的简短答案是:

不,您无法做自己想做的事情(如果某些小部件不合适在屏幕上,则显示某些内容),因为您无法访问构建方法中的任何尺寸。

另一种解决方案是使用 Wrap 包装芯片或在水平轴上使用 ListView ,以使芯片列表水平滚动。


无论如何,如果您真的想这样做,则可以用 MediaQuery.of(context).Size 或使用 LayoutBuilder 使用 contrapts.maxwidth 作为父宽度。然后,您可以检查 numberofchips * chipsize< = maxWidth 。但是我不建议这样做,因为设计不会响应:

  • 所有芯片的尺寸都相同,因此您最终会得到“ C”的大筹码,也许是像“ Python” Won'这样的长名字。 T适合,您最终会遇到溢出问题。
  • 如果用户更改设备的字体尺寸怎么办?您还将遇到溢出问题。

In flutter

Constraints go down and sizes go up

See this documentation.

Flutter uses a single pass algorithm to render your application. This is a technical choice to ensure performance but it comes with limitations.

One of them is that, when you are building the widget tree, you only have access to the constraints of the parent, and not any size of any widget (since they are not rendered yet).

So a short answer to your question is:

No, you cannot do what you are trying to do (displaying something if some widgets are not fitting on the screen) since you don't have access to any sizes in the build method.

An alternative solution would be to use Wrap to wrap your chips or use a ListView on the horizontal axis to make the list of chips horizontally scrollable.


Anyway, if you really want to do this, you can hardcode the sizes of your chip and access the device size with MediaQuery.of(context).size or by using the LayoutBuilder and using contraints.maxWidth as the parent's width. Then you can check whether or not numberOfChips * chipSize <= maxWidth. But I wouldn't recommend it as the design wouldn't be responsive:

  • All the chips will have the same size, so you'll end up with a big chip for "c" and maybe a long name like "python" won't fit in and you'll end up with overflow issues.
  • What if the user changes the font size of his device? You will also end up with overflow issues.

有没有办法计算动态尺寸的小部件?

倾城花音 2025-02-20 09:01:04

好的,这是如何非审查但列表的示例

请注意,此示例是基于/访问本地文件系统的,但是可以轻松地重写/扩展到任何类型的层次/递归结构。

package stackoverflow.nonrecursivefilesearch;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.stream.Stream;

public class NonRecursiveFileSearch {

    public static void main(final String[] args) throws IOException {
        final File searchDir = new File("D:\\test\\maven-test"); // set one

        System.out.println("\nOld Java");
        printDirs(listFiles_old(searchDir, true, true), "OLD: Depth first, include dirs");
        printDirs(listFiles_old(searchDir, true, false), "OLD: Breadth first, include dirs");
        printDirs(listFiles_old(searchDir, false, true), "OLD: Depth first, exclude dirs");
        printDirs(listFiles_old(searchDir, false, false), "OLD: Breadth first, exclude dirs");

        System.out.println("\nNew java.io with streams");
        printDirs(listFiles_newIO(searchDir, true), "Java NIO, include dirs");
        printDirs(listFiles_newIO(searchDir, false), "Java NIO, exclude dirs");
    }

    /**
     * this is the way to 'manually' find files in hierarchial/recursive structures
     *
     * reminder: "Depth First" is not a real depth-first implementation
     * real depth-first would iterate subdirs immediately.
     * this implementation iterates breadth first, but descends into supdirs before it handles same-level directories
     * advantage of this implementation is its speed, no need for additional lists etc.
     *
     * in case you want to exclude recursion traps made possible by symbolic or hard links, you could introduce a hashset/treeset with
     * visited files (use filename strings retrieved with canonicalpath).
     * in the loop, check if the current canonical filename string is contained in the hash/treeset
     */
    static public ArrayList<File> listFiles_old(final File pDir, final boolean pIncludeDirectories, final boolean pDepthFirst) {
        final ArrayList<File> found = new ArrayList<>();
        final ArrayList<File> todo = new ArrayList<>();

        todo.add(pDir);

        while (todo.size() > 0) {
            final int removeIndex = pDepthFirst ? todo.size() - 1 : 0;
            final File currentDir = todo.remove(removeIndex);
            if (currentDir == null || !currentDir.isDirectory()) continue;

            final File[] files = currentDir.listFiles();
            for (final File file : files) {
                if (file.isDirectory()) {
                    if (pIncludeDirectories) found.add(file);
                    // additional directory filters go here
                    todo.add(file);
                } else {
                    // additional file filters go here
                    found.add(file);
                }
            }
        }

        return found;
    }

    static private void printDirs(final ArrayList<File> pFiles, final String pTitle) {
        System.out.println("====================== " + pTitle + " ======================");
        for (int i = 0; i < pFiles.size(); i++) {
            final File file = pFiles.get(i);
            System.out.println(i + "\t" + file.getAbsolutePath());
        }
        System.out.println("============================================================");
    }

    /**
     * this is the java.nio approach. this is NOT be a good solution for cases where you have to retrieve/handle files in your own code.
     * this is only useful, if the any NIO class provides support. in this case, NIO class java.nio.file.Files helps handling local files.
     * if NIO or your target system does not offer such helper methods, this way is harder to implement, as you have to set up the helper method yourself.
     */
    static public Stream<Path> listFiles_newIO(final File pDir, final boolean pIncludeDirectories) throws IOException {
        final Stream<Path> stream = Files.find(pDir.toPath(), 100,
                (path, basicFileAttributes) -> {
                    final File file = path.toFile(); // conversion to File for easier access (f.e. isDirectory()), could also use NIO methods
                    return (pIncludeDirectories || !file.isDirectory() /* additional filters go here */ );
                });
        return stream;

    }
    static private void printDirs(final Stream<Path> pStream, final String pTitle) {
        System.out.println("====================== " + pTitle + " ======================");
        pStream.forEach(System.out::println);
        System.out.println("============================================================");
    }
}

而且,必须添加 java.nio.file.files.find()可以递归地实现。但这只是一个电话,这也许也可以算作“非恢复性”。

另外,正如OP在评论中所说的那样,人们可能会使用堆栈或其他FIFO/LIFO收集。 Lifo是混合深度第一,FIFO,用于广度优先的方法。

Okay, here is an example of how to handle it non-recursively, but with lists.

Mind, that this example is based on /accessing the local filesystem, but can easily be rewritten/extended for any kind of hierarchial/recursive structure.

package stackoverflow.nonrecursivefilesearch;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.stream.Stream;

public class NonRecursiveFileSearch {

    public static void main(final String[] args) throws IOException {
        final File searchDir = new File("D:\\test\\maven-test"); // set one

        System.out.println("\nOld Java");
        printDirs(listFiles_old(searchDir, true, true), "OLD: Depth first, include dirs");
        printDirs(listFiles_old(searchDir, true, false), "OLD: Breadth first, include dirs");
        printDirs(listFiles_old(searchDir, false, true), "OLD: Depth first, exclude dirs");
        printDirs(listFiles_old(searchDir, false, false), "OLD: Breadth first, exclude dirs");

        System.out.println("\nNew java.io with streams");
        printDirs(listFiles_newIO(searchDir, true), "Java NIO, include dirs");
        printDirs(listFiles_newIO(searchDir, false), "Java NIO, exclude dirs");
    }

    /**
     * this is the way to 'manually' find files in hierarchial/recursive structures
     *
     * reminder: "Depth First" is not a real depth-first implementation
     * real depth-first would iterate subdirs immediately.
     * this implementation iterates breadth first, but descends into supdirs before it handles same-level directories
     * advantage of this implementation is its speed, no need for additional lists etc.
     *
     * in case you want to exclude recursion traps made possible by symbolic or hard links, you could introduce a hashset/treeset with
     * visited files (use filename strings retrieved with canonicalpath).
     * in the loop, check if the current canonical filename string is contained in the hash/treeset
     */
    static public ArrayList<File> listFiles_old(final File pDir, final boolean pIncludeDirectories, final boolean pDepthFirst) {
        final ArrayList<File> found = new ArrayList<>();
        final ArrayList<File> todo = new ArrayList<>();

        todo.add(pDir);

        while (todo.size() > 0) {
            final int removeIndex = pDepthFirst ? todo.size() - 1 : 0;
            final File currentDir = todo.remove(removeIndex);
            if (currentDir == null || !currentDir.isDirectory()) continue;

            final File[] files = currentDir.listFiles();
            for (final File file : files) {
                if (file.isDirectory()) {
                    if (pIncludeDirectories) found.add(file);
                    // additional directory filters go here
                    todo.add(file);
                } else {
                    // additional file filters go here
                    found.add(file);
                }
            }
        }

        return found;
    }

    static private void printDirs(final ArrayList<File> pFiles, final String pTitle) {
        System.out.println("====================== " + pTitle + " ======================");
        for (int i = 0; i < pFiles.size(); i++) {
            final File file = pFiles.get(i);
            System.out.println(i + "\t" + file.getAbsolutePath());
        }
        System.out.println("============================================================");
    }

    /**
     * this is the java.nio approach. this is NOT be a good solution for cases where you have to retrieve/handle files in your own code.
     * this is only useful, if the any NIO class provides support. in this case, NIO class java.nio.file.Files helps handling local files.
     * if NIO or your target system does not offer such helper methods, this way is harder to implement, as you have to set up the helper method yourself.
     */
    static public Stream<Path> listFiles_newIO(final File pDir, final boolean pIncludeDirectories) throws IOException {
        final Stream<Path> stream = Files.find(pDir.toPath(), 100,
                (path, basicFileAttributes) -> {
                    final File file = path.toFile(); // conversion to File for easier access (f.e. isDirectory()), could also use NIO methods
                    return (pIncludeDirectories || !file.isDirectory() /* additional filters go here */ );
                });
        return stream;

    }
    static private void printDirs(final Stream<Path> pStream, final String pTitle) {
        System.out.println("====================== " + pTitle + " ======================");
        pStream.forEach(System.out::println);
        System.out.println("============================================================");
    }
}

AND, one must add, java.nio.file.Files.find() might be implemented recursively. But as it's just one call, this maybe could count as 'non-recursive' too.

ALSO, as the OP stated in comments, one might use Stack or other FIFO/LIFO collections. LIFO for a mixed depth-first, FIFO for breadth-first approach.

列出文件,目录,子文件&amp; amp;的想法FTP服务器中没有递归的子目录

倾城花音 2025-02-20 01:49:07

它应该是 message.Reply({embeds:[testembed]})

{content:“”} 仅适用于常规消息,因此应该是:

client.on('messageCreate', (message) => {
const testEmbed = new DiscordJS.MessageEmbed().setTitle('Topic')
if (message.content === '%topic') {
    message.reply({
        embeds: [testEmbed]
    })
   }
})

It should be message.reply({embeds: [testEmbed]})

{content: ""} for regular messages only, so it should be:

client.on('messageCreate', (message) => {
const testEmbed = new DiscordJS.MessageEmbed().setTitle('Topic')
if (message.content === '%topic') {
    message.reply({
        embeds: [testEmbed]
    })
   }
})

消息内容必须是非空字符串消息

倾城花音 2025-02-20 01:21:08

Bootstrap在他们的CSS课程中使用!将覆盖您的自定义课程。尝试在CSS声明中添加!重要的是或尝试将其添加为内联或ID。在特异性层次结构中,ID和内联样式更高。

如果那不起作用,请尝试使用开发工具来确保您正在设计正确的元素。

Bootstrap uses !important in their css classes which will override your custom classes. Try adding !important to your css declaration or try adding it inline or as an ID. IDs and inline styles are higher in the specificity hierarchy.

If that doesn't work, try using dev tools to make sure you're styling the correct element.

ReactJS Bootstrap媒体查询CSS

倾城花音 2025-02-19 13:57:40

您可以使用定义样式属性。

格式字符串有两个等效语法:“ plain_text {{code}}” (aka jinja-style)和“ plain_text#{code {code}” (aka)红宝石风格)。

示例:
继承销售订单模板并在 H2 标签上设置保证金

<template id="report_saleorder_document_inherit" inherit_id="sale.report_saleorder_document">
    <xpath expr="//h2" position="attributes">
        <attribute name="t-attf-style">margin:{{doc.margin}}cm</attribute>
    </xpath>
</template>

You can use t-attf-$name to define the style attribute.

There are two equivalent syntaxes for format strings: "plain_text {{code}}" (aka jinja-style) and "plain_text #{code}" (aka ruby-style).

Example:
Inherit sale order template and set the margin on h2 tag

<template id="report_saleorder_document_inherit" inherit_id="sale.report_saleorder_document">
    <xpath expr="//h2" position="attributes">
        <attribute name="t-attf-style">margin:{{doc.margin}}cm</attribute>
    </xpath>
</template>

根据现场值设置odoo qweb-pdf报告中的最高值

倾城花音 2025-02-19 10:55:10

作为键入整体函数的替代方法,这很方便,因为它键入参数和返回类型,您可以单独键入这些函数并保留导出异步函数语法。

但是,参数类型没有名称,因此您需要从 handle 手动提取它。请注意,实际上只有一个参数正在破坏。例如,

// Maybe export this from elsewhere to not repeat it
type HandleParams = Parameters<Handle>[0];

export async function handle({ event, resolve }: HandleParams) : Promise<Response> {
    // ...
}

原始返回类型使用 maybepromise&lt; t&gt; 允许同步和异步返回。您只能仅使用 Promise ,如果该功能实际上是 async

还有另一种诸如参数的助手类型,它可以使您从 handle

type HandleResult = ReturnType<Handle>;

As an alternative to typing the function as a whole, which is convenient in that it types arguments and return type, you can type those separately and retain the export async function syntax.

The argument type does not have a name, though, so you need to extract it manually from Handle. Note that there actually is only one argument, which is being destructured. E.g.

// Maybe export this from elsewhere to not repeat it
type HandleParams = Parameters<Handle>[0];

export async function handle({ event, resolve }: HandleParams) : Promise<Response> {
    // ...
}

The original return type uses MaybePromise<T> to allow synchronous and async returns. You can just only use Promise if the function is actually async.

There also is another helper type like Parameters that would allow you to extract the return type generically from Handle:

type HandleResult = ReturnType<Handle>;

如何在钩子中添加TypeScript到Sveltekit句柄功能?

倾城花音 2025-02-18 19:13:21

问题

您将 myFolder 作为您在代码中未定义的函数的变量,因此提高了名称。

解决方案

只需将其替换为'myFolder' [将其传递为字符串]。

CreateCorpusFromDataFrame('myfolder',mydf)

Problem

You are passing myfolder as a variable to your function which you have not defined in your code and hence it raises a NameError.

Solution

Just replace it with 'myfolder' [pass it as a string].

CreateCorpusFromDataFrame('myfolder',mydf)

通过参数通过函数将pandas dataframe转换为语料库文件时的错误

倾城花音 2025-02-18 12:15:46

我不会出于两个原因将移动应用程序作为消费者成为消费者

  1. - 您需要在客户端
  2. 缩放性上保存信用 - 每个移动都将充当消费者,这将使主题的吞吐量随着用户数量的增长而增长,

我建议您编写一个新的组件,该组件会消耗来自Kafka的消息,并通过套接字数据发布给移动客户端。

查看socket.io,支持打字稿以及易于使用的库。

祝你好运!

I wouldn’t make the mobile app a consumer for 2 reasons

  1. Security - you will need to save creds at client side
  2. scaleability - every mobile would act as a consumer which will make the throughput of the topic to grow as the number of users grows

I would suggest you to write a new component that consumes that messages from kafka and publishes through socket data to the mobile clients.

Take a look at socket.io, supports typescript and also a easy to use library.

Good luck!

KAFKA的通知引擎发送推送通知从Android应用中的不同用户获取ID

倾城花音 2025-02-18 06:45:15

如果有人想要解决方案(怀疑),我设法在这样的中间件中检索了cookie:

callbacks: {
    authorized: ({ req }) => {
      const cookie = req.headers.get('cookie');
      const accessToken = cookie.split('accessToken=')[1].split(';')[0];
      console.log(accessToken);
      // Do your logic
      return !!accessToken
    },
  },

If anyone wants the solution (doubt it), I managed to retrieve the cookie in the middleware like this :

callbacks: {
    authorized: ({ req }) => {
      const cookie = req.headers.get('cookie');
      const accessToken = cookie.split('accessToken=')[1].split(';')[0];
      console.log(accessToken);
      // Do your logic
      return !!accessToken
    },
  },

当给予外部访问令牌时,如何绕过NextAuth

倾城花音 2025-02-17 22:51:06

如果语句,您不需要。使用 :has() 选择器可以使用此后代选择元素。

:contains()是个体敏感的,因此您需要 red 而不是 red 那里。

jQuery(document).ready(function($) {
  $('.taxonomy-list-item:has(.tax-desc:contains("Red"))').addClass("red");
});
.red {
  color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="taxonomy-list-item">
  <div class="tax-details">
    <div class="tax-name">
      <div class="tax-title">
        <a href="#">Category 1</a>
      </div>
    </div>
    <div class="tax-desc">Red</div>
  </div>
</div>
<div class="taxonomy-list-item">
  <div class="tax-details">
    <div class="tax-name">
      <div class="tax-title">
        <a href="#">Category 2</a>
      </div>
    </div>
    <div class="tax-desc">Blue</div>
  </div>
</div>

You don't need an if statement. Use the :has() selector to select the elements with this descendant.

:contains() is case-sensitive, so you need Red rather than red there.

jQuery(document).ready(function($) {
  $('.taxonomy-list-item:has(.tax-desc:contains("Red"))').addClass("red");
});
.red {
  color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="taxonomy-list-item">
  <div class="tax-details">
    <div class="tax-name">
      <div class="tax-title">
        <a href="#">Category 1</a>
      </div>
    </div>
    <div class="tax-desc">Red</div>
  </div>
</div>
<div class="taxonomy-list-item">
  <div class="tax-details">
    <div class="tax-name">
      <div class="tax-title">
        <a href="#">Category 2</a>
      </div>
    </div>
    <div class="tax-desc">Blue</div>
  </div>
</div>

根据其内容将类添加到特定元素

倾城花音 2025-02-17 14:15:35

要更改Q1,Q3等的颜色和值,您可以使用以下更新的代码。更改 myq1 myq3 和其他数组中的值以更改值。可以使用 Marker_Color 更改颜色。但是,基础数据点不可见。希望这会有所帮助。

from plotly.subplots import make_subplots
import plotly.graph_objects as go

#fig = go.Figure()
myq1=[ 2, 3, 4 ]
myq3=[ 8, 9, 10 ]
mymedian=[ 4, 5, 6 ]
mymean=[ 2.2, 2.8, 3.2 ]
mylowerfence=[ 0, 1, 2 ]
mynotchspan=[ 0.2, 0.4, 0.6 ]
mysd=[ 0.2, 0.4, 0.6 ]
mylowerfence=[ 0, 1, 2 ]
myupperfence=[9, 10, 11]


trace0 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile1", marker_color='#3D9970', q1=[myq1[0]], 
                median=[mymedian[0]], q3 = [myq3[0]], lowerfence=[mylowerfence[0]], upperfence=[myupperfence[0]], 
                mean=[mymean[0]],sd=[mysd[0]], notchspan=[mynotchspan[0]])

trace1 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile2", marker_color='#FF4136', q1=[myq1[1]], 
                median=[mymedian[1]], q3 = [myq3[1]], lowerfence=[mylowerfence[1]], upperfence=[myupperfence[1]], 
                mean=[mymean[1]],sd=[mysd[1]], notchspan=[mynotchspan[1]])

trace2 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile3", marker_color='#FF851B', q1=[myq1[2]], 
                median=[mymedian[2]], q3 = [myq3[2]], lowerfence=[mylowerfence[2]],upperfence=[myupperfence[2]], 
                mean=[mymean[2]],sd=[mysd[2]], notchspan=[mynotchspan[2]])

fig=go.Figure(data=[trace0, trace1, trace2])

fig.update_traces(orientation='v')
fig.update_layout(boxmode='group')                  
fig.show()

output

”在此处输入图像说明”

To change the colors and the values for q1, q3, etc., you can use the below updated code. Change the values in the myq1, myq3 and other array to change the values. The colors can be changed using the marker_color. The underlying data points, however are not visible. Hope this helps.

from plotly.subplots import make_subplots
import plotly.graph_objects as go

#fig = go.Figure()
myq1=[ 2, 3, 4 ]
myq3=[ 8, 9, 10 ]
mymedian=[ 4, 5, 6 ]
mymean=[ 2.2, 2.8, 3.2 ]
mylowerfence=[ 0, 1, 2 ]
mynotchspan=[ 0.2, 0.4, 0.6 ]
mysd=[ 0.2, 0.4, 0.6 ]
mylowerfence=[ 0, 1, 2 ]
myupperfence=[9, 10, 11]


trace0 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile1", marker_color='#3D9970', q1=[myq1[0]], 
                median=[mymedian[0]], q3 = [myq3[0]], lowerfence=[mylowerfence[0]], upperfence=[myupperfence[0]], 
                mean=[mymean[0]],sd=[mysd[0]], notchspan=[mynotchspan[0]])

trace1 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile2", marker_color='#FF4136', q1=[myq1[1]], 
                median=[mymedian[1]], q3 = [myq3[1]], lowerfence=[mylowerfence[1]], upperfence=[myupperfence[1]], 
                mean=[mymean[1]],sd=[mysd[1]], notchspan=[mynotchspan[1]])

trace2 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile3", marker_color='#FF851B', q1=[myq1[2]], 
                median=[mymedian[2]], q3 = [myq3[2]], lowerfence=[mylowerfence[2]],upperfence=[myupperfence[2]], 
                mean=[mymean[2]],sd=[mysd[2]], notchspan=[mynotchspan[2]])

fig=go.Figure(data=[trace0, trace1, trace2])

fig.update_traces(orientation='v')
fig.update_layout(boxmode='group')                  
fig.show()

Output

enter image description here

情节?如何在Plotly Python中同时更改晶须长度和彩色单个盒子图?

倾城花音 2025-02-17 07:29:31

我设法解决了这个问题,但我的传说分为两个部分:

fig, ax = plt.subplots()

# your code with your plots

ax.legend(['A'], fontsize=15)
ax.right_ax.legend(['B'], fontsize=15)

I managed to kind of solve the problem, but my legend is divided into two parts :

fig, ax = plt.subplots()

# your code with your plots

ax.legend(['A'], fontsize=15)
ax.right_ax.legend(['B'], fontsize=15)

当使用`secondary_y'时,如何更改pd.dataframe.plot()的传奇字体大小?

倾城花音 2025-02-17 02:36:27

如果您没有代码或与作者联系,则使用此文本,我们必须猜测错误在哪里。

我的猜测

  1. $ w_m^m $在等式中,是$ w_m^m $
  2. softmax输出实际上是计算$ u^t $,而不是$ u $
  3. eq。 9应该是$ m^t u^t $,而不是$ m u^t $

另一个假设是它们具有如所述的方程式,它们有一个工作代码,并且在编写论文时,他们计算出矩阵的维度错误。

我不知道我是否会相信将来发行日期的论文,而引用为零。


If you don't have the code or you reach the authors, with this piece of text we have to guess where the error is.

My guess

  1. $W_m^M$ in the equation, is $W_m^M$
  2. The softmax output is actually computing $u^T$, not $u$
  3. eq. 9 should be $M^T u^T$, instead of $M u^T$

Another hypothesis is that they had the equations as described, they had a working code, and when writing the paper they worked out the dimension of the matrices incorrectly.

I don't know if I would trust a paper with publication date in the future, and zero citations.

https://www.sciencedirect.com/science/article/abs/pii/S0957417422006170#!
enter image description here

注意机制中的矩阵操作

倾城花音 2025-02-17 00:25:06

有两种方法可以这样做,使用 dayjs 通过使用它,您可以处理日期并转换为许多不同的形状信息检查它们的文件)。 如果您想将日期时间与时间戳分开

/*
  other your imports and codes
*/
let timestamp = moment(item.starts_on);
let date = timestamp.format('L');
let time = timestamp.format('LT');
/*
  other your codes
*/

例如, 日期,您可以:

/*
  other your imports and codes
*/
let d = new Date(item.starts_on);
let date = `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`;
let time = `${d.getHours()}:${d.getMinutes()}`;
/*
  other your codes
*/

更新答案
对于将日期转换为“ 2022年3月19日星期六”,您想要的,以下内容以下内容:

//fill in Months array
const Months = ["Jan", "Feb", ..., "Dec"];
//fill in Days of week array
const Days = ["Sun", "Mon", ..., "Sat"];
/*
  other your codes
*/
let d = new Date(item.starts_on);
let monthIndex = d.getMonth();
let month = Months[monthIndex];
let dayIndex = d.getDay();
let day = Days[dayIndex];

let date = `${day} ${d.getDate()} ${month} ${d.getFullYear()}`;
/*
  other your codes
*/

There are two approach for doing it, first way (that is easier) using packages like moment or dayjs by using it you are be able to handle date and convert to many different shapes (for more information check the documents of them). For example if you want to separate date and time from a timestamp you can do it by moment like below:

/*
  other your imports and codes
*/
let timestamp = moment(item.starts_on);
let date = timestamp.format('L');
let time = timestamp.format('LT');
/*
  other your codes
*/

Second way is using at instance of Date, for doing it you can:

/*
  other your imports and codes
*/
let d = new Date(item.starts_on);
let date = `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`;
let time = `${d.getHours()}:${d.getMinutes()}`;
/*
  other your codes
*/

Update Answer
For converting date to like "Sat 19 Mar 2022" you want, followings below:

//fill in Months array
const Months = ["Jan", "Feb", ..., "Dec"];
//fill in Days of week array
const Days = ["Sun", "Mon", ..., "Sat"];
/*
  other your codes
*/
let d = new Date(item.starts_on);
let monthIndex = d.getMonth();
let month = Months[monthIndex];
let dayIndex = d.getDay();
let day = Days[dayIndex];

let date = `${day} ${d.getDate()} ${month} ${d.getFullYear()}`;
/*
  other your codes
*/

如何将日期,时间和日期与react Native代码中的标题分开?

倾城花音 2025-02-17 00:11:38

您可以将其用作您想做的事情的蓝图,重要的是Runspace看不到表单的控件。如果您希望您的Runspace与控件进行交互,则必须通过 sessionStateProxy.setVariable(...)或用 .addparameters(..)例如。

using namespace System.Windows.Forms
using namespace System.Drawing
using namespace System.Management.Automation.Runspaces

Add-Type -AssemblyName System.Windows.Forms

[Application]::EnableVisualStyles()

try {
    $form = [Form]@{
        StartPosition   = 'CenterScreen'
        Text            = 'Test'
        WindowState     = 'Normal'
        MaximizeBox     = $false
        ClientSize      = [Size]::new(200, 380)
        FormBorderStyle = 'Fixed3d'
    }

    $listBox = [ListBox]@{
        Name       = 'myListBox'
        Location   = [Point]::new(10, 10)
        ClientSize = [Size]::new(180, 300)
    }
    $form.Controls.Add($listBox)

    $runBtn = [Button]@{
        Location   = [Point]::new(10, $listBox.ClientSize.Height + 30)
        ClientSize = [Size]::new(90, 35)
        Text       = 'Click Me'
    }
    $runBtn.Add_Click({
        $resetBtn.Enabled = $true

        if($status['AsyncResult'].IsCompleted -eq $false) {
            # we assume it's running
            $status['Instance'].Stop()
            $this.Text = 'Continue!'
            return # end the event here
        }

        $this.Text = 'Stop!'
        $status['Instance']    = $instance
        $status['AsyncResult'] = $instance.BeginInvoke()
    })
    $form.Controls.Add($runBtn)

    $resetBtn =  [Button]@{
        Location   = [Point]::new($runBtn.ClientSize.Width + 15, $listBox.ClientSize.Height + 30)
        ClientSize = [Size]::new(90, 35)
        Text       = 'Reset'
        Enabled    = $false
    }
    $resetBtn.Add_Click({
        if($status['AsyncResult'].IsCompleted -eq $false) {
            $status['Instance'].Stop()
        }
        $runBtn.Text  = 'Start!'
        $this.Enabled = $false
        $listBox.Items.Clear()
    })
    $form.Controls.Add($resetBtn)

    $status = @{}
    $rs = [runspacefactory]::CreateRunspace([initialsessionstate]::CreateDefault2())
    $rs.ApartmentState = [Threading.ApartmentState]::STA
    $rs.ThreadOptions  = [PSThreadOptions]::ReuseThread
    $rs.Open()
    $rs.SessionStateProxy.SetVariable('controls', $form.Controls)
    $instance = [powershell]::Create().AddScript({
        $listBox = $controls.Find('myListBox', $false)[0]
        $ran  = [random]::new()

        while($true) {
            Start-Sleep 1
            $listBox.Items.Add($ran.Next())
        }
    })
    $instance.Runspace = $rs
    $form.Add_Shown({ $this.Activate() })
    $form.ShowDialog()
}
finally {
    ($form, $instance, $rs).ForEach('Dispose')
}

demo

“

You can use this as a blueprint of what you want to do, the important thing is that the runspace can't see the controls of your form. If you want your runspace to interact with the controls, they must be passed to it, either by SessionStateProxy.SetVariable(...) or as argument with .AddParameters(..) for example.

using namespace System.Windows.Forms
using namespace System.Drawing
using namespace System.Management.Automation.Runspaces

Add-Type -AssemblyName System.Windows.Forms

[Application]::EnableVisualStyles()

try {
    $form = [Form]@{
        StartPosition   = 'CenterScreen'
        Text            = 'Test'
        WindowState     = 'Normal'
        MaximizeBox     = $false
        ClientSize      = [Size]::new(200, 380)
        FormBorderStyle = 'Fixed3d'
    }

    $listBox = [ListBox]@{
        Name       = 'myListBox'
        Location   = [Point]::new(10, 10)
        ClientSize = [Size]::new(180, 300)
    }
    $form.Controls.Add($listBox)

    $runBtn = [Button]@{
        Location   = [Point]::new(10, $listBox.ClientSize.Height + 30)
        ClientSize = [Size]::new(90, 35)
        Text       = 'Click Me'
    }
    $runBtn.Add_Click({
        $resetBtn.Enabled = $true

        if($status['AsyncResult'].IsCompleted -eq $false) {
            # we assume it's running
            $status['Instance'].Stop()
            $this.Text = 'Continue!'
            return # end the event here
        }

        $this.Text = 'Stop!'
        $status['Instance']    = $instance
        $status['AsyncResult'] = $instance.BeginInvoke()
    })
    $form.Controls.Add($runBtn)

    $resetBtn =  [Button]@{
        Location   = [Point]::new($runBtn.ClientSize.Width + 15, $listBox.ClientSize.Height + 30)
        ClientSize = [Size]::new(90, 35)
        Text       = 'Reset'
        Enabled    = $false
    }
    $resetBtn.Add_Click({
        if($status['AsyncResult'].IsCompleted -eq $false) {
            $status['Instance'].Stop()
        }
        $runBtn.Text  = 'Start!'
        $this.Enabled = $false
        $listBox.Items.Clear()
    })
    $form.Controls.Add($resetBtn)

    $status = @{}
    $rs = [runspacefactory]::CreateRunspace([initialsessionstate]::CreateDefault2())
    $rs.ApartmentState = [Threading.ApartmentState]::STA
    $rs.ThreadOptions  = [PSThreadOptions]::ReuseThread
    $rs.Open()
    $rs.SessionStateProxy.SetVariable('controls', $form.Controls)
    $instance = [powershell]::Create().AddScript({
        $listBox = $controls.Find('myListBox', $false)[0]
        $ran  = [random]::new()

        while($true) {
            Start-Sleep 1
            $listBox.Items.Add($ran.Next())
        }
    })
    $instance.Runspace = $rs
    $form.Add_Shown({ $this.Activate() })
    $form.ShowDialog()
}
finally {
    ($form, $instance, $rs).ForEach('Dispose')
}

Demo

demo

powerShell中的按钮事件的runspace

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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