忆依然

文章 评论 浏览 29

忆依然 2025-02-20 16:58:59

您当前尝试不起作用的原因是,PowerShell中的单引号(')字符串是 verbatim strings - 不尝试扩展子表达管道或变量表达。

如果您想要一个可扩展的字符串文字而无需逃脱字符串本身中包含的所有双引号(),请使用此处的字符串:

$mynumber = 2

$tag = @"
{"number" = "$($mynumber)", "application" = "test","color" = "blue", "class" = "Java"}
"@

The reason your current attempt doesn't work is that single-quoted (') string literals in PowerShell are verbatim strings - no attempt will be made at expanding subexpression pipelines or variable expressions.

If you want an expandable string literal without having to escape all the double-quotes (") contained in the string itself, use a here-string:

$mynumber = 2

$tag = @"
{"number" = "$($mynumber)", "application" = "test","color" = "blue", "class" = "Java"}
"@

powershell格式为字符串

忆依然 2025-02-20 16:57:26

如果有帮助,请尝试:

const combinedData = firstData.map(item => {
    return {
      ...item,
      ...(secondData.find(secondItem => secondItem.year_and_month === item.year_and_month && secondItem.name === item.name))
    }
  })

Try if this helps:

const combinedData = firstData.map(item => {
    return {
      ...item,
      ...(secondData.find(secondItem => secondItem.year_and_month === item.year_and_month && secondItem.name === item.name))
    }
  })

根据键组合对象数组

忆依然 2025-02-20 00:58:40

这里的诀窍是要了解 pandas 对象非常关心 .index 很多。由于 .index series 可以支持几乎是类似行为。从这个角度来看,就像在字典上检查在中检查键是否存在,也有意义地说, in in pandas object in in in索引存在。

因此,使用上述内容,我们可以检查:

>>> import pandas as pd
>>> s = pd.Series([1,2,3,4,6,7,8,9])
>>> s.index
RangeIndex(start=0, stop=8, step=1)

>>> 5 in s # implicitly check if 5 is in s.index
True
>>> 5 in s.index # explicitly check if 5 is in s.index
True

>>> 5 in s.values # explicitly check if 5 is in values
False

一种替代方法来检查值是否在 series 中您可以使用一些布尔逻辑:

>>> (5 == s).any()
False

另请参阅也是这个答案

The trick here is to understand that pandas objects care about the .index a lot. Because of the .index, Series can support a near-dictionary like behavior. From this perspective, just like checking in on a dictionary to check for key existence, it makes some sense that in on a pandas object checks for index existence.

So using the above, we can check:

>>> import pandas as pd
>>> s = pd.Series([1,2,3,4,6,7,8,9])
>>> s.index
RangeIndex(start=0, stop=8, step=1)

>>> 5 in s # implicitly check if 5 is in s.index
True
>>> 5 in s.index # explicitly check if 5 is in s.index
True

>>> 5 in s.values # explicitly check if 5 is in values
False

An alternative way to check if a value is in a Series you can use some boolean logic:

>>> (5 == s).any()
False

Also see This Answer as well.

如果数据框架不转换为列表,则熊猫数据框中的非现有值返回true。

忆依然 2025-02-19 12:13:32

假设您控制网页的源代码,则有两种将数据传递到HTML网页中的方法。请注意,<%= coords%> 是ASP.NET的事物,可将信息从加载后的前端传递到前端,并且需要更多的工作才能工作(更容易工作选项)。

方法1

如果您只需要一种方式通信(传递到网页,但不需要将任何内容发送回WPF C#),则可以将信息作为查询字符串传递,然后解析当您的应用程序加载时。这真的很容易。这是一个网页的示例,该网页使用可选的 Center Zoom 参数显示为this test.html?center = 51.50632,-0.12714 & Zoom = 15

<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>

    <meta charset="utf-8" />
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
</head>
<body>

    <div id='myMap' style='width: 100vw; height: 100vh;'></div>

<script>
    var map;
    
    function GetMap(){  
        //Default center/zoom values.
        let center = new Microsoft.Maps.Location(0, 0);
        let zoom = 1;

        //Get the queryStringuery string of the URL. 
        const queryString = window.location.search;
        const urlParams = new URLSearchParams(queryString);
        
        //Extract center infromation from query string. 
        if (urlParams.has('center')) {
            //Parse coordinates from the center parameter. Assume that string is in the format "latitude, longitude". Comma/space optional, must have atleast one. 
            let parts = urlParams.get('center').split(/[,\s]+/gi);
            
            if(parts.length >= 2){
                let lat = parseFloat(parts[0]);
                let lon = parseFloat(parts[1]);
                
                if(!isNaN(lat) && !isNaN(lat)){
                    center = new Microsoft.Maps.Location(lat, lon);
                }
            }
        } 
        
        if (urlParams.has('zoom')) {
            let z = parseInt(urlParams.get('zoom'));
            
            if(!isNaN(z)){
                zoom = z;
            }   
        }
        
         map = new Microsoft.Maps.Map('#myMap', {
            center: center,
            zoom: zoom
         });
    }
</script>
<script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[Your Bing Maps Key]' async defer></script>
</body>
</html>

这种方法的主要限制是:

  • 您只能传递最大URL长度允许的信息(2083个字符)。
  • 页面加载时仅发送一次信息。如果要发送新信息,则必须重新加载该页面(效率低下,并且在使用Bing Maps时可以生成其他地图会话)。
  • 无法将信息发送回WPF应用程序。

方法2

如果要进行双向通信,或者想避免方法1的局限性,则可以在应用程序中包装Web浏览器控件并利用互操作性。当前WPF提供WebView2,它允许您将边缘浏览器嵌入应用程序 https://learn.microsoft.com/en-us/microsoft-ge/webview2/get-started/wpf 这是一篇很棒的详细博客文章,介绍了如何做到这一点: https://weblog.west-wind.com/posts/2021/jan/26/chromium-webview2-control-webview2-control-and-net-net-net-net-to-javascript-interop-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-2

另外,您可以可以还使用Chromium/CEFSHARP( https://cefsharp.github.io/ ),而不是WPF的WebView2 Control(它可能会使您的应用程序更大,因为它不会利用已经安装在已经安装在该浏览器上的浏览器系统: https://dev.to/noseratio/comparing-process-working-sets-of-webview基于windows-desktop-apps-5dkk )。

更新:方法3

您可以将HTML文件读取为字符串,然后在占位符上进行查找和替换。在下面的示例中,我使HTML文件成为嵌入式资源(如果您想在某个时候将其运送到其他人,则可能需要做的事情)。我称其为 mappage.html ,并将其放在项目的根目录中。将HTML文件添加到您的项目中,转到属性并将构建操作设置为嵌入式资源。要读取它,您需要将项目的名称空间包括在文件名路径中,在我的情况下,名称空间为 simplewebbrowser ,因此,当读取为 simple> simple> simple weebbrowser.mappage时,文件名将是。 html 。然后,在您的C#代码中,您可以使用这样的方法:

private void LoadMap(double latitude, double longitude)
{
    Assembly assembly = Assembly.GetExecutingAssembly();
    using (var reader = new StreamReader(assembly.GetManifestResourceStream("SimpleWebBrowser.mapPage.html")))
    {
        var html = reader.ReadToEnd();
        html = html.Replace("<%=coords%>", latitude + " " + longitude);

        myBrowser.NavigateToString(html);
    }
}

您的HTML代码将处理这样的输入:

<script type='text/javascript'>
    var map;
    var coords = '<%=coords%>';

    function GetMap() {
        //Default center.
        var center = new Microsoft.Maps.Location(55, 0);
       
        //Parse the coords string and get lat/lon values.
        var parts = coords.split(' ');
       
        if(parts.length >= 2){
            let lat = parseFloat(parts[0]);
            let lon = parseFloat(parts[1]);

            if(!isNaN(lat) && !isNaN(lat)){
                center = new Microsoft.Maps.Location(lat, lon);
            }
        }
     
        map = new Microsoft.Maps.Map('#myMap', {center: });
    ...

There are two ways to pass data into a HTML web page from a WPF app, assuming you control the source code of the web page. Note that <%=coords%> is an ASP.NET thing that passes information from the code behind to the front end on load and would require a lot more work to get working (there are easier options).

Method 1

If you only want one way communication (pass into the web page, but don't need to send anything back to WPF C#), you can pass the information in as a query string, then parse that when your application loads. This is really easy. Here is an example of a web page that takes in a URL with optional center and zoom parameters the look like this test.html?center=51.50632,-0.12714&zoom=15

<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>

    <meta charset="utf-8" />
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
</head>
<body>

    <div id='myMap' style='width: 100vw; height: 100vh;'></div>

<script>
    var map;
    
    function GetMap(){  
        //Default center/zoom values.
        let center = new Microsoft.Maps.Location(0, 0);
        let zoom = 1;

        //Get the queryStringuery string of the URL. 
        const queryString = window.location.search;
        const urlParams = new URLSearchParams(queryString);
        
        //Extract center infromation from query string. 
        if (urlParams.has('center')) {
            //Parse coordinates from the center parameter. Assume that string is in the format "latitude, longitude". Comma/space optional, must have atleast one. 
            let parts = urlParams.get('center').split(/[,\s]+/gi);
            
            if(parts.length >= 2){
                let lat = parseFloat(parts[0]);
                let lon = parseFloat(parts[1]);
                
                if(!isNaN(lat) && !isNaN(lat)){
                    center = new Microsoft.Maps.Location(lat, lon);
                }
            }
        } 
        
        if (urlParams.has('zoom')) {
            let z = parseInt(urlParams.get('zoom'));
            
            if(!isNaN(z)){
                zoom = z;
            }   
        }
        
         map = new Microsoft.Maps.Map('#myMap', {
            center: center,
            zoom: zoom
         });
    }
</script>
<script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[Your Bing Maps Key]' async defer></script>
</body>
</html>

The main limitations of this approach are:

  • You can only pass as much information as the max URL length will allow (2083 characters).
  • Information is only sent once, when the page loads. If you want to send new information, then the page has to be reloaded (inefficient, and can generate additional map sessions when using Bing Maps).
  • No way to send information back to the WPF app.

Method 2

If you want to two-way communication, or want to avoid the limitations of method 1 you can wrap a web browser control in your application and make use of interoperability. Currently WPF provides WebView2 which allows you to embed the Edge browser into your application https://learn.microsoft.com/en-us/microsoft-edge/webview2/get-started/wpf Here is a great detailed blog post on how to do this: https://weblog.west-wind.com/posts/2021/Jan/26/Chromium-WebView2-Control-and-NET-to-JavaScript-Interop-Part-2

Alternatively, you can also use Chromium/CefSharp (https://cefsharp.github.io/) rather than WPF's WebView2 control (it likely will make your application a lot larger since it won't leverage the browser that's already installed on the system: https://dev.to/noseratio/comparing-process-working-sets-of-webview-based-windows-desktop-apps-5dkk).

Update: Method 3

You can read your HTML file as a string and do a find and replace on your placeholder. In the below example I've made the HTML file an embedded resource (likely what you will need to do if you want to ship this to others at some point). I called it mapPage.html and have it in the root directory of the project. Add the html file to your project, go to properties and set build action to embedded resource. To read it you will need to include the namespace of your project in the file name path, in my case the namespace is SimpleWebBrowser, thus the file name would when reading would be SimpleWebBrowser.mapPage.html. Then in your C# code you could have a method like this:

private void LoadMap(double latitude, double longitude)
{
    Assembly assembly = Assembly.GetExecutingAssembly();
    using (var reader = new StreamReader(assembly.GetManifestResourceStream("SimpleWebBrowser.mapPage.html")))
    {
        var html = reader.ReadToEnd();
        html = html.Replace("<%=coords%>", latitude + " " + longitude);

        myBrowser.NavigateToString(html);
    }
}

You HTML code would then handle the input like this:

<script type='text/javascript'>
    var map;
    var coords = '<%=coords%>';

    function GetMap() {
        //Default center.
        var center = new Microsoft.Maps.Location(55, 0);
       
        //Parse the coords string and get lat/lon values.
        var parts = coords.split(' ');
       
        if(parts.length >= 2){
            let lat = parseFloat(parts[0]);
            let lon = parseFloat(parts[1]);

            if(!isNaN(lat) && !isNaN(lat)){
                center = new Microsoft.Maps.Location(lat, lon);
            }
        }
     
        map = new Microsoft.Maps.Map('#myMap', {center: });
    ...

如何从C#中接收JavaScript中的变量?

忆依然 2025-02-19 04:02:35

我无法复制您的错误。一方面,您的0.10845值不正确:请记住,它可以以这种方式计算(即 logistic(z)在您的实现中。但是,无论如何,我计算的价值与Pytorch产生的价值一致。

这是逻辑函数:

import numpy as np

def logistic(z, derivative=False):
    if not derivative:
        return 1 / (1 + np.exp(-z))
    else:
        return logistic(z) * (1 - logistic(z))
    
logistic(0.8762, derivative=True)

这将产生 0.20754992931590668

现在使用pytorch:

import torch

t = torch.Tensor([0.8762])
t.requires_grad = True
torch.sigmoid(t).backward()
t.grad

这会产生张量([0.2075])

I can't reproduce your error. For one thing, your value of 0.10845 is not correct: remember that it might be computed that way (i.e. z * (1 - z)) because you expect z to be logistic(z) in your implementation. But, in any case, the value I compute agrees with what PyTorch produces.

Here's the logistic function:

import numpy as np

def logistic(z, derivative=False):
    if not derivative:
        return 1 / (1 + np.exp(-z))
    else:
        return logistic(z) * (1 - logistic(z))
    
logistic(0.8762, derivative=True)

This produces 0.20754992931590668.

Now with PyTorch:

import torch

t = torch.Tensor([0.8762])
t.requires_grad = True
torch.sigmoid(t).backward()
t.grad

This produces tensor([0.2075]).

我的nn.sigmoid()梯度与我的手动计算不同

忆依然 2025-02-19 02:35:57

您可以使用:

kubectl get hpa -A -w

使用 -A 选项,它可以从所有 namespaces 中为您提供所有HPA,如果您要指定 namepace ,您可以使用 -n 选项。并且 -w 参数用于手表,因此您有一个刷新的接口,可在HPA ressources上为您提供信息。

You can use:

kubectl get hpa -A -w

with the -A option it gives you all your hpa from all namespaces if you want to specify a namespace, you can use -n option. And the -w argument is for watch so you have a refreshed interface that gives you infos on your hpa ressources.

如何检查Kubernetes Pod的最小和最大副本集

忆依然 2025-02-18 22:35:49

这本质上是一个错误,已在Linux 5.15.78中固定。

日志所说的:

    With just the forward declaration of the 'struct pt_regs' in
    syscall_wrapper.h, the syscall stub functions:
    
      __[x64|ia32]_sys_*(struct pt_regs *regs)
    
    will have different definition of 'regs' argument in BTF data
    based on which object file they are defined in.
    
    If the syscall's object includes 'struct pt_regs' definition,
    the BTF argument data will point to a 'struct pt_regs' record,
    like:
    
      [226] STRUCT 'pt_regs' size=168 vlen=21
             'r15' type_id=1 bits_offset=0
             'r14' type_id=1 bits_offset=64
             'r13' type_id=1 bits_offset=128
      ...
    
    If not, it will point to a fwd declaration record:
    
      [15439] FWD 'pt_regs' fwd_kind=struct
    
    and make bpf tracing program hooking on those functions unable
    to access fields from 'struct pt_regs'.
    
    Include asm/ptrace.h directly in syscall_wrapper.h to make sure all
    syscalls see 'struct pt_regs' definition. This then results in BTF for
    '__*_sys_*(struct pt_regs *regs)' functions to point to the actual
    struct, not just the forward declaration.

这是提交 在 asm/ptrace.h 带有实际定义 #include&lt; asm/ptrace.h&gt; 解决了问题。

This is essentially a bug and has been fixed in Linux 5.15.78.

This is what the commit log says:

    With just the forward declaration of the 'struct pt_regs' in
    syscall_wrapper.h, the syscall stub functions:
    
      __[x64|ia32]_sys_*(struct pt_regs *regs)
    
    will have different definition of 'regs' argument in BTF data
    based on which object file they are defined in.
    
    If the syscall's object includes 'struct pt_regs' definition,
    the BTF argument data will point to a 'struct pt_regs' record,
    like:
    
      [226] STRUCT 'pt_regs' size=168 vlen=21
             'r15' type_id=1 bits_offset=0
             'r14' type_id=1 bits_offset=64
             'r13' type_id=1 bits_offset=128
      ...
    
    If not, it will point to a fwd declaration record:
    
      [15439] FWD 'pt_regs' fwd_kind=struct
    
    and make bpf tracing program hooking on those functions unable
    to access fields from 'struct pt_regs'.
    
    Include asm/ptrace.h directly in syscall_wrapper.h to make sure all
    syscalls see 'struct pt_regs' definition. This then results in BTF for
    '__*_sys_*(struct pt_regs *regs)' functions to point to the actual
    struct, not just the forward declaration.

Replacing a forward declaration struct pt_regs; in asm/ptrace.h with an actual definition #include <asm/ptrace.h> fixes the issue.

“无效的bpf_context访问”试图读取“ regs”参数时

忆依然 2025-02-18 15:15:40

getRangeByName()不是表格的方法,而是电子表格。因此,您应该尝试:

var bot_id = SpreadsheetApp.getActiveSpreadsheet().getRangeByName("bot_id");

getRangeByName() is not a method of Sheet but instead of Spreadsheet. So you should try:

var bot_id = SpreadsheetApp.getActiveSpreadsheet().getRangeByName("bot_id");

这可以使用Gsheet AppScript中的rangenames来处理吗?我遇到此错误:'typeError:sheet.getRangebyName不是函数。

忆依然 2025-02-18 12:29:34

我正在使用NextJS版本14和Next-auth 4.24,并与下一个Auth Middleware一起发现了同样的问题。我正在使用下一个Auth的数据库策略。对于仍然弄清楚这个问题的每个人。我这样管理的

import { withAuth } from "next-auth/middleware";

export default withAuth({
  callbacks: {
    authorized: ({ req }) => {
      // verify token and return a boolean
      const sessionToken = req.cookies.get("next-auth.session-token");
      if (sessionToken) return true;
      else return false;
    },
  },
});

export const config = { matcher: ["/home/:path*"] };

想法是检查令牌cookie是否仍然存在,如果不是,请重定向

I'm using nextJS version 14 and next-auth 4.24 and found the same issue with next auth middleware. I'm using database strategies with next auth. For everyone who still figure out this issue. I manage it like this

import { withAuth } from "next-auth/middleware";

export default withAuth({
  callbacks: {
    authorized: ({ req }) => {
      // verify token and return a boolean
      const sessionToken = req.cookies.get("next-auth.session-token");
      if (sessionToken) return true;
      else return false;
    },
  },
});

export const config = { matcher: ["/home/:path*"] };

The idea is to check if token cookies still exist, if it's not then redirect

成功登录后,Next-auth.js with next.js中间件重定向到登录页面

忆依然 2025-02-18 10:58:50

不幸的是,简短的答案是,不可能通过来源生成器来达到您希望的精确解决方案。原因是源发电机的绝对设计理念之一(我感到沮丧,但可以理解理由)是通过使用源发电机来积极地禁止现有源文件突变。换句话说,您实际上无法修改任何手写类的代码。源生成器为。它仍然可以非常强大的原因是通过使用部分类(其定义在多个文件中声明的类型)。

有了这个序言,让我们更仔细地看一下您的确切用例。您有此方法:

public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
                        [ValidateParameter(typeof(EmailValidator))] Email email,
                        [ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
    User user = new(name, email, dateOfBirth);
    _userRepository.Add(user);
    return user;
}

您想将其转换为此方法:

public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
                        [ValidateParameter(typeof(EmailValidator))] Email email,
                        [ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
    Activator.CreateInstance<NameValidator>().Validate(name);
    Activator.CreateInstance<EmailValidator>().Validate(email);
    Activator.CreateInstance<AdultValidator>().Validate(dateOfBirth);
    User user = new(name, email, dateOfBirth);
    _userRepository.Add(user);
    return user;
}

如您所见,您想要的结果需要修改您的 createuser 方法,这是不可能的。

一个可以使您一半的解决方案是为任何方法生成一种用 validateParameter 属性的参数生成自定义验证方法。例如,您可以生成此方法:

// Generated
private void ValidateCreateUser(Name name, Email email, DateOfBirth dateOfBirth)
{
    Activator.CreateInstance<NameValidator>().Validate(name);
    Activator.CreateInstance<EmailValidator>().Validate(email);
    Activator.CreateInstance<AdultValidator>().Validate(dateOfBirth);
}

然后在您的 createuser 方法中,您可以直接自己调用此方法:

public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
                        [ValidateParameter(typeof(EmailValidator))] Email email,
                        [ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
    ValidateCreateUser(name, email, dateOfBirth);  // You'd add this line yourself
    User user = new(name, email, dateOfBirth);
    _userRepository.Add(user);
    return user;
}

这是否是一个足够成功的结果,只有您可以说。

如果您想准确地找到所希望的解决方案,恐怕您在评论中的怀疑是您必须求助于Fody是准确的。创建自定义FODY插件需要对Fody和C#IL有相当深的了解。

无耻的插头:我维护了一个名为 lyea 的fody库这将使您很容易通过 method interceptors> method Interpectors

Unfortunately, the short answer is that it will not be possible to arrive at the exact solution you are hoping for with source generators. The reason is that one of the absolute design philosophies of source generators (which I find dismaying, but can understand the rationale) was to actively disallow mutation of existing source files through the use of source generators. To put it another way, you can't actually modify the code of any of your hand-written classes. Source generators are strictly additive. The reason it can still be very powerful is through the use of partial classes (a type whose definition is declared in multiple files).

With that preamble out of the way, let's look a bit more closely at your exact use-case. You have this method:

public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
                        [ValidateParameter(typeof(EmailValidator))] Email email,
                        [ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
    User user = new(name, email, dateOfBirth);
    _userRepository.Add(user);
    return user;
}

And you want to turn it into this method:

public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
                        [ValidateParameter(typeof(EmailValidator))] Email email,
                        [ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
    Activator.CreateInstance<NameValidator>().Validate(name);
    Activator.CreateInstance<EmailValidator>().Validate(email);
    Activator.CreateInstance<AdultValidator>().Validate(dateOfBirth);
    User user = new(name, email, dateOfBirth);
    _userRepository.Add(user);
    return user;
}

As you can see, the outcome you desire requires modifying your CreateUser method, which isn't possible.

One solution that will get you half-way there would be to generate a custom validate method for any method with a parameter decorated with the ValidateParameter attribute. For example, you could generate this method:

// Generated
private void ValidateCreateUser(Name name, Email email, DateOfBirth dateOfBirth)
{
    Activator.CreateInstance<NameValidator>().Validate(name);
    Activator.CreateInstance<EmailValidator>().Validate(email);
    Activator.CreateInstance<AdultValidator>().Validate(dateOfBirth);
}

Then in your CreateUser method you would be able to call this method directly yourself:

public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
                        [ValidateParameter(typeof(EmailValidator))] Email email,
                        [ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
    ValidateCreateUser(name, email, dateOfBirth);  // You'd add this line yourself
    User user = new(name, email, dateOfBirth);
    _userRepository.Add(user);
    return user;
}

Whether this is a sufficiently successful outcome only you can say.

If you want to get to exactly the solution you were hoping for, I'm afraid your suspicion in the comments that you'd have to resort to Fody is accurate. Creating a custom Fody plugin requires a pretty deep understanding of both Fody and the C# IL.

Shameless plug: I maintain a Fody library called Someta that would make it pretty easy for you to accomplish this via method interceptors.

将代码添加到使用属性装饰的参数的方法

忆依然 2025-02-18 08:45:58

在这种情况下,刚刚添加了一些CSS的技巧,添加了 burgeropen 此类为身体元素

body.burgerOpen {
    overflow: hidden;
}

尝试以下演示

const burger = document.querySelector('#burger')

const tl = gsap.timeline()

tl.to('.menu-link', {
    translateY: '100%',
    duration: 0.5,
})

tl.to('.menu-overlay', {
    width: '0'
})


burger.addEventListener('click', () => {
    tl.reversed(!tl.reversed());
    $('body').toggleClass('burgerOpen');
})
:root {
    --zIndex-overlay: 900;
    --zIndex-navbar: 905;
    --colors-text: white;
    --colors-background: black;
    --colors-contast: #f4e285;
}
body {
    color: var(--colors-text);
    background-color: #304a36;
    font-family: "Prompt", sans-serif;
    font-variant-ligatures: common-ligatures;
}
*, *::before, *::after {
    border-width: 0;
    border-style: solid;
    box-sizing: border-box;
    word-wrap: break-word;
}
a {
    background-color: transparent;
    color: inherit;
    -webkit-text-decoration: inherit;
    text-decoration: inherit;
}
.menu-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: auto;
    bottom: 0;
    z-index: var(--zIndex-overlay);
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}
.menu-content {
    width: 50%;
    height: 100%;
    overflow-x: hidden;
    position: relative;
    display: flex;
    align-items: center;
    transition-delay: 0.1s;
    background-color: var(--colors-background);
}
.menu-list {
    list-style: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding-left: 10%;
}
.menu-list li {
    width: fit-content;
    overflow: hidden;
}
.menu-link {
    font-size: 3.5rem;
    display: inline-block;
    transform: translateY(0);
}
.menu-link:hover {
    color: white;
    -webkit-text-fill-color: rgba(255, 255, 255, 0);
    -webkit-text-stroke-width: 1px;
    -webkit-text-stroke-color: #fff;
}
.menu-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 0 0 10% 10%;
}
.menu-footer span {
    color: var(--colors-contast);
}
.title {
    letter-spacing: 0.02em;
    font-weight: 900;
    font-size: 3rem;
    text-transform: uppercase;
}
.menu-social-links {
    font-size: 13px;
    margin-block: 0.4em 0.7em;
    overflow-x: hidden;
    white-space: nowrap;
}
.menu-social-links a:hover {
    text-decoration: underline;
}
@media screen and (max-width: 786px) {
    .menu-content {
        width: 100%;
    }
}
button[id='burger'] {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}
body{
    height: 1500px;
}
body.burgerOpen {
    overflow: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.co/gsap@3/dist/gsap.min.js"></script>
<div class='menu-overlay'>
    <div class='menu-content'>
        <ul class='menu-list'>
            <li>
                <a href='' class='menu-link title'>About</a>
            </li>
            <li>
                <a href='' class='menu-link title'>Projects</a>
            </li>
            <li>
                <a href='' class='menu-link title'>Contact</a>
            </li>
        </ul>
    </div>
</div>
<button id='burger'>Burger</button>

just added some css trick in this case, added burgerOpen this class to body element

body.burgerOpen {
    overflow: hidden;
}

Try below demo

const burger = document.querySelector('#burger')

const tl = gsap.timeline()

tl.to('.menu-link', {
    translateY: '100%',
    duration: 0.5,
})

tl.to('.menu-overlay', {
    width: '0'
})


burger.addEventListener('click', () => {
    tl.reversed(!tl.reversed());
    $('body').toggleClass('burgerOpen');
})
:root {
    --zIndex-overlay: 900;
    --zIndex-navbar: 905;
    --colors-text: white;
    --colors-background: black;
    --colors-contast: #f4e285;
}
body {
    color: var(--colors-text);
    background-color: #304a36;
    font-family: "Prompt", sans-serif;
    font-variant-ligatures: common-ligatures;
}
*, *::before, *::after {
    border-width: 0;
    border-style: solid;
    box-sizing: border-box;
    word-wrap: break-word;
}
a {
    background-color: transparent;
    color: inherit;
    -webkit-text-decoration: inherit;
    text-decoration: inherit;
}
.menu-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: auto;
    bottom: 0;
    z-index: var(--zIndex-overlay);
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}
.menu-content {
    width: 50%;
    height: 100%;
    overflow-x: hidden;
    position: relative;
    display: flex;
    align-items: center;
    transition-delay: 0.1s;
    background-color: var(--colors-background);
}
.menu-list {
    list-style: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding-left: 10%;
}
.menu-list li {
    width: fit-content;
    overflow: hidden;
}
.menu-link {
    font-size: 3.5rem;
    display: inline-block;
    transform: translateY(0);
}
.menu-link:hover {
    color: white;
    -webkit-text-fill-color: rgba(255, 255, 255, 0);
    -webkit-text-stroke-width: 1px;
    -webkit-text-stroke-color: #fff;
}
.menu-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 0 0 10% 10%;
}
.menu-footer span {
    color: var(--colors-contast);
}
.title {
    letter-spacing: 0.02em;
    font-weight: 900;
    font-size: 3rem;
    text-transform: uppercase;
}
.menu-social-links {
    font-size: 13px;
    margin-block: 0.4em 0.7em;
    overflow-x: hidden;
    white-space: nowrap;
}
.menu-social-links a:hover {
    text-decoration: underline;
}
@media screen and (max-width: 786px) {
    .menu-content {
        width: 100%;
    }
}
button[id='burger'] {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}
body{
    height: 1500px;
}
body.burgerOpen {
    overflow: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.co/gsap@3/dist/gsap.min.js"></script>
<div class='menu-overlay'>
    <div class='menu-content'>
        <ul class='menu-list'>
            <li>
                <a href='' class='menu-link title'>About</a>
            </li>
            <li>
                <a href='' class='menu-link title'>Projects</a>
            </li>
            <li>
                <a href='' class='menu-link title'>Contact</a>
            </li>
        </ul>
    </div>
</div>
<button id='burger'>Burger</button>

Smooth -Scrollbar.js-打开全屏菜单时禁用滚动,菜单关闭时激活

忆依然 2025-02-17 17:54:34

给任何可能有同样问题的人。我设法将文件上传到我的S3存储桶中。

在github上环顾四周之后,有一个提交不合并会给实际错误提供:
'https://bucket.s3.region.amazonaws.com/file.ext上执行“ putoBject”的错误“ putoBject”; AWS http错误:卷曲错误60:SSL证书问题:无法获得本地发行者证书(请参阅 https://curl.haxx.se/libcurl/c/libcurl-errors.html )for https://bucket.s3.region.amazonaws.com/file.ext'

解决该问题:
我对这个问题有一个非常简单的解决方案。您可以在没有任何证书文件的情况下执行此操作。

在laravel root文件夹中 - &gt; vender-&gt; guzzlehttp-&gt; guzzle-&gt; SRC

Open Client.php

查找$ defaults数组。看起来像这样。

$defaults = [
    'allow_redirects' => RedirectMiddleware::$defaultSettings,
    'http_errors'     => true,
    'decode_content'  => true,
    'verify'          => true,
    'cookies'         => false
];

现在的主要工作是更改验证密钥的值。

'verify'          => false,

因此,此后,它不会检查SSL证书是否有卷曲请求。该解决方案对我有用。经过大量研究,我发现了这个解决方案。

注意:'verify'=&gt; false 可以在任何实时或开发服务器中创建安全问题。不要在服务器上尝试此操作。该解决方案仅适用于本地系统。
答案在这里找到:

To anyone who might have the same problem. I managed to upload a file to my s3 bucket.

After looking around on the github, there was a commit not merged that would give the actual error which was :
'Error executing "PutObject" on "https://bucket.s3.region.amazonaws.com/file.ext"; AWS HTTP error: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://bucket.s3.region.amazonaws.com/file.ext'

To resolve that issue :
I have a very Simple Solution to this problem. You can do this without any certificate file.

Go on Laravel Root Folder -> Vender -> guzzlehttp -> guzzle -> src

open Client.php

find $defaults Array . that looks like this way.

$defaults = [
    'allow_redirects' => RedirectMiddleware::$defaultSettings,
    'http_errors'     => true,
    'decode_content'  => true,
    'verify'          => true,
    'cookies'         => false
];

Now main Job is to change value of verify key.

'verify'          => false,

So After this, it will not check SSL Certificate for CURL Request. This Solution works for me. I find this solution after much research.

Note: 'verify' => false can create a security issue in any Live or Development server. Do not try this on Server. This solution is only for Local System.
Answer found here : AWS SSL security error : [curl] 60: SSL certificate prob...: unable to get local issuer certificate

Laravel 9访问AWS S3-位置Unabletowritefile

忆依然 2025-02-17 11:11:01

您只能在客户端中使用路由器对象。在 getserversideprops()中,您可以使用上下文

您可以使用 context.query.id

export const getServerSideProps = async (context) => {
  const { query } = context;
  const { id } = query;

source

You can only have the router object in the client. In getServerSideProps(), you can use context though.

You can use context.query.id:

export const getServerSideProps = async (context) => {
  const { query } = context;
  const { id } = query;

Source

为什么我不能在Next.js中调用userouter钩子getserversideprops

忆依然 2025-02-17 09:41:28

一个解决方法是删除首选项文件:

~Library/Application Support/BraveSoftware/Brave-Browser/Default/Preferences

导航到〜库:打开查找器,保持“选项”,然后单击菜单上的“转到”菜单。

One workaround is to delete the Preferences file:

~Library/Application Support/BraveSoftware/Brave-Browser/Default/Preferences

To Navigate to ~Library: Open Finder, hold 'option' and click in menu on 'go to'

勇敢的浏览器在开始时崩溃了

忆依然 2025-02-17 06:26:18

这是因为您仅定义一个函数而不将其调用代码中的任何位置,

还可以确保在HTML中使用JavaScript文件。了解更多。 https://wwwwwww.w3schools.com/tags/tags/tags/tags/att_script_src.src_src.asp

function click(){
    console.log("Test");
}
//Call this function
click();

javascript在这里: javascript函数

It is because you are only defining a function and not calling it anywhere in the code

Also make sure use Add a javascript file to your html. Learn more. https://www.w3schools.com/tags/att_script_src.asp

function click(){
    console.log("Test");
}
//Call this function
click();

Learn more about Javascript here : Javascript function

我无法称呼外部JavaScript功能

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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