指尖凝香

文章 评论 浏览 30

指尖凝香 2025-02-02 03:48:17

使用getrowheight将修复它:

  <DataGrid
    rows={rows}
    columns={columns}
    getRowHeight={() => 'auto'}
    sx={{
      [`& .${gridClasses.cell}`]: {
        py: 1,
      },
    }}
  />

use getRowHeight will fix it:

  <DataGrid
    rows={rows}
    columns={columns}
    getRowHeight={() => 'auto'}
    sx={{
      [`& .${gridClasses.cell}`]: {
        py: 1,
      },
    }}
  />

REECT MUI DATAGRID-插入线路断开时,当行中的文本命中最大宽度

指尖凝香 2025-02-01 10:33:32

添加到 @captain-yossarian的答案中并解决对OP的评论,我们可以制作自己的实用程序类型,只需要几个特定的​​键:

type Project = {
  title: string
}

interface Entry {
  id: number
  project?: Project
}

type SomeAreRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;

type WithProject = SomeAreRequired<Entry, "project">;

declare const entries: Entry[]

entries
  .filter((entry): entry is WithProject => !!entry.project)
  .map(entry => ({
    title: entry.project.title
  }))

somearerequired pickst 并使它们需要它们,然后将其添加到t的情况下,并省略了k键,有效地仅制作所需的选定键。

Playground

Adding onto @captain-yossarian's answer and addressing OP's comment on it, we can make our own utility type to require only a few specific keys:

type Project = {
  title: string
}

interface Entry {
  id: number
  project?: Project
}

type SomeAreRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;

type WithProject = SomeAreRequired<Entry, "project">;

declare const entries: Entry[]

entries
  .filter((entry): entry is WithProject => !!entry.project)
  .map(entry => ({
    title: entry.project.title
  }))

SomeAreRequired picks all keys in T and makes them required, then adds it to T with the K keys omitted, effectively making only the selected keys required.

Playground

打字稿不理解对象数组中未定义值的过滤器

指尖凝香 2025-02-01 04:52:28

这里有许多问题。您似乎在交互方式运行SPUFI,必须将其更改为批处理执行,否则您将每次使用SPUFI出于不同的目的使用SPUFI时覆盖您的用户IDERID.RESULTS数据集。 IBM DB2文档中记录了DSNTEP2和DSNTEP4,建议其输出限制为宽度133个字节。这看起来对您的情况有效,但不一定在一般情况下。

这样做之后,您有许多的选项用于重新格式化结果,商店的排序实用程序,尴尬,sed,自定义代码,您在rexx,java,pl/i,pl/i,cobol,cbol,c,c,c,c,c,python,python ,等等。选择其中之一取决于许多因素,包括当前在商店中安装了哪些产品和语言,您自己的技能,从DB2返回的结果集的大小,目前正在从您的产品和/或语言中逐步逐步逐步淘汰。购物,等等。

如果要使用自定义代码路由,则可能需要用该语言(如果受支持)对您的选择语句进行编码,并在一个程序中进行数据检索并重新格式化。

如果您的商店拥有该产品,则可以更好地解决问题的方法是使用Syncsort。 Syncsort有能力针对DB2执行选择语句,然后处理结果,并根据需要进行重新格式化。请记住,尽管有能力,但您的商店可能选择不使用它。

通常,通过询问同龄人和支持员工通常如何在您的商店中应对这种类型的挑战,您会得到很好的服务。商店标准存在许多原因,遵循它们符合您的最大利益。

There are a number of issues here. You appear to be running SPUFI interactively, you'd have to change that to a batch execution otherwise you'll be overwriting your userid.RESULTS dataset every time you use SPUFI for a different purpose. DSNTEP2 and DSNTEP4 are documented in the IBM DB2 documentation, be advised their output is limited to 133 bytes in width. This looks like it will work for your situation, but not necessarily in the general case.

After doing that, you have many options for reformatting your results, your shop's SORT utility, awk, sed, custom code you write yourself in Rexx, Java, PL/I, COBOL, C, C++, Python, and so forth. Choosing one of these is dependent on a number of factors including what products and languages are currently installed in your shop, your own skill set, size of the result set returned from DB2, which products and/or languages are currently being phased out of your shop, and so forth.

If you're going to go the custom code route, you might want to code your SELECT statement in that language (if it's supported) and do your data retrieval and reformatting all in one program.

Perhaps a better solution to your problem is to use Syncsort, if your shop has that product. Syncsort has the ability to execute a SELECT statement against DB2 and then process the result, reformatting as necessary. Bear in mind that while the ability is there, your shop may have elected not to use it.

As is often the case, you are well served by asking your peers and support staff how this type of challenge is normally met in your shop. Shop standards exist for many reasons, following them is in your best interest.

使用JCL格式化捕获的SPUFI结果

指尖凝香 2025-02-01 03:11:07

您可以使用livedata构建器将流的值收集到mutablelist中。

在这里,我使用TOLIST()在发射它之前复制Mutablelist,因为RecyClerview适配器在可变数据源方面效果不佳。

val scanResults: LiveData<List<BleScanResult>> = liveData {
    val cumulativeResults = mutableListOf<BleScanResult>()

    scanEnabled.flatMapLatest { doScan ->
        if (doScan) {
            repository.bluetoothScan().map { BleScanResult(it.device.name, it.device.address) }
        } else {
            emptyFlow()
        }
    }.collect {
        cumulativeResults += it
        emit(cumulativeResults.toList())
    }
}

如果要避免重复条目并重新排序条目,则可以使用这样的集合:

val scanResults: LiveData<List<BleScanResult>> = liveData {
    val cumulativeResults = mutableSetOf<BleScanResult>()

    scanEnabled.flatMapLatest { doScan ->
        if (doScan) {
            repository.bluetoothScan().map { BleScanResult(it.device.name, it.device.address) }
        } else {
            emptyFlow()
        }
    }.collect {
        if (it !in cumulativeResults) {
            cumulativeResults += it
            emit(cumulativeResults.toList())
        }
    }
}

You could use the liveData builder to collect the Flow's values into a MutableList.

Here I copy the MutableList using toList() before emitting it since RecyclerView Adapters don't play well with mutable data sources.

val scanResults: LiveData<List<BleScanResult>> = liveData {
    val cumulativeResults = mutableListOf<BleScanResult>()

    scanEnabled.flatMapLatest { doScan ->
        if (doScan) {
            repository.bluetoothScan().map { BleScanResult(it.device.name, it.device.address) }
        } else {
            emptyFlow()
        }
    }.collect {
        cumulativeResults += it
        emit(cumulativeResults.toList())
    }
}

If you want to avoid duplicate entries and reordering of entries, you can use a set like this:

val scanResults: LiveData<List<BleScanResult>> = liveData {
    val cumulativeResults = mutableSetOf<BleScanResult>()

    scanEnabled.flatMapLatest { doScan ->
        if (doScan) {
            repository.bluetoothScan().map { BleScanResult(it.device.name, it.device.address) }
        } else {
            emptyFlow()
        }
    }.collect {
        if (it !in cumulativeResults) {
            cumulativeResults += it
            emit(cumulativeResults.toList())
        }
    }
}

如何从扫描的BLE结果中创建列表

指尖凝香 2025-02-01 00:15:52

如果由于某种原因您无法使用:

find . -print0 2>/dev/null | xargs -0 ...

这是做同样事情的POSIX方法:

find . -exec sh -c '"$0" "$@" 2>&3' ... {} + 3>&2 2>/dev/null

注意: 3&gt;&gt;&gt; 2位于 2&gt;/dev/null

If for some reason you can't use:

find . -print0 2>/dev/null | xargs -0 ...

Then here's a POSIX way to do the same thing:

find . -exec sh -c '"$0" "$@" 2>&3' ... {} + 3>&2 2>/dev/null

note: 3>&2 is located before 2>/dev/null

查找-Exec-仅抑制错误以供查找,但不能用于执行命令

指尖凝香 2025-01-31 20:12:14

您可以使用groupby代替value_counts

df.groupby(['group', 'item']).filter(lambda g: len(g)>1).index

variant:

mask = df.groupby(['group', 'item'])['val'].transform('size').gt(1)
df.index[mask]

output:

Int64Index([0, 1, 4], dtype='int64')

nb。添加.to_list()获取列表

You can use groupby in place of value_counts:

df.groupby(['group', 'item']).filter(lambda g: len(g)>1).index

variant:

mask = df.groupby(['group', 'item'])['val'].transform('size').gt(1)
df.index[mask]

output:

Int64Index([0, 1, 4], dtype='int64')

NB. add .to_list() to get a list

熊猫:获取该匹配组的索引行

指尖凝香 2025-01-31 19:40:08

您可以使用OnChange事件侦听器到两个输入标签来检测更改,然后调用一个函数,该函数使用setAttribute添加属性添加到一个无线电输入并删除属性使用REMOVEATTRIBUTE从其他收音机中。

you can use onchange event listener to both of the input tags to detect change, then call a function that adds an attribute to one of the radio inputs using setAttribute and remove an attribute from other radio using removeAttribute.

当我单击单击按钮时,检查的属性不会更改

指尖凝香 2025-01-31 11:14:08

我也面临同样的问题。我刚刚从javalanguageversion.of(17)更改了build.gradle。

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(22)
    }
}

我正在使用java 22

I was also facing same issue. I just changed the build.gradle from JavaLanguageVersion.of(17)

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(22)
    }
}

I am using java 22

无法计算任务的值&#x27;:CompileJava&#x27;属性&#x27; javacompiler&#x27;

指尖凝香 2025-01-31 06:03:50
function hasDuplicateString(strings: string[]): boolean {
    const table: { [key: string]: boolean} = {}
    for (let string of strings) {
        if (string in table) return true;
        table[string] = true;
    }
    return false
}


在这里,运算符中的通常被认为是0(1)时间查找,因为它是哈希表格查找。

function hasDuplicateString(strings: string[]): boolean {
    const table: { [key: string]: boolean} = {}
    for (let string of strings) {
        if (string in table) return true;
        table[string] = true;
    }
    return false
}


Here the in operator is generally considered to be an 0(1) time lookup, since it's a hash table lookup.

在JavaScript数组中检查重复的字符串

指尖凝香 2025-01-31 04:53:45

好的,错误似乎在我这一边。我只是看一下Slack Block套件构建器中的动作有效载荷预览。在实际发布消息时,我会看到响应中所有元素的状态。

OK, error seems to be on my side. I was just looking at the action payload preview in the Slack Block Kit Builder. When actually posting a message I see the state of all elements in the response.

Slack API:如何获得所有输入/动作元素的状态

指尖凝香 2025-01-31 01:33:58

对于那些在组成 type-safety 的人:
在一致性数据类/数据对象上检查

目的地,不是对象

@Serializable
data class EnterPin(val verificationGoal: VerificationGoal)
  • 检查 startDestination
  • 检查 popupto()函数
  • 检查 navigate()函数,

以防万一您尝试以对象的身份传递目标 - 您将会崩溃:

popUpTo(EnterPin) {
   inclusive = true
}

正确的方法是:

popUpTo<EnterPin> {
   inclusive = true
}

For those who are using type-safety in compose-navigation:
check your destinations on consistency data class/data object

For example, you have a destination which is class, not the object

@Serializable
data class EnterPin(val verificationGoal: VerificationGoal)
  • check startDestination
  • check popUpTo() functions
  • check navigate() functions

In case you try to pass the destination as an object - you will get such crash:

popUpTo(EnterPin) {
   inclusive = true
}

The right way is:

popUpTo<EnterPin> {
   inclusive = true
}

类的序列化器&#x27; ...&#x27;找不到。将类标记为@serializable或明确提供序列化器

指尖凝香 2025-01-30 15:46:32

尝试以下操作:

for ($col=$minimum; $col <= $maximum; $col+=5) {
echo "<tr>";
echo "<td>" .$col. "</td>";
echo "<td>" .$col*$costOne. "</td>";
echo "<td>" .$col*$costTwo. "</td>";
echo "<td>" .$col*$costThree. "</td>";
echo "<td>" .$col*$costFour. "</td>";
echo "<td>" .$col*$costFive. "</td>";
echo "</tr>";
}

Try this:

for ($col=$minimum; $col <= $maximum; $col+=5) {
echo "<tr>";
echo "<td>" .$col. "</td>";
echo "<td>" .$col*$costOne. "</td>";
echo "<td>" .$col*$costTwo. "</td>";
echo "<td>" .$col*$costThree. "</td>";
echo "<td>" .$col*$costFour. "</td>";
echo "<td>" .$col*$costFive. "</td>";
echo "</tr>";
}

如何在此中乘以PHP变量以进行循环

指尖凝香 2025-01-30 13:02:34

如果您不是在您的代码中使用jQuery,则此答案是为您的,

您的代码应该与此相似:

function foo() {
    var httpRequest = new XMLHttpRequest();
    httpRequest.open('GET', "/echo/json");
    httpRequest.send();
    return httpRequest.responseText;
}

var result = foo(); // Always ends up being 'undefined'

felix kling做得很好为使用jquery for ajax的人们写答案,但是我我已经决定为没有的人提供替代方案。

注意,对于使用新的fetch> fetch api api,Angular或Promise的人,我在下面添加了另一个答案)


您面临的内容

是其他答案中“解释问题的解释”的简短摘要,如果您不确定阅读本文后,请阅读此内容。

Ajax中的 a 代表异步。这意味着发送请求(或更确切地说是接收响应)是从正常执行流中取出的。在您的示例中, 立即返回,下一个语句,返回结果;,在您传递的功能以success呼叫之前,都将执行。

这意味着当您返回时,您定义的侦听器尚未执行,这意味着您返回的值尚未定义。

这是一个简单的类比:

function getFive(){
    var a;
    setTimeout(function(){
         a=5;
    },10);
    return a;
}

(fiddle)

a返回的值是未定义的因为a = 5零件尚未执行。 Ajax的作用是这样,您在服务器有机会告诉您的浏览器该值是什么之前返回值。

解决此问题的一种可能解决方案是代码 ,告诉您的程序完成计算后该怎么办。

function onComplete(a){ // When the code completes, do this
    alert(a);
}

function getFive(whenDone){
    var a;
    setTimeout(function(){
         a=5;
         whenDone(a);
    },10);
}

这称为 cps 。基本上,我们正在传递getfive完成完成后执行的操作,我们告诉代码事件完成时如何反应(例如我们的Ajax调用,或在这种情况下为超时)。

用法将是:

getFive(onComplete);

它应在屏幕上提醒“ 5”。 (fiddle)

可能的解决方案

基本上有两种解决方法的方法:

  1. 使Ajax调用同步(我们称其为sjax)。
  2. 重组您的代码以正式使用回调。

1。同步Ajax-不要做!!

至于同步的Ajax,不要做!总而言之,它将冻结用户的浏览器,直到服务器返回响应并创建非常糟糕的用户体验。这是MDN的另一个简短摘要:

xmlhttprequest支持同步和异步通信。但是,总的来说,出于绩效原因,异步请求应优选同步请求。

简而言之

如果您要这样做,则可以传递标志。

var request = new XMLHttpRequest();
request.open('GET', 'yourURL', false);  // `false` makes the request synchronous
request.send(null);

if (request.status === 200) {// That's HTTP for 'ok'
  console.log(request.responseText);
}

https://develover.mozilla.org/en-us/docs/web/web/pai/xmlhttprequest/synchronous_and_ashronous_ashronous_requests#synchronous_requests#synchonchronous_request_request_request 您的功能接受回调。在示例代码foo中可以接受回调。当foo完成时,我们将告诉我们的代码如何 react

因此:

var result = foo();
// Code that depends on `result` goes here

变为:

foo(function(result) {
    // Code that depends on `result`
});

在这里我们传递了一个匿名函数,但是我们可以很容易地传递对现有功能的引用,使其看起来像:

function myHandler(result) {
    // Code that depends on `result`
}
foo(myHandler);

有关如何完成此类回调设计的更多详细信息,请检查Felix的答案。

现在,让我们定义foo本身以相应地行动

function foo(callback) {
    var httpRequest = new XMLHttpRequest();
    httpRequest.onload = function(){ // When the request is loaded
       callback(httpRequest.responseText);// We're calling our method
    };
    httpRequest.open('GET', "/echo/json");
    httpRequest.send();
}

(小提琴)

我们现在已经使我们的 foo 功能接受AJAX成功完成时运行的操作。我们可以通过检查响应状态是否不是200并相应地行动(创建失败处理程序等),以进一步扩展这一点。实际上,它正在解决我们的问题。

如果您仍然很难理解这一点,阅读AJAX启动启动指南< /a>在MDN。

If you're not using jQuery in your code, this answer is for you

Your code should be something along the lines of this:

function foo() {
    var httpRequest = new XMLHttpRequest();
    httpRequest.open('GET', "/echo/json");
    httpRequest.send();
    return httpRequest.responseText;
}

var result = foo(); // Always ends up being 'undefined'

Felix Kling did a fine job writing an answer for people using jQuery for AJAX, but I've decided to provide an alternative for people who aren't.

(Note, for those using the new fetch API, Angular or promises I've added another answer below)


What you're facing

This is a short summary of "Explanation of the problem" from the other answer, if you're not sure after reading this, read that.

The A in AJAX stands for asynchronous. That means sending the request (or rather receiving the response) is taken out of the normal execution flow. In your example, .send returns immediately and the next statement, return result;, is executed before the function you passed as success callback was even called.

This means when you're returning, the listener you've defined did not execute yet, which means the value you're returning has not been defined.

Here is a simple analogy:

function getFive(){
    var a;
    setTimeout(function(){
         a=5;
    },10);
    return a;
}

(Fiddle)

The value of a returned is undefined since the a=5 part has not executed yet. AJAX acts like this, you're returning the value before the server got the chance to tell your browser what that value is.

One possible solution to this problem is to code re-actively , telling your program what to do when the calculation completed.

function onComplete(a){ // When the code completes, do this
    alert(a);
}

function getFive(whenDone){
    var a;
    setTimeout(function(){
         a=5;
         whenDone(a);
    },10);
}

This is called CPS. Basically, we're passing getFive an action to perform when it completes, we're telling our code how to react when an event completes (like our AJAX call, or in this case the timeout).

Usage would be:

getFive(onComplete);

Which should alert "5" to the screen. (Fiddle).

Possible solutions

There are basically two ways how to solve this:

  1. Make the AJAX call synchronous (let’s call it SJAX).
  2. Restructure your code to work properly with callbacks.

1. Synchronous AJAX - Don't do it!!

As for synchronous AJAX, don't do it! Felix's answer raises some compelling arguments about why it's a bad idea. To sum it up, it'll freeze the user's browser until the server returns the response and create a very bad user experience. Here is another short summary taken from MDN on why:

XMLHttpRequest supports both synchronous and asynchronous communications. In general, however, asynchronous requests should be preferred to synchronous requests for performance reasons.

In short, synchronous requests block the execution of code... ...this can cause serious issues...

If you have to do it, you can pass a flag. Here is how:

var request = new XMLHttpRequest();
request.open('GET', 'yourURL', false);  // `false` makes the request synchronous
request.send(null);

if (request.status === 200) {// That's HTTP for 'ok'
  console.log(request.responseText);
}

2. Restructure code

Let your function accept a callback. In the example code foo can be made to accept a callback. We'll be telling our code how to react when foo completes.

So:

var result = foo();
// Code that depends on `result` goes here

Becomes:

foo(function(result) {
    // Code that depends on `result`
});

Here we passed an anonymous function, but we could just as easily pass a reference to an existing function, making it look like:

function myHandler(result) {
    // Code that depends on `result`
}
foo(myHandler);

For more details on how this sort of callback design is done, check Felix's answer.

Now, let's define foo itself to act accordingly

function foo(callback) {
    var httpRequest = new XMLHttpRequest();
    httpRequest.onload = function(){ // When the request is loaded
       callback(httpRequest.responseText);// We're calling our method
    };
    httpRequest.open('GET', "/echo/json");
    httpRequest.send();
}

(fiddle)

We have now made our foo function accept an action to run when the AJAX completes successfully. We can extend this further by checking if the response status is not 200 and acting accordingly (create a fail handler and such). Effectively it is solving our issue.

If you're still having a hard time understanding this, read the AJAX getting started guide at MDN.

如何从异步电话中返回响应?

指尖凝香 2025-01-29 17:21:57

使用:

=ARRAYFORMULA(SUMIF(A2:A22, F2:F22, D2:D22))

用于删除零的使用:

=ARRAYFORMULA(IFERROR(1/(1/(SUMIF(A2:A22, F2:F22, D2:D22))))

与标头:

={"Score"; ARRAYFORMULA(IFERROR(1/(1/(SUMIF(A2:A22, F2:F22, D2:D22))))}

use:

=ARRAYFORMULA(SUMIF(A2:A22, F2:F22, D2:D22))

for removing zeros use:

=ARRAYFORMULA(IFERROR(1/(1/(SUMIF(A2:A22, F2:F22, D2:D22))))

with header:

={"Score"; ARRAYFORMULA(IFERROR(1/(1/(SUMIF(A2:A22, F2:F22, D2:D22))))}

arrayformula&#x2b; SUMIF到自动填充 /扩展结果

指尖凝香 2025-01-29 16:33:11

在笔记本中:file =&gt;下载为=&gt; PDF ...

您可以在Google驱动器中导入文件,然后使用Google Colab打开它:file =&gt; print =&gt;将其保存为PDF。

in notebook : file => Download as => PDF ...

or

you can import your file in google drive, and open it with google colab then : file => print => save it as a pdf.

Jupyter笔记本将多个图另存为一个PDF

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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