大姐,你呐

文章 评论 浏览 28

大姐,你呐 2025-02-20 17:16:58

如果打算在中间件调用中访问服务,则无需尝试访问serviceCollection在启动寄存器

寄存器外部使用中间件中的延期工厂委托所需的暂时服务,

//...

services.AddTransient<IService>(sp => {
    var ctx = sp.GetService<IHttpContextAccessor>().HttpContext;

    var user = //get user however you intended to get user

    //create instance of service
    return ActivatorUtilities.CreateInstance<Service>(sp, user);        
});

//...

可以通过方法注入明确注入服务

//...

public async Task InvokeAsync(HttpContext context, IService service) {
    //...
}

//...

中间件的InvokeAsync的其他参数,httpcontext由依赖项注入填充(di)。

进而注入会员时,这将解决您的瞬态服务

If intending to access the service within the middleware invoke then there is no need to try and access ServiceCollection outside of Startup

register desired transient service using deferred factory delegate

//...

services.AddTransient<IService>(sp => {
    var ctx = sp.GetService<IHttpContextAccessor>().HttpContext;

    var user = //get user however you intended to get user

    //create instance of service
    return ActivatorUtilities.CreateInstance<Service>(sp, user);        
});

//...

In the middleware the service can be explicitly injected via method injection

//...

public async Task InvokeAsync(HttpContext context, IService service) {
    //...
}

//...

Additional parameters for the middleware's InvokeAsync, after HttpContext are populated by dependency injection (DI).

This will in turn resolve your transient service when injecting into the member

您可以在中间件中创建瞬态DI服务吗?

大姐,你呐 2025-02-20 14:33:11

不要将使用作为正则表达式的日期格式格式的字符串误解。
如果解析的字符串使用“ - ”作为日期组件之间的分离器,这也将有效。

Do not mistake the string you use as format of the date formatter for a regular expression.
This would have also worked if the parsed string used the “-“ as separator between the date components.

检查日期是否匹配日期格式

大姐,你呐 2025-02-19 18:41:37

尝试以下操作:

import pandas as pd


dataset = {
    'A': [6, 2, 3, 4, 5, 5, 7, 8, 9, 7],
    'B': [5, 1, 2, 3, 4, 4, 6, 7, 8, 6],
    'C': [0, 1, 0, 1, 1, 0, 1, 0, 1, 0]
}
df = pd.DataFrame(dataset)

print(df)


# this part of code is ok to return muntiple values
def quanta1(data):
        return data['A']+data['B'], data['A']-data['B']


a, b = quanta1(df)
print(a)
print(b)


# I want to return two values a and b  with the if condition
def quanta2(data):
    data = data[data["C"] > 0]
    return data['A']+data['B'], data['A']-data['B']


a, b = quanta2(df)
print(a)
print(b)

try this:

import pandas as pd


dataset = {
    'A': [6, 2, 3, 4, 5, 5, 7, 8, 9, 7],
    'B': [5, 1, 2, 3, 4, 4, 6, 7, 8, 6],
    'C': [0, 1, 0, 1, 1, 0, 1, 0, 1, 0]
}
df = pd.DataFrame(dataset)

print(df)


# this part of code is ok to return muntiple values
def quanta1(data):
        return data['A']+data['B'], data['A']-data['B']


a, b = quanta1(df)
print(a)
print(b)


# I want to return two values a and b  with the if condition
def quanta2(data):
    data = data[data["C"] > 0]
    return data['A']+data['B'], data['A']-data['B']


a, b = quanta2(df)
print(a)
print(b)

我可以从条件函数中返回多个值并单独打印它们吗?

大姐,你呐 2025-02-19 17:19:44

也许修改了所有这些功能和过程的其他对象(例如,包装规范),并且“无效”了所有引用它的对象。

基本上,您不必做任何事情 - Oracle一旦有人称呼它们,就会自动重新编译它们。

这是一个例子。

带有单个函数的软件包:

SQL> create or replace package pkg_test as
  2    function f_test (par_number in number) return number;
  3  end;
  4  /

Package created.

SQL> create or replace package body pkg_test as
  2    function f_test (par_number in number) return number
  3    is
  4    begin
  5      return par_number;
  6    end;
  7  end;
  8  /

Package body created.

独立函数,该函数从包装中引用(呼叫)函数;

SQL> create or replace function f_test_2 (par_number in number)
  2    return number
  3  is
  4  begin
  5    return pkg_test.f_test(par_number);
  6  end;
  7  /

Function created.

它的状态是什么?它是有效的:

SQL> select object_name, object_type, status from user_objects where object_name = 'F_TEST_2';

OBJECT_NAME          OBJECT_TYPE         STATUS
-------------------- ------------------- -------
F_TEST_2             FUNCTION            VALID

它有效吗?是的:

SQL> select f_test_2 (100) result from dual;

    RESULT
----------
       100

SQL>

好的,现在让我们稍微修改包装函数的规格(我添加default srause):

SQL> create or replace package pkg_test as
  2    function f_test (par_number in number default 0) return number;
  3  end;
  4  /

Package created.

SQL> create or replace package body pkg_test as
  2    function f_test (par_number in number default 0) return number
  3    is
  4    begin
  5      return par_number;
  6    end;
  7  end;
  8  /

Package body created.

我没有修改独立函数f_test_2。它的状态是什么?它现在无效

SQL> select object_name, object_type, status from user_objects where object_name = 'F_TEST_2';

OBJECT_NAME          OBJECT_TYPE         STATUS
-------------------- ------------------- -------
F_TEST_2             FUNCTION            INVALID           --> see? INVALID

我可以使用它(不重新编译)吗?是的,我可以:

SQL> select f_test_2 (500) result from dual;

    RESULT
----------
       500

SQL>

Maybe some other object - that is used by all those functions and procedures - was modified (e.g. package specification), and it "invalidated" all objects that reference it.

Basically, you don't have to do anything - Oracle will automatically recompile them as soon as someone calls them.

Here's an example.

Package with a single function:

SQL> create or replace package pkg_test as
  2    function f_test (par_number in number) return number;
  3  end;
  4  /

Package created.

SQL> create or replace package body pkg_test as
  2    function f_test (par_number in number) return number
  3    is
  4    begin
  5      return par_number;
  6    end;
  7  end;
  8  /

Package body created.

Standalone function that references (calls) function from the package;

SQL> create or replace function f_test_2 (par_number in number)
  2    return number
  3  is
  4  begin
  5    return pkg_test.f_test(par_number);
  6  end;
  7  /

Function created.

What is its status? It is VALID:

SQL> select object_name, object_type, status from user_objects where object_name = 'F_TEST_2';

OBJECT_NAME          OBJECT_TYPE         STATUS
-------------------- ------------------- -------
F_TEST_2             FUNCTION            VALID

Does it work? YES:

SQL> select f_test_2 (100) result from dual;

    RESULT
----------
       100

SQL>

OK, let's now slightly modify the packaged function's spec (I'll add the DEFAULT clause):

SQL> create or replace package pkg_test as
  2    function f_test (par_number in number default 0) return number;
  3  end;
  4  /

Package created.

SQL> create or replace package body pkg_test as
  2    function f_test (par_number in number default 0) return number
  3    is
  4    begin
  5      return par_number;
  6    end;
  7  end;
  8  /

Package body created.

I didn't modify standalone function f_test_2. What is its status? It is now INVALID:

SQL> select object_name, object_type, status from user_objects where object_name = 'F_TEST_2';

OBJECT_NAME          OBJECT_TYPE         STATUS
-------------------- ------------------- -------
F_TEST_2             FUNCTION            INVALID           --> see? INVALID

Can I use it (without recompiling it)? Yes, I can:

SQL> select f_test_2 (500) result from dual;

    RESULT
----------
       500

SQL>

SQL开发人员,功能和过程摆脱了编译

大姐,你呐 2025-02-19 14:52:12

您可以在任何跨度上提供一堂课,并给他们样式

you can give one class for any span and give them styles

如何将线性级别的CSS应用于通常的两个具有背景颜色的跨度相互重叠的跨度?

大姐,你呐 2025-02-19 13:39:16

这是您答案的示例代码:

html:

<p id="ANYTHING_YOU_WANT">ANYTHING_YOU_WANT</p>

js:

const VARIABLE_NAME = document.getElementById("ANYTHING_YOU_WANT");

VARIABLE_NAME.style.color = "aqua";

给您的课程和文本,而不是 nothing_you_want 和您的变量名称,而不是 variable_name...

Here is an example code for your answer:

HTML:

<p id="ANYTHING_YOU_WANT">ANYTHING_YOU_WANT</p>

JS:

const VARIABLE_NAME = document.getElementById("ANYTHING_YOU_WANT");

VARIABLE_NAME.style.color = "aqua";

Give your class and text instead of ANYTHING_YOU_WANT and your variable name instead of VARIABLE_NAME...

通过控制台更改段落标签颜色

大姐,你呐 2025-02-19 13:27:25

您不必担心它。一个线程读数和一个线程编写将按照您的预期工作。插座是完整的双链体,因此您可以在写作时阅读,反之亦然。您必须担心是否有多个作家,但事实并非如此。

You don't have to worry about it. One thread reading and one thread writing will work as you expect. Sockets are full duplex, so you can read while you write and vice-versa. You'd have to worry if you had multiple writers, but this is not the case.

同时在C或C&#x2B;&#x2B中的同一插座上读写和写入。

大姐,你呐 2025-02-19 05:33:46

我认为您应该加入工人节点的码头组合

depends on :master

I think you should add in the docker-compose of worker nodes

depends on :master

如何在独立的多节点多折叠设置上运行火花群集

大姐,你呐 2025-02-18 19:03:15

最流利的方式:

Model::query()->whereNotIn('column', $arrayOfValues);

我建议您始终将Query()方法与模型一起使用,因为它可以探索Laravel模型类的所有可用选项

The most fluent way :

Model::query()->whereNotIn('column', $arrayOfValues);

I will recommend you always using query() method together with your models, since it will allow you to explore all of the available options for the Laravel Model class

如何放置&#x27;!=&#x27;在Laravel查询构建器中有一个数组?

大姐,你呐 2025-02-18 11:20:50

好的,我仍然不了解certbot启动自己的nginx,不停止它,弄乱pids的怪异,所有这些...但是certbot现在可以看到我们的服务器并续订SSL证书。经过两天的宣誓盲人,它并没有被防火墙规则阻止……那是防火墙。

叹。

Ok, I still don't understand the weirdness with certbot starting its own nginx and not stopping it and mucking up PIDs and all that... but certbot can now see our server and renew the SSL certs. And after two days of IT swearing blind that it wasn't being blocked by a firewall rule... it was the firewall.

Sigh.

certbot nginx身份验证失败:“连接重置”

大姐,你呐 2025-02-18 07:06:21

需要一点澄清条件应将一排从DF2合并为DF1,以及合并的外观。

该代码段可以按照我的条件来完成我认为您正在寻找的操作,但是我只是在DF1中添加了一个Col,该Col跟踪DF1的Col与DF2中的一些行相匹配,以及DF2

df1 = pd.DataFrame(data_1)
df2 = pd.DataFrame(data_2)


check = []
for df1_ind in df1.index:
    found = ""
    for df2_ind in df2.index:
        col1_check = df1["Col1_df1"][df1_ind] in df2["To_Check"][df2_ind]
        col2_check = df1["Col2_df1"][df1_ind] in df2["To_Check"][df2_ind]
        df1_id_present = df1["df1_ID"][df1_ind] in [df2['df2_ID1'][df2_ind], df2['df2_ID2'][df2_ind]]
        # wasn't sure if that first conditional meant the df1_id being present effected the column checks
        if col1_check:
            found += f"Col_1_present(df2_ID={df2_ind})::"
        if col2_check:
            found += f"Col_2_present(df2_ID={df2_ind})::"
        if not found == "":
            # this means the cols from df1 we are looking for in df2 were found at some row. 
            # leave the inner for loop and save these results
            # unless you expect the row contents to appear in multiple rows of df2
            break 
    if found == "":
        found = "false"
    check.append(found)

df1['Checks'] = check
print(df1.head())

输出 的该行的ID :

    df1_ID    Col1_df1 Col2_df1 Col3_df1                      Checks
0  ABC-001  a.102_103i    k159*    Test1  Col_1_present:(df2_ID=0)::
1  DEF-002    a.36-89E     k188    Test2              Col_2_present:
2  GHI-003    ab.23<<X    e542m    Test3              Col_1_present:

Need a little clarification on what condition means that a row should be merged from df2 into df1, as well as what that merge should look like.

This code segment does what I think you're looking for in terms of the conditional, but I just added a col to df1 that tracks which col from df1 matched some rows To_Check in df2, as well as the ID of that row from df2

df1 = pd.DataFrame(data_1)
df2 = pd.DataFrame(data_2)


check = []
for df1_ind in df1.index:
    found = ""
    for df2_ind in df2.index:
        col1_check = df1["Col1_df1"][df1_ind] in df2["To_Check"][df2_ind]
        col2_check = df1["Col2_df1"][df1_ind] in df2["To_Check"][df2_ind]
        df1_id_present = df1["df1_ID"][df1_ind] in [df2['df2_ID1'][df2_ind], df2['df2_ID2'][df2_ind]]
        # wasn't sure if that first conditional meant the df1_id being present effected the column checks
        if col1_check:
            found += f"Col_1_present(df2_ID={df2_ind})::"
        if col2_check:
            found += f"Col_2_present(df2_ID={df2_ind})::"
        if not found == "":
            # this means the cols from df1 we are looking for in df2 were found at some row. 
            # leave the inner for loop and save these results
            # unless you expect the row contents to appear in multiple rows of df2
            break 
    if found == "":
        found = "false"
    check.append(found)

df1['Checks'] = check
print(df1.head())

output:

    df1_ID    Col1_df1 Col2_df1 Col3_df1                      Checks
0  ABC-001  a.102_103i    k159*    Test1  Col_1_present:(df2_ID=0)::
1  DEF-002    a.36-89E     k188    Test2              Col_2_present:
2  GHI-003    ab.23<<X    e542m    Test3              Col_1_present:

将多列与特殊字符和合并数据框进行比较

大姐,你呐 2025-02-18 06:04:56

对于Python版本&gt; = 3.6(请参阅 pep 498

s1='albha'
s2='beta'

f'{s1}{s2:>10}'

#output
'albha      beta'

For python version >= 3.6 (see PEP 498)

s1='albha'
s2='beta'

f'{s1}{s2:>10}'

#output
'albha      beta'

字符串格式:%vs. .format与F-string字面

大姐,你呐 2025-02-18 02:37:20

这是我组合的“级联选择”的演示系统,以回答另一个网站上的类似问题。

演示页面:

@page "/Test"
@page "/"

<PageTitle>Index</PageTitle>

<h6>Select Test</h6>

<div class="m-2 p-2 row">
    <div class="col-2">
        Continent:
    </div>
    <div class="col-6">
        <select class="form-select form-select-sm" value="@model.Continent" @onchange=this.ContinentChange>
            <option value="">-- Select A Continent --</option>
            @foreach (var continent in Data.Continents)
            {
                <option value="@continent.Name">@continent.Name</option>
            }
        </select>
    </div>
</div>

<div class="m-2 p-2 row">
    <div class="col-2">
        Country:
    </div>
    <div class="col-6">
        <select disabled="@this.countryDisabled" class="form-select form-select-sm" value="@model.Country" @onchange=this.CountryChange>
            <option value="">-- Select A Country --</option>
            @foreach (var item in filteredCountries)
            {
                <option value="@item.Name">@item.Name</option>
            }
        </select>
    </div>
</div>

<div class="m-2 p-2 bg-light">
    <div>
        Continent = @model.Continent
    </div>
    <div>
        Country = @model.Country
    </div>
</div>

@code {
    private CountryData Data = CountryData.Instance();
    private Model model = new Model();
    private List<Country> filteredCountries = new List<Country>();
    private bool countryDisabled => string.IsNullOrWhiteSpace(this.model.Continent);

    private void ContinentChange(ChangeEventArgs e)
    {
        string continent = e.Value?.ToString() ?? string.Empty;

        if (!model.Continent.Equals(continent, StringComparison.CurrentCultureIgnoreCase))
        {
            filteredCountries.Clear();
            filteredCountries.AddRange(Data.Countries.Where(item => item.Continent == continent));
            model.Country = string.Empty;
            model.Continent = continent;
        }
    }

    private void CountryChange(ChangeEventArgs e)
    {
        string country = e.Value?.ToString() ?? string.Empty;

        if (!model.Country.Equals(country, StringComparison.CurrentCultureIgnoreCase))
            model.Country = country;
    }

    public class Model
    {
        public string Country { get; set; } = string.Empty;
        public string Continent { get; set; } = string.Empty;
    }

}

及其使用的数据集。

namespace BlazorApp3.Data;

public class Continent
{
    public string Name { get; set; } = String.Empty;
}

public class Country
{
    public string Continent { get; set; } = string.Empty;
    public string Name { get; set; } = String.Empty;
}

public class CountryData
{
    public IEnumerable<Country> Countries { get; private set; } = Enumerable.Empty<Country>();
    public IEnumerable<Continent> Continents { get; private set; } = Enumerable.Empty<Continent>();

    private CountryData()
        => this.GetData();

    public void GetData()
    {
        var continents = new List<Continent>();

        var continent = new Continent { Name = "Europe" };
        continents.Add(continent);
        var countries = new List<Country>
        {
            new Country { Name = "France", Continent = continent.Name },
            new Country { Name = "Portugal", Continent = continent.Name },
            new Country { Name = "England", Continent = continent.Name },
        };

        continent = new Continent { Name = "Africa" };
        continents.Add(continent);
        countries.Add(new Country { Name = "Senegal", Continent = continent.Name });
        countries.Add(new Country { Name = "Egypt", Continent = continent.Name });
        countries.Add(new Country { Name = "Kenya", Continent = continent.Name });

        continent = new Continent {Name = "South America" };
        continents.Add(continent);
        countries.Add(new Country { Name = "Brazil", Continent = continent.Name });
        countries.Add(new Country { Name = "Chile", Continent = continent.Name });
        countries.Add(new Country { Name = "Peru", Continent = continent.Name });

        this.Continents = continents;
        this.Countries = countries;
    }

    public static CountryData? _instance;
    public static CountryData Instance()
    {
        if (_instance is null)
            _instance = new CountryData();

        return _instance;
    }
}

Here's a demo system for a "Cascading Select" that I put together to answer a similar question on another site.

The demo page:

@page "/Test"
@page "/"

<PageTitle>Index</PageTitle>

<h6>Select Test</h6>

<div class="m-2 p-2 row">
    <div class="col-2">
        Continent:
    </div>
    <div class="col-6">
        <select class="form-select form-select-sm" value="@model.Continent" @onchange=this.ContinentChange>
            <option value="">-- Select A Continent --</option>
            @foreach (var continent in Data.Continents)
            {
                <option value="@continent.Name">@continent.Name</option>
            }
        </select>
    </div>
</div>

<div class="m-2 p-2 row">
    <div class="col-2">
        Country:
    </div>
    <div class="col-6">
        <select disabled="@this.countryDisabled" class="form-select form-select-sm" value="@model.Country" @onchange=this.CountryChange>
            <option value="">-- Select A Country --</option>
            @foreach (var item in filteredCountries)
            {
                <option value="@item.Name">@item.Name</option>
            }
        </select>
    </div>
</div>

<div class="m-2 p-2 bg-light">
    <div>
        Continent = @model.Continent
    </div>
    <div>
        Country = @model.Country
    </div>
</div>

@code {
    private CountryData Data = CountryData.Instance();
    private Model model = new Model();
    private List<Country> filteredCountries = new List<Country>();
    private bool countryDisabled => string.IsNullOrWhiteSpace(this.model.Continent);

    private void ContinentChange(ChangeEventArgs e)
    {
        string continent = e.Value?.ToString() ?? string.Empty;

        if (!model.Continent.Equals(continent, StringComparison.CurrentCultureIgnoreCase))
        {
            filteredCountries.Clear();
            filteredCountries.AddRange(Data.Countries.Where(item => item.Continent == continent));
            model.Country = string.Empty;
            model.Continent = continent;
        }
    }

    private void CountryChange(ChangeEventArgs e)
    {
        string country = e.Value?.ToString() ?? string.Empty;

        if (!model.Country.Equals(country, StringComparison.CurrentCultureIgnoreCase))
            model.Country = country;
    }

    public class Model
    {
        public string Country { get; set; } = string.Empty;
        public string Continent { get; set; } = string.Empty;
    }

}

And the data set it uses.

namespace BlazorApp3.Data;

public class Continent
{
    public string Name { get; set; } = String.Empty;
}

public class Country
{
    public string Continent { get; set; } = string.Empty;
    public string Name { get; set; } = String.Empty;
}

public class CountryData
{
    public IEnumerable<Country> Countries { get; private set; } = Enumerable.Empty<Country>();
    public IEnumerable<Continent> Continents { get; private set; } = Enumerable.Empty<Continent>();

    private CountryData()
        => this.GetData();

    public void GetData()
    {
        var continents = new List<Continent>();

        var continent = new Continent { Name = "Europe" };
        continents.Add(continent);
        var countries = new List<Country>
        {
            new Country { Name = "France", Continent = continent.Name },
            new Country { Name = "Portugal", Continent = continent.Name },
            new Country { Name = "England", Continent = continent.Name },
        };

        continent = new Continent { Name = "Africa" };
        continents.Add(continent);
        countries.Add(new Country { Name = "Senegal", Continent = continent.Name });
        countries.Add(new Country { Name = "Egypt", Continent = continent.Name });
        countries.Add(new Country { Name = "Kenya", Continent = continent.Name });

        continent = new Continent {Name = "South America" };
        continents.Add(continent);
        countries.Add(new Country { Name = "Brazil", Continent = continent.Name });
        countries.Add(new Country { Name = "Chile", Continent = continent.Name });
        countries.Add(new Country { Name = "Peru", Continent = continent.Name });

        this.Continents = continents;
        this.Countries = countries;
    }

    public static CountryData? _instance;
    public static CountryData Instance()
    {
        if (_instance is null)
            _instance = new CountryData();

        return _instance;
    }
}

如果在Blazor中更改了另一个选择框,则如何重置选择框的选择(带到Adefault值)?

大姐,你呐 2025-02-17 19:21:22

以下两个选项可用。

  1. 列表生成
mylist = [1, 2, 7, 11, 8, 55, 89, 1, 3, 8]
res = [mylist[i:i+5] for i in range(0, len(mylist)-4)]
  1. 循环,因为它是顺序构造的,并且一旦不满足长度,就可以简单地退出循环(另请参见以前的方法,以限制循环长度的限制)
mylist = [1, 2, 7, 11, 8, 55, 89, 1, 3, 8]
new = []
for i in range(0, len(mylist)):
    if len(mylist[i:i+5]) == 5:
        new.append(mylist[i:i+5])
    else:
        break

The following two options are available.

  1. List Generative
mylist = [1, 2, 7, 11, 8, 55, 89, 1, 3, 8]
res = [mylist[i:i+5] for i in range(0, len(mylist)-4)]
  1. a loop, since it is constructed sequentially and can simply exit the loop once the length is not satisfied (see also the previous approach for a limit on the length of the loop)
mylist = [1, 2, 7, 11, 8, 55, 89, 1, 3, 8]
new = []
for i in range(0, len(mylist)):
    if len(mylist[i:i+5]) == 5:
        new.append(mylist[i:i+5])
    else:
        break

如何创建列表列表

大姐,你呐 2025-02-17 17:32:52

请查看

Please take a look at documentation, and for further explanation you can take a look at sample apps, providing by deepstream (e.g. test4, written in C - there are frame, object and user metadata presented.

NVIDIA数据类型

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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