与他有关

文章 评论 浏览 28

与他有关 2025-02-20 23:17:58

REMINDER_TYPE Regexp_replace 的结果,该导致类型 varchar(101)

突然间,当我将列明确地施放到 varchar

regexp_replace(remin_type,'< regex>',','')时,它可以起作用

。 remin_type,'< regex>'''):: varchar as REMINDER_TYPE 正常工作

The column reminder_type was a result of REGEXP_REPLACE that resulted in type VARCHAR(101).

Suddenly it worked when I explicitly cast the column to VARCHAR

REGEXP_REPLACE(remin_type, '<regex>', '') AS reminder_type doesn't work

REGEXP_REPLACE(remin_type, '<regex>', '')::VARCHAR AS reminder_type works perfectly

RedShift-不支持的枢轴列类型:文本

与他有关 2025-02-20 22:56:26

这对我来说很好。您可以在此处查看代码在这里

如果 bg 类都适用于任何自定义颜色,则它也应与 Red-700 一起使用。否则您可以检查是否有错字。

您还可以添加 likr此!bg-red-700 使此类重要。

最后尝试重新启动服务器,

It is working fine for me. YOu can see here for the code here .

If the bg class is working for any custom color, then it should also work with red-700. Else you can check if there's any typo.

You can also add ! likr this !bg-red-700 to make this class important.

Lastly try to restart the server,

django -tailwindcss赢得了一些属性

与他有关 2025-02-20 18:15:01

该组件仅从传递的路径中提取标签,因此它不会对属性的任何更改做出反应。您必须声明任何应通过 $ 进行反应性更新为反应的变量:

export let paths;

$: labels = paths ? paths.map((value) => value.label) : [];

The component pulls labels from the passed paths only once, so it will not react to any changes to the property. You have to declare any variables that should update as reactive via $:

export let paths;

$: labels = paths ? paths.map((value) => value.label) : [];

Svelte:自我标签不能正确地恢复

与他有关 2025-02-20 07:57:50

理解CDKDROPLIST的最佳方法是忘记CDKDROPLIST。我们需要简单地思考对象的两个数组

CDKDROPLIST只是一个接口,即更改数组元素的位置或将数组的一个元素移至另一个元素。我们可以想象两个简单的输入和三个按钮,第一个按钮互换一个数组中一个元素的位置,另一个按钮在另一个阵列中以及最后一个按钮互换两个阵列的元素

函数moveiteminArray和TransferararayItem只是JavaScript函数。我们可以看到定义 a>我们可以使用是否使用(*)

发出事件的$事件(CDKDroplistDropped)是 cdkdragdrop ,所以我们有

  1. 容器,cdkdroplist,cdkdroplist 强>掉落 - 所以我们有
    event.container.data我们在[数据]或
    CDKDROPLIST
  2. 先前查看器,关于CKDDROPLIST 的同上,我们从开始drag
  3. currentIndex,该元素的索引(位置)在数组中
    event.container.data 其中 droped
  4. 先前索引,元素的索引(位置)
    event.previouscontainer.data

so so,您的CDKDROPLIST的数据应为colorways.colorways和imgsource.colorways.colorways.colorways @sameer所说,您需要初始化OBJ imgsource

注意:在.html中使用.html,

<pre>
{{cdkDropTarget.data|json}}
</pre>

以查看“存储” CDKDROPLIST“目标”阵列, ”

(*)例如在要在一个数组中添加元素,在此另一个 cdkdroplist to cdkdroplist to cdkdroplist to cdkdroplist to cdkdroplist “数据”是一个对象的CDKDROPLIST

The best way to understand the cdkDropList is forget the cdkDropList. We need think simply in two arrays of object

The cdkDropList is only an interface to change the position of the elements of the arrays or to move one element of the array to the another one. We can imagine two simple inputs and three buttons, the first buttons interchange the position of one element in one array and in the another one and the last button interchange the elements of the two arrays

The functions moveItemInArray and transferArrayItem are only javascript function. We can see the definition this and we can use or not (*)

The $event that emit an event (cdkDropListDropped) is type of CdkDragDrop, so we have

  1. container, the cdkDropList where is dropped -so we have in the
    event.container.data the array we indicate in [data] or the
    cdkDropList
  2. previousContainer, idem about the ckdDropList from we start drag
  3. currentIndex, the index (position) of the element in array
    event.container.data where is dropped
  4. previousIndex, the index (position) of the element in array of
    event.previousContainer.data

So, the data of your cdkDropList should be colorways.colorways and imgSource.colorways as @Sameer says and you need initialize your obj imgSource

NOTE: use in .html

<pre>
{{cdkDropTarget.data|json}}
</pre>

To see the array that "store" the cdkDropList "target"

(*) e.g. in this stackblitz I used the a cdkDropList only to add elements to one array, in this another one drop elements in a CdkDropList to a group of cdkDropList who "data" is an object

卡住超过2小时的角CDK拖动 - 无法将项目放在位置

与他有关 2025-02-20 05:33:22

1-不要将任何内容放在&lt; head&gt; 标签中,而不是&lt; tltle&gt; &amp; &lt; link&gt; 主要问题
2- &lt; div class =“ header”&gt; 很旧,应该被您拒绝。使用&lt; header&gt;
3- &lt; a&gt; 标签是一个链接。为什么要将&lt; nav&gt; 放入链接中?它将您的整个导航视为一个链接... Major 问题
4-在CSS中,为什么您的标头宽度固定?它应该一直是 100%
5-您的MainNAV CS必须修复...
6-而不是使用左:450px; 使用 text-align:中心

您的最终代码看起来像这样:

.header {
    background-color: aqua;
    width: 100%; /*100% width all the time no matter what the screen is*/
}
.mainnav ul {
    position: relative;
    text-align: center; /*Never use left, right, top, bottom in position!!!*/
    font-size: 20px;
    list-style: none;
    color: gray;
    text-transform: uppercase;
}

.mainnav ul li {
  padding-right: 10px; /*sets a little space between the <li> to the right*/
  color: gray;
  text-decoration: none;
  display: inline-table;
}

.mainnav ul a {
    color: gray;
    text-decoration: none;
}

.mainnav ul a:hover {
    color: black;
}
<!DOCTYPE html>
<html>
    <head>
        <title>Hyard - 2022 Based Programming group</title>
        <link rel="stylesheet" href="index.css">
    </head>
    <body>
      <header class="header">
        <img src="images/logo.png" alt="head-logo" height="200" width="200" />
        <nav class="mainnav">
            <ul>
              <li><a href="projects/selector.html">Projects</a></li>
               <li><a href="en/about.html">About</a></li>
               <li><a href="en/versions.html">Versions</a></li>
            </ul>
            </nav>
      </header>
    </body>
</html>

1- Don't put anything in the <head> tag except <tltle> & <link>. Major problem
2- <div class="header"> is very old and should be banned from you mind. use <header> instead.
3- <a> tag is a link. Why are you putting the <nav> inside a link? it counts your entire nav as one link...Major problem
4- in CSS, why is your header width fixed? it should be 100% all the time.
5- your mainnav CSS must be fixed...
6- instead of using left: 450px; use text-align: center

Your final code will look like this:

.header {
    background-color: aqua;
    width: 100%; /*100% width all the time no matter what the screen is*/
}
.mainnav ul {
    position: relative;
    text-align: center; /*Never use left, right, top, bottom in position!!!*/
    font-size: 20px;
    list-style: none;
    color: gray;
    text-transform: uppercase;
}

.mainnav ul li {
  padding-right: 10px; /*sets a little space between the <li> to the right*/
  color: gray;
  text-decoration: none;
  display: inline-table;
}

.mainnav ul a {
    color: gray;
    text-decoration: none;
}

.mainnav ul a:hover {
    color: black;
}
<!DOCTYPE html>
<html>
    <head>
        <title>Hyard - 2022 Based Programming group</title>
        <link rel="stylesheet" href="index.css">
    </head>
    <body>
      <header class="header">
        <img src="images/logo.png" alt="head-logo" height="200" width="200" />
        <nav class="mainnav">
            <ul>
              <li><a href="projects/selector.html">Projects</a></li>
               <li><a href="en/about.html">About</a></li>
               <li><a href="en/versions.html">Versions</a></li>
            </ul>
            </nav>
      </header>
    </body>
</html>

我的网页的宽度扩展了。有什么方法可以使它变得更小?

与他有关 2025-02-20 00:07:17

您可以使用路径模块检查大小

以具有更大的想法此处

os.path.getSize()方法用于检查指定路径的大小。它返回字节中指定路径的大小。如果文件不存在或以某种方式无法访问,该方法会增加Oserror。

import os
def write(filename,text):
    if os.path.size(filename) <= 50*100_000: # is bigger or equal to 50 Million
        return False
    with open(filename) as file:
        file.write(text)
    return True

you can use the path module to check the size

to have a bigger idea here

os.path.getsize() method in Python is used to check the size of specified path. It returns the size of specified path in bytes. The method raise OSError if the file does not exist or is somehow inaccessible.

import os
def write(filename,text):
    if os.path.size(filename) <= 50*100_000: # is bigger or equal to 50 Million
        return False
    with open(filename) as file:
        file.write(text)
    return True

达到一定大小后,如何开始覆盖文件?

与他有关 2025-02-19 07:10:56

标记匹配为功能
https://codesandbox.io/s/pgenty-diffie -nwwxe?file =/src/app.js

import React from "react";

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      res: "Lorem ipsum dolor"
    };
    this.markMatches = this.markMatches.bind(this);
  }
  markMatches(ev) {
    let res = "Lorem ipsum dolor";
    const req = ev.target.value;
    if (req) {
      const normReq = req
        .toLowerCase()
        .replace(/\s+/g, " ")
        .trim()
        .split(" ")
        .sort((a, b) => b.length - a.length);
      res = res.replace(
        new RegExp(`(${normReq.join("|")})`, "gi"),
        match => "<mark>" + match + "</mark>"
      );
    }
    this.setState({
      res: res
    });
  }

  render() {
    return (
      <div className="App">
        <input type="text" onChange={this.markMatches} />
        <br />
        <p dangerouslySetInnerHTML={{ __html: this.state.res }} />
      </div>
    );
  }
}

export default App;

Mark matches as a function
https://codesandbox.io/s/pensive-diffie-nwwxe?file=/src/App.js

import React from "react";

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      res: "Lorem ipsum dolor"
    };
    this.markMatches = this.markMatches.bind(this);
  }
  markMatches(ev) {
    let res = "Lorem ipsum dolor";
    const req = ev.target.value;
    if (req) {
      const normReq = req
        .toLowerCase()
        .replace(/\s+/g, " ")
        .trim()
        .split(" ")
        .sort((a, b) => b.length - a.length);
      res = res.replace(
        new RegExp(`(${normReq.join("|")})`, "gi"),
        match => "<mark>" + match + "</mark>"
      );
    }
    this.setState({
      res: res
    });
  }

  render() {
    return (
      <div className="App">
        <input type="text" onChange={this.markMatches} />
        <br />
        <p dangerouslySetInnerHTML={{ __html: this.state.res }} />
      </div>
    );
  }
}

export default App;

使用ReactJ突出显示文本

与他有关 2025-02-19 04:25:17

你能尝试吗

{ path: '**', pathMatch: 'full', component: PageNotFoundComponent },

Can you try with

{ path: '**', pathMatch: 'full', component: PageNotFoundComponent },

我使用Angular路由器,可以使用路径:&#x27; **&#x27;对于404页

与他有关 2025-02-18 21:30:55

最后,我决定在测试项目中使用以下设置:

<Nullable>annotations</Nullable>

因为如上所述在此,它将禁用null-reference警告,但它还允许我使用 t?在测试。由于我有假的值将其传递给我故意分配零值的方法,因此我想自由地将它们声明为 t?

IEnumerable<Foo>? collection = null;
a.DoSomething(collection); 

我决定不使用注释,因为它不使用注释请允许我将变量声明为 t?

Finally, I decided to use the following setting in the tests projects:

<Nullable>annotations</Nullable>

Because as described here, it will disable null-reference warnings, but it will also allow me to use the T? type in the tests. Since I have fake values which I pass to the methods to which I on purpose assign the null value, I want to have the freedom to declare them as T?

IEnumerable<Foo>? collection = null;
a.DoSomething(collection); 

I decided not to use annotations because it does not allow me to declare variables as T?.

是否有必要在单位测试中启用无效上下文?

与他有关 2025-02-18 11:16:13

使用Tidyr,有 pivot_wider() pivot_longer(),可以从长 - &gt;宽或宽 - &gt;分别长。使用OP的数据:

单列长 - &gt;

library(tidyr)

dat1 %>% 
    pivot_wider(names_from = numbers, values_from = value)

# # A tibble: 2 x 5
#   name          `1`    `2`    `3`    `4`
#   <fct>       <dbl>  <dbl>  <dbl>  <dbl>
# 1 firstName   0.341 -0.703 -0.380 -0.746
# 2 secondName -0.898 -0.335 -0.501 -0.175

多列长 - &gt; wide

pivot_wider()也能够进行更复杂的枢轴操作。例如,您可以同时旋转多个列:

# create another column for showing the functionality
dat2 <- dat1 %>% 
    dplyr::rename(valA = value) %>%
    dplyr::mutate(valB = valA * 2) 

dat2 %>% 
    pivot_wider(names_from = numbers, values_from = c(valA, valB))

# # A tibble: 2 × 9
#   name       valA_1 valA_2 valA_3 valA_4 valB_1 valB_2 valB_3 valB_4
#   <chr>       <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
#  1 firstName   0.341 -0.703 -0.380 -0.746  0.682 -1.41  -0.759 -1.49 
#  2 secondName -0.898 -0.335 -0.501 -0.175 -1.80  -0.670 -1.00  -0.349

With tidyr, there is pivot_wider() and pivot_longer() which are generalized to do reshaping from long -> wide or wide -> long, respectively. Using the OP's data:

single column long -> wide

library(tidyr)

dat1 %>% 
    pivot_wider(names_from = numbers, values_from = value)

# # A tibble: 2 x 5
#   name          `1`    `2`    `3`    `4`
#   <fct>       <dbl>  <dbl>  <dbl>  <dbl>
# 1 firstName   0.341 -0.703 -0.380 -0.746
# 2 secondName -0.898 -0.335 -0.501 -0.175

multiple columns long -> wide

pivot_wider() is also capable of more complex pivot operations. For example, you can pivot multiple columns simultaneously:

# create another column for showing the functionality
dat2 <- dat1 %>% 
    dplyr::rename(valA = value) %>%
    dplyr::mutate(valB = valA * 2) 

dat2 %>% 
    pivot_wider(names_from = numbers, values_from = c(valA, valB))

# # A tibble: 2 × 9
#   name       valA_1 valA_2 valA_3 valA_4 valB_1 valB_2 valB_3 valB_4
#   <chr>       <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
#  1 firstName   0.341 -0.703 -0.380 -0.746  0.682 -1.41  -0.759 -1.49 
#  2 secondName -0.898 -0.335 -0.501 -0.175 -1.80  -0.670 -1.00  -0.349

There is much more functionality to be found in the docs.

如何将数据重新设计为长格式

与他有关 2025-02-18 08:52:49

有趣的是,此页面上没有一个答案提及两个边缘情况:

边缘案例#1:同时访问

.NET中对字典通用词典的访问不是线程安全,并且它们有时可能会抛出 nullReference ,甚至(更频繁的) keynotfoundException 尝试从两个并发线程访问键时。在这种情况下,例外是非常误导的。

边缘案例#2:

如果 nullReferenceException Unsafe 代码抛出的不安全代码,您可以查看指针变量,并检查它们是否 intptr.Zero 或其他东西。这是同一件事(“ null指针异常”),但是在不安全的代码中,变量通常被铸成值类型/数组等,并且您的头撞到了墙上,想知道价值类型如何将其扔给例外。

(顺便说一句,除非需要,除非您需要不使用不安全的代码。)

边缘案例#3:带有辅助监视器的Visual Studio Multi Monitor设置,该设置的DPI设置与主监视器不同,

此EDGE CASE是Software-与“ nofollow noreferrer”> Visualio&nbsp; studio&nbsp; 2019 iDe(以及可能的versions)。

一种重现问题的方法:将任何组件从工具箱拖到具有与主监视器不同的DPI设置的非主要监视器上的Windows表单中目的。”根据,这个问题已经闻名了很多时间,在编写时,它仍然没有修复。

Interestingly, none of the answers on this page mention the two edge cases:

Edge case #1: concurrent access to a Dictionary

Generic dictionaries in .NET are not thread-safe and they sometimes might throw a NullReference or even (more frequent) a KeyNotFoundException when you try to access a key from two concurrent threads. The exception is quite misleading in this case.

Edge case #2: unsafe code

If a NullReferenceException is thrown by unsafe code, you might look at your pointer variables, and check them for IntPtr.Zero or something. Which is the same thing ("null pointer exception"), but in unsafe code, variables are often cast to value-types/arrays, etc., and you bang your head against the wall, wondering how a value-type can throw this exception.

(Another reason for non-using unsafe code unless you need it, by the way.)

Edge case #3: Visual Studio multi monitor setup with secondary monitor(s) that has different DPI setting than the primary monitor

This edge case is software-specific and pertains to the Visual Studio 2019 IDE (and possibly earlier versions).

A method to reproduce the problem: drag any component from the Toolbox to a Windows form on a non-primary monitor with different DPI setting than the primary monitor, and you get a pop-up with “Object reference not set to an instance of an object.” According to this thread, this issue has been known for quite some time and at the time of writing it still hasn't been fixed.

什么是NullReferenceException,我该如何修复?

与他有关 2025-02-18 00:53:55

您首次构建视图,然后加载数据。在力 setstate 上没有视图交互,因此在此视图上没有任何更改。您现在可以做什么?
您有两种方法:

  1. 运行 setState sharone_pref
  2. 使用 funerbuilder 以后呈现另一个小部件,然后加载数据后,
    我建议第二选项

You build view first time, then load data. There is no view interaction on force setState so nothing is changed on this view. What do You can do now?
You have 2 ways:

  1. Run setState after load variables from shared_pref
  2. Use FutureBuilder to render another widget before, and after loading data
    I suggest 2nd option

共享偏好:值未在实时或立即更新

与他有关 2025-02-17 19:11:53

C ++ 23已更新了此问题的最佳答案,这要归功于

struct s {
    auto && f(this auto && self) {
        // all the common code goes here
    }
};

单个功能模板可作为普通成员函数可调用,并为您推论正确的参考类型。没有铸造犯错的东西,也没有为概念上一件事的事情编写多个功能。


注意:此功能由 p0847:deeduc this

C++23 has updated the best answer for this question thanks to explicit object parameters.

struct s {
    auto && f(this auto && self) {
        // all the common code goes here
    }
};

A single function template is callable as a normal member function and deduces the correct reference type for you. No casting to get wrong, no writing multiple functions for something that is conceptually one thing.


Note: this feature was added by P0847: Deducing this.

如何在类似的const和非CONST成员功能之间删除代码重复?

与他有关 2025-02-17 15:50:16

解决方案 a>足够好,您可以留下来。您还可以使用 csv.dictwriter 这将很短:

import xml.etree.ElementTree as ET
from csv import DictWriter

parse_xml = ET.parse(r"/content/sample_data/xyz.xml")
root = parse_xml.getroot()
with open(r"/content/sample_data/abc.csv", "w", newline="") as f:
    writer = DictWriter(f, fieldnames=("price", "name", "calories"), extrasaction="ignore")
    writer.writeheader()
    writer.writerows({e.tag: e.text for e in row} for row in root)

基本上,我们设置了 dictwriter 忽略除 PRISE , name 和卡路里 PRICE 以外的所有字段< /code>然后将生成器传递到 &lt; row&gt; 的所有子节点的构造字典中,键是tag value是文本

Solution of @kiric8494 is good enough, you can stay with it. You can also implement it using csv.DictWriter which will be quite shorter:

import xml.etree.ElementTree as ET
from csv import DictWriter

parse_xml = ET.parse(r"/content/sample_data/xyz.xml")
root = parse_xml.getroot()
with open(r"/content/sample_data/abc.csv", "w", newline="") as f:
    writer = DictWriter(f, fieldnames=("price", "name", "calories"), extrasaction="ignore")
    writer.writeheader()
    writer.writerows({e.tag: e.text for e in row} for row in root)

Basically we set up DictWriter to ignore all fields except price, name and calories and then pass generator to .writerows() which construct dictionary of all child nodes of <row> where key is tag and value is text.

如何读取特定数据并写入CSV文件

与他有关 2025-02-17 12:19:56

要添加附加字段:

form_extra_fields = {
    'Unrelated': SelectField('Unrelated label', widget=Select2Widget(), choices=[('', '')]),
}

请注意,即使空为空,您也必须提供选择,否则该字段会

   def render(self, template, **kwargs):
    '''
      This method is called just before the form is render. Here you can add extra choices and custom JS if you want.
      '''

    #Checks that the form is not being called on the list or delete page
    if not is_form_submitted() and (template == 'admin/model/edit.html' or template == 'admin/model/create.html'):

        #add custom JS
        self.extra_js = [url_for('static', filename='optionalCodeForFrontEndValidatiion.js')]

        form = kwargs['form']

        #Get the field entries from the database. filter and order by are optional.
        all_entries = (request.db_session.query(Unrelated).filter().order_by().all())
        
        #transform them to an iterable for the field
        unrelated_field_choices = ((m.name, m.name) for m in all_entries)
        
        #assign them to the field
        form.unrelated.choices = unrelated_field_choices
         
    #continue the render workflow
    return super().render(template, **kwargs)


def validate_form(self, form):
    """Custom validation code called on form submit. 
    """
    
    #check that we are not being called on load or on delete
    if is_form_submitted() and 'unrelated' in form.data:

        #here we can play with the submited form data and transform what is inside, then pass
        #it to the usual validation flow
        form = self.validate_your_data_conditions(form)

    return super().validate_form(form)

通过使用此答案中的信息来调整和错误,我设法将自定义CSS属性传递给前端:

create selectiffe selectiffe selectiffect in wtforms in wtforms

To add an additional field:

form_extra_fields = {
    'Unrelated': SelectField('Unrelated label', widget=Select2Widget(), choices=[('', '')]),
}

Note that you have to provide choices, even if empty, otherwise the field will throw and error

   def render(self, template, **kwargs):
    '''
      This method is called just before the form is render. Here you can add extra choices and custom JS if you want.
      '''

    #Checks that the form is not being called on the list or delete page
    if not is_form_submitted() and (template == 'admin/model/edit.html' or template == 'admin/model/create.html'):

        #add custom JS
        self.extra_js = [url_for('static', filename='optionalCodeForFrontEndValidatiion.js')]

        form = kwargs['form']

        #Get the field entries from the database. filter and order by are optional.
        all_entries = (request.db_session.query(Unrelated).filter().order_by().all())
        
        #transform them to an iterable for the field
        unrelated_field_choices = ((m.name, m.name) for m in all_entries)
        
        #assign them to the field
        form.unrelated.choices = unrelated_field_choices
         
    #continue the render workflow
    return super().render(template, **kwargs)


def validate_form(self, form):
    """Custom validation code called on form submit. 
    """
    
    #check that we are not being called on load or on delete
    if is_form_submitted() and 'unrelated' in form.data:

        #here we can play with the submited form data and transform what is inside, then pass
        #it to the usual validation flow
        form = self.validate_your_data_conditions(form)

    return super().validate_form(form)

Additionally, i managed to pass custom css attributes to the frontend by using the information from this answer:

Create selectfield options with custom attributes in WTForms

在烧瓶管理员编辑和创建表单上加载其他选择字段和数据条目

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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