北座城市

文章 评论 浏览 32

北座城市 2025-02-19 19:25:53

您可以通过替换对象(因此与范围的领带)来解决这个问题:

def foo(a=[]):
    a = list(a)
    a.append(5)
    return a

丑陋,但可以使用。

You can get round this by replacing the object (and therefore the tie with the scope):

def foo(a=[]):
    a = list(a)
    a.append(5)
    return a

Ugly, but it works.

&quot“至少惊讶”和可变的默认论点

北座城市 2025-02-18 21:40:52

迈克尔·李维(Michael Levi)的建议,它在我的项目中对我有用,并在导入JSON文件时以这种方式应用了它:

import * as fs from 'fs';
import * as path from 'path';
const filePath = path.join(process.cwd(), './src/api/send-message/conf/conf.json');
const configFIle = fs.readFileSync(filePath, 'utf-8').toString();
export const config = JSON.parse(configFIle);

Michael Levi's recommendation, it worked for me in my project and I applied it in this way as I import a json file:

import * as fs from 'fs';
import * as path from 'path';
const filePath = path.join(process.cwd(), './src/api/send-message/conf/conf.json');
const configFIle = fs.readFileSync(filePath, 'utf-8').toString();
export const config = JSON.parse(configFIle);

Nestjs读取文件 - 没有这样的文件或目录

北座城市 2025-02-18 17:18:46

您应该能够使用pyproj的 /code> 类,这是Metpy在引擎盖下用来计算Eg lat_lon_grid_deltas 的方法。我认为这样的事情会起作用:

import pyproj
geod = pyproj.Geod(ellps='sphere')
_, _, dist = geod.inv(cross['longitude'][0], cross['latitude'][0],
                      cross['longitude'], cross['latitude'])

我实际上还没有尝试过该代码,因此您可能需要将Xarray dataArray s转换为numpy Plain阵列。

You should be able to do this using PyPROJ's Geod class, which is what MetPy uses under the hood to calculate e.g. lat_lon_grid_deltas. Something like this I think will work:

import pyproj
geod = pyproj.Geod(ellps='sphere')
_, _, dist = geod.inv(cross['longitude'][0], cross['latitude'][0],
                      cross['longitude'], cross['latitude'])

I haven't actually tried that code, so you may need to convert the xarray DataArrays into numpy plain arrays.

将LAT/LON坐标转换为米/公里,以用于Metpy HRRR横截面

北座城市 2025-02-18 13:40:02

看起来您的范围是空的。您可能需要在范围参数中添加OpenID和配置文件才能获取ID令牌。

如果您也可以显示您的授权请求(该指南中的步骤1),这将有所帮助。

然后,Ya,Umakanth对刷新令牌说了什么。需要将Offline_access添加到范围。

包括offline_access获取刷新令牌(请确保在应用程序设置中启用了允许离线访问字段)。

It looks like your scope is empty. You might need to add openid and profile to the scope param to get the id token.

It would help if you could show your authorize request too (step 1 in that guide).

Then, ya, what Umakanth said about the refresh token. Need to add offline_access to the scope.

Include offline_access to get a refresh token (make sure that the Allow Offline Access field is enabled in the Application Settings).

AUTH0仅从令牌终点接收访问令牌

北座城市 2025-02-18 13:01:23

现在,您可以使用迈克尔·米尔顿(Michael Milton)(@多聚元素)要在Python中进行ID映射,请参见公告。该软件包还可以与Uniprot在2022 REST API中的新产品配合使用。

示例在原始帖子中使用Unipredsed:

from unipressed import IdMappingClient
request = IdMappingClient.submit(
    source="UniProtKB_AC-ID", dest="PDB", ids={"A0A0M3KKX3"}
)
list(request.each_result())

结果:

[{'from': 'A0A0M3KKX3', 'to': '4U7N'},
 {'from': 'A0A0M3KKX3', 'to': '4U7O'},
 {'from': 'A0A0M3KKX3', 'to': '4ZKI'}]

请参阅使用它进行三个人类基因的ID映射到Uniprot标识符/登录代码在这里。该帖子还具有链接,以获取有关未经许可的软件包的更多信息,以及用于锻炼 source 和目标( dest )详细信息的建议。

查看更多示例使用Unipredsed访问Uniprot的新REST API 和在底部来自“从 - 到”结果的熊猫数据框。

更新:我做了一个存储库,允许在浏览器中运行此和其他未经许可的示例,而无需在计算机上安装任何内容。首先,Go 在这里,然后单击任何'启动binder '徽章。

You can now use the Unipressed package by Michael Milton (@multimeric) to do ID mapping in Python, see the announcement. This package also works with UniProt's new in 2022 REST API.

Example from original post using Unipressed:

from unipressed import IdMappingClient
request = IdMappingClient.submit(
    source="UniProtKB_AC-ID", dest="PDB", ids={"A0A0M3KKX3"}
)
list(request.each_result())

Result:

[{'from': 'A0A0M3KKX3', 'to': '4U7N'},
 {'from': 'A0A0M3KKX3', 'to': '4U7O'},
 {'from': 'A0A0M3KKX3', 'to': '4ZKI'}]

See an example of using it to do ID mapping of three human genes to UniProt identifier / accession code here. That post also has links for more information about the Unipressed package and advice for working out source and destination (dest) details.

See more examples of using Unipressed to access Uniprot's new REST API here in my reply to Biostar's post 'Accessing UNIPROT using REST API', and at the bottom here includes making a Pandas dataframe from the 'from - to' results.

UPDATE: I made a repo that allows running this and other Unipressed examples right in your browser without installing anything on your machine. To get started, go here and click any 'launch binder' badge.

HTTP错误405用于以前用于查询Uniprot ID映射的代码

北座城市 2025-02-18 12:47:18

创建一个状态变量:

import React ,{useState} from "react";
[visible,setVisible]=useState(false);

根据您想要的事件进行更改

create a state variable:

import React ,{useState} from "react";
[visible,setVisible]=useState(false);

change it depending on the event that you want

如何在Reactjs中进行表演/隐藏

北座城市 2025-02-18 08:43:24

一种简单的方法是使用 str_extract_all 获取空间之前的数字:

library(stringr)
str_extract_all(text, "(?<= )[0-9]+")
[[1]]
[1] "24095"

[[2]]
[1] "31130"

[[3]]
[1] "39420"

[[4]]
[1] "41690"

[[5]]
[1] "37430"

[[6]]
[1] "36490

One simple way is to use str_extract_all to get numbers preceded by a space:

library(stringr)
str_extract_all(text, "(?<= )[0-9]+")
[[1]]
[1] "24095"

[[2]]
[1] "31130"

[[3]]
[1] "39420"

[[4]]
[1] "41690"

[[5]]
[1] "37430"

[[6]]
[1] "36490

更好的方法列表?

北座城市 2025-02-18 04:35:17

我已更新了我的nodejs版本18.18,然后发生了此错误。我将WebPack与5版本的版本和7版一起使用。但是我没有SASS模块。

对我来说,解决方案是安装SASS。

npm i sass-save-dev

I was updated my nodejs version 18.18 then this error occured to me. I'm using webpack with the version of 5 and node-sass with the version of 7. But I had no sass module.

The solution for me was installing the sass.

npm i sass --save-dev

SASS尚未支持您当前的环境:Windows 64位具有不支持的运行时(93)

北座城市 2025-02-18 03:09:16

您的排序功能可能是将空字符分类为0。

Your sorting function is probably sorting the null character to position 0.

在C中,当我使用%s打印字符阵列的内容时,它会打印为空白,但是当我循环循环并打印每个字符时,它起作用

北座城市 2025-02-17 01:33:03

这不是进行身份验证的最佳方法,因为MERN开发人员相反,您最好使用cookie从首先获得请求中获取身份验证信息,
您可以在Passport.js的帮助下轻松执行此操作,
祝你好运...

this is not the best way to do Authentication as MERN developer instead you have better to use cookies to get authentication info from first get request ,
you can do that easily with help of passport.js ,
Good luck...

仅当用户登录时,如何在MERN中显示特定页面

北座城市 2025-02-16 23:36:59

您有以下选项:

  1. 配置 bsondefaults.guidrepresentationmode = guidrePresentationMode.v3; 。在这种情况下,您将使用文档中指定的子类型(或通过属性在最后查看文档)。如果是 csuuid - ,那么子类型为3, uuid -4。

  2. 配置 guidserialization.unspecified 。例如,在收集期间创建:

      db.getCollection&lt; bsondocument&gt;(
        “ coll”, 
        new Mongocollectionsettings(){guidRepresentation = guidRepresentation.unspecified});
     

这种情况类似于#1,我们从文档中获得了子类型,但仅适用于特定集合

  1. 配置 guid> guidserialization.standard 强迫使用此特定集合的子类型,无论 subtype 在文档中提供:

      var coll = db.getCollection&lt; bsondocument&gt;(“ coll”,new mongocollectionsettings(){guidrePresentation = guidrepresentation.standard});
    var testjson =“ [{'_id':csuuID('609e26f6-dbad-4dba-ba37-4e37-4e35f0e348ec'),'name':'data1'},{'_ id'} 4E35F0E348FF'),'名称':'data2'}]”;
    Coll.InsertMany(bsonserializer.deserialize&lt; bsondocument []&gt;(testjson)); //插入子类型为4(UUID/标准)
     

您还可以在全球范围内配置GuidRepresentation: bsondefaults.guidrepresentation = guidrepresentation.standard; 。在这种情况下,您将默认情况下强制使用此表示形式(对于guidrepresentationmode.v2默认模式),

您可以找到详细信息在这里

You have the following options:

  1. Configure BsonDefaults.GuidRepresentationMode = GuidRepresentationMode.V3;. In this case, you will work with subTypes specified in the document (or via attributes see the doc in the end). If it's CSUUID - then subType is 3, UUID - 4.

  2. Configure GuidSerialization.Unspecified. For example during collection creating:

    db.GetCollection<BsonDocument>(
        "coll", 
        new MongoCollectionSettings() { GuidRepresentation = GuidRepresentation.Unspecified});
    

this case is similar to #1 where we get used subType from a document, but only for a particular collection

  1. Configuring GuidSerialization.Standard to force using this particular subType for a collection regardless a subType provided in the document:

    var coll = db.GetCollection<BsonDocument>("coll", new MongoCollectionSettings() { GuidRepresentation = GuidRepresentation.Standard});
    var testJson = "[{'_id':CSUUID('609e26f6-dbad-4dba-ba37-4e35f0e348ec'),'name':'Data1'},{'_id':CSUUID('609e26f6-dbad-4dba-ba37-4e35f0e348ff'),'name':'Data2'}]";
    coll.InsertMany(BsonSerializer.Deserialize<BsonDocument[]>(testJson)); // inserted subType is 4 (UUID/Standard)
    

You also can configure GuidRepresentation globally like: BsonDefaults.GuidRepresentation = GuidRepresentation.Standard;. In this case you will force using this representation by default everywhere (for GuidRepresentationMode.V2 which is default mode)

You can find details here

JSON必须如何将MongoDB迫使Bindata子类型4

北座城市 2025-02-16 23:35:00

原因:

简单地说,现在不支持。

您正在使用运行时变量。

但是运行时间变量不支持服务连接或Azure订阅。该变量将在运行时间初始化。

您可以按照下面的方法进行使用以使用不同的服务连接:

但仍然需要点,在管道运行之前,参数会扩展,硬码不可避免,这是设计。

在此官方文件中也很明显:

https://learn.microsoft.com/en-us/en-us/azure/azure/devops/devops/devops/pipelines/pipelines/library/library/service/service -endpoints?view = azure-devops&amp; tabs = yaml#use-a-service-connection

Reason:

Simply say, not support now.

You are using a runtime variable.

But run time variables aren't supported for service connection OR azure subscription. The variable will get initialized at the run time.

https://github.com/microsoft/azure-pipelines-tasks/issues/10376#issuecomment-514477023

You can follow below method to use different service connection:

https://stackoverflow.com/a/57520153/6261890

But still need point that, parameters are expanded just before the pipeline runs, hardcode the specific service connection is unavoidable, this is by design.

Also clearly in this official document:

https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#use-a-service-connection

enter image description here

Azure DevOps NPM身份验证任务终点

北座城市 2025-02-16 23:09:04

C ++ 20和C ++ 23

对于感兴趣的人,我将从现代C ++的角度提供完整的答案。
C ++ 20和C ++ 23之间只有很小的差异。

为什么我们需要模板 typename

基本问题是,没有其他提示,编译器无法理解C ++。正式地,C ++语法是上下文敏感的,您需要提供其他disamuguators。

int x, y;

template <typename T>
void f() {
    T::type * x;
    // if 'type' is a type, then this is declaring 'x' as a pointer to 'T::type'
    // if 'type' is a static data member, this is multiplying 'x' with 'T::type'
    typename T::type* x; // unambiguous

    T::templ<0>> y;
    // if 'templ' is a template, then this is ( (T::templ<0>) > y) )
    // if 'templ' is a static data member, this is ((T::templ < 0) >> y)
    T::template templ<0>> y; // unambiguous
}

如您所见,问题是 t 可以是任何类型,因此 t ::类型 t :: Templ 可以是任何东西:静态数据成员,类型别名,模板,成员函数模板,非模板成员函数等。
这是因为 t :: Type t :: Templ 相关类型,取决于模板参数 t

C ++通过将 t ::某物作为数据成员或成员函数来解决这种歧义。您指定 template typename 被解释为类型或模板的东西。

依赖类型和表达式

概括术语的

  • t :: Type 之类的类型是依赖性模板参数 t
  • (x+y)之类的表达 - 依赖性如果 x y 依赖于模板类型参数。
  • (x+y)之类的表达 - 依赖性如果 x y 依赖于非类型模板参数。

通常,当涉及依赖类型时, typename template 是必要的。如果从依赖的表达式形成依赖类型,例如 decltype(x + y)::类型也可能发生这种情况。

模板 typename 关键字如何工作?

这些关键字有时被称为Disamamutorator,并告知编译器您需要类型或模板而不是数据成员/成员函数。

typename disambuator

typename 被准备到 typename特定词,并适用于需要歧义的名字。例如:

typename T::type // interpreted as type
   │        ▲
   └────────┘

typename T::type::type // interpreted as type
   │              ▲
   └──────────────┘

typename T::templ<0>::type // interpreted as non-type
   │        ▲
   └────────┘

typename T::template templ<0>::type // interpreted as a type
   │                           ▲
   └───────────────────────────┘

template disambiguator

template 合格 - id ,使其如此&lt; 不是被解释为不太少的操作员,而是一个开始 template-argument-list

T::templ<0> // '<' is interpreted as less-than

T::template templ<0> // '<0>' is interpreted as template-argument-list

T::template templ<0>::templ<1> // '<1' is interpreted as less than 1

typename T::templ<0> // '<0>' is interpreted as template-argument-list
   │        ▲        // due to type-only context
   └────────┘

如上一个示例所示, typename 可以使模板不必要,因为 templ&lt; 只能将其解释为a template-argument-list 如果 templ 必须是一种类型。

模板有另一种(现在已弃用)的使用,即提供template-template参数:

template <template <typename> typename TT>
void f();

template <typename T>
void g() { f<T::template templ>(); }

此用途已被弃用,因为始终很明显&lt; ...&gt; 是a template-argument-list 在此上下文中和模板是毫无意义的。

C ++ 20和C ++ 23放松是多少?

模板 typename 的许多用途现已变得不必要。如上所述, typename 有时制作模板不必要。更一般地, typename 模板可以省略仅类型的上下文

例如:

using T = T::type;         // OK
static_cast<T::type>(...); // OK
std::is_const_v<T::type>;  // OK
void f(T::type t);         // OK

这些用途和其他用途将在C ++ 20之前被不良形成。 C ++ 23添加了 template typename 之间的交互,这消除了进一步的用途。
相关建议是:

,通常会努力消除 typename and code>和模板的所有位置并不是真正必要的。
请注意, template typename 并不总是需要歧义,而只是有助于解析。例如:

typename T::a::b::c::d::e::f::g::h::i::j x,

在这里,我们仍然需要 typename ,尽管明确是声明。否则,知道 a 是一种类型和 a :: 是有效的。

因此,在这种情况下, typename 不太可能成为可选的。

C++20 and C++23

For those interested, I will provide complete answer from a modern C++ perspective.
There are only minor differences between C++20 and C++23.

Why do we need template and typename?

The basic issue is that C++ can't be understood by the compiler without some additional hints. Formally, the C++ grammar is context-sensitive, and you need to provide additional disambiguators.

int x, y;

template <typename T>
void f() {
    T::type * x;
    // if 'type' is a type, then this is declaring 'x' as a pointer to 'T::type'
    // if 'type' is a static data member, this is multiplying 'x' with 'T::type'
    typename T::type* x; // unambiguous

    T::templ<0>> y;
    // if 'templ' is a template, then this is ( (T::templ<0>) > y) )
    // if 'templ' is a static data member, this is ((T::templ < 0) >> y)
    T::template templ<0>> y; // unambiguous
}

As you can see, the problem is that T can be any type, and so T::type and T::templ can be anything: static data members, type aliases, templates, member function templates, non-template member functions,etc.
This is because T::type and T::templ are dependent types, depending on the template parameter T.

C++ resolves this ambiguity by treating T::something as a data member or member function when in doubt. Only if T is known, or if you specify template or typename, is something interpreted as a type or template.

Dependent types and expressions

To sum up the terminology:

  • A type such as T::type is dependent on a template parameter T.
  • An expression such as (x + y) is type-dependent if x or y depend on a template type parameter.
  • An expression such as (x + y) is value-dependent if x or y depend on a non-type template parameter.

Generally, typename and template become necessary when dependent types are involved. This can also happen if a dependent type is formed from a dependent expression, such as decltype(x + y)::type.

How do the template and typename keywords work?

These keywords are sometimes called disambiguators, and inform the compiler that you want a type or a template instead of a data member/member function.

The typename disambiguator

typename is prepended to a typename-specifier and applies to the first name that needs disambiguation. For example:

typename T::type // interpreted as type
   │        ▲
   └────────┘

typename T::type::type // interpreted as type
   │              ▲
   └──────────────┘

typename T::templ<0>::type // interpreted as non-type
   │        ▲
   └────────┘

typename T::template templ<0>::type // interpreted as a type
   │                           ▲
   └───────────────────────────┘

The template disambiguator

template acts as "glue" within a qualified-id which makes it so < is not interpreted as the less-than operator, but the beginning of a template-argument-list.

T::templ<0> // '<' is interpreted as less-than

T::template templ<0> // '<0>' is interpreted as template-argument-list

T::template templ<0>::templ<1> // '<1' is interpreted as less than 1

typename T::templ<0> // '<0>' is interpreted as template-argument-list
   │        ▲        // due to type-only context
   └────────┘

As seen in the last example, typename can make template unnecessary because templ< can only be interpreted as a template-argument-list if templ must be a type.

There is another (now deprecated) use of template, namely for providing template-template arguments:

template <template <typename> typename TT>
void f();

template <typename T>
void g() { f<T::template templ>(); }

This use has been deprecated because it is always clear that <...> is a template-argument-list in this context, and template is pointless.

What are the C++20 and C++23 relaxations?

Many uses of template and typename have now become unnecessary. As seen above, typename sometimes makes template unnecessary. More generally, typename and template can be omitted in a type-only context.

For example:

using T = T::type;         // OK
static_cast<T::type>(...); // OK
std::is_const_v<T::type>;  // OK
void f(T::type t);         // OK

These and other uses would have been ill-formed prior to C++20. C++23 has added the interaction between template and typename which eliminates further uses.
The relevant proposals are:

In general, there is an effort to eliminate all the places where typename and template aren't truly necessary.
Note that template and typename are not always necessary for disambiguation, but merely assist in parsing. For example:

typename T::a::b::c::d::e::f::g::h::i::j x,

Here, we still need typename despite this unambiguously being a declaration. Otherwise, it would require arbitrarily look-ahead to know that a is a type and a:: is valid.

Therefore, it is unlikely that typename will ever become optional in this context.

我必须在何处以及为什么要放置“模板”。和“ typename”关键字?

北座城市 2025-02-16 11:21:37

也许以下是您需要的。我对Sec.Gov不熟悉,因此您必须


根据您对该网站的经验(例如文档ID)提供输入和编辑。我添加了一种方法,可以根据我在Chrome的调试器控制台的响应标头中看到的cookie来获取cookie。 This is the cookie I got back that expires in about 8 hours (ak_bmsc=5EF62DAF005C6A95904F7ED7CCED9D78~000000000000000000000000000000~YAAQFC0tF+cmqpSBAQAAGJavoxCRBM3XBiKPn8e24CgXNLo+q6fI5C4VOJAkqdQdlHpsf2p08VHMcp10NI9rhpcoiI1i8CFQEvrR9b1SyCA9wN6sCAhoioLMvuqsYCw​​vVr21+AXb+XTvs65Kc70n5P7bEDYsvvWAFC5L+jdAQ+mLlcDTWF7twH2Lg1vYQAbxcje8OnbTDSldM2IGsWltH4ii1h73ZYPqlcTMWf/uh9AbKAlk+x50YQ1bUkTGdl+HZgulE6crPxHOqy4Q2PbXi2QwgylnYG9VTkmMzCnLi+clfWFQVuTz1i85x+YO9B4/eV3VHTYgFFk/SEmerp0kZbmzhT/RdFneLSaOOjg0KfHFR0tsKrlY1Ys= ;),这就是为什么每次执行这些请求的一批时都希望获得新的cookie的原因。我在在线Regex测试仪上测试了它,因此应该可以使用。

; GET COOKIE IDEA (EDIT)
Global reqCookie
secReq := getReq("www.sec.gov")
If (foundCookie := regexMatch(secReq.getAllResponseHeaders(), "U)Set\-?Cookie:[\s\r\n]+\K(\S+\;)", cookie)) {
    reqCookie := cookie1
} Else {
    Msgbox, Didn't find a cookie!
    Return
}

itWorked := urlDownloadToFileSEC(A_Desktop . "\SEC Download.xml", "1548527/000154852712000001")

Msgbox % (itWorked ? "It Worked!" : "Something went wrong")
Return

urlDownloadToFileSEC(FilePath, docID, timeoutMS=60000, bAsync=false)
    r := comObjCreate("WinHttp.WinHttpRequest.5.1")
    r.Open("GET", "https://www.SEC.gov/Archives/edgar/data/" . docID . "/xslFormDX01/primary_doc.xml", bAsync)
    r.SetTimeouts(timeoutMS, timeoutMS, timeoutMS, timeoutMS)
    r.SetRequestHeader("User-Agent", "Sample Company Name AdminContact@<sample company domain>.com")
     ; DO NOT KNOW WHAT YOU WOULD ACTUALLY WANT TO PUT IN THE ABOVE USER AGENT.
    r.SetRequestHeader("Accept-Encoding", "gzip, deflate")
    r.SetRequestHeader("Host", "www.sec.gov")
    r.SetRequestHeader("cookie", reqCookie)
    r.Send()
    if (bAsync) {
        Return r
    ; you have to use WaitForResponse method to check for it later.
    }
    if (r.Status="200") {
        fileText := r.ResponseText
        fileAppend, %fileText%, %filePath%
    } ; ERRORLEVEL CONTAINS WRITE SUCCESS.
    Return (r.Status="200" ? true : false)
 
 ; NEW FUNCTION!
getReq(URL, bAsync=false, timeouts=60000, reqHeadersMap="") {
    Req := comObjCreate("WinHttp.WinHttpRequest.5.1")
    Req.Open("GET", URL, bAsync)
    Req.SetTimeouts(timeouts, timeouts, timeouts, timeouts)
    if (isObject(reqHeadersMap)) {
        For key, value in reqHeadersMap {
            Req.SetRequestHeader(Key, Value)
        }
    }
    Req.Send()
    if (bAsync) {
        Return Req
    }
    ErrorLevel := (Req.Status==200 ? true : false)
    Return Req
}

Perhaps something like below is what you need. I have NO familiarity with SEC.gov, so you will


have to provide input and edits based on your experience with that website (like document ID). I added a method for getting a cookie that might work based on the cookie that I saw returned by sec.gov in the response headers in debugger console in Chrome. This is the cookie I got back that expires in about 8 hours (ak_bmsc=5EF62DAF005C6A95904F7ED7CCED9D78~000000000000000000000000000000~YAAQFC0tF+cmqpSBAQAAGJavoxCRBM3XBiKPn8e24CgXNLo+q6fI5C4VOJAkqdQdlHpsf2p08VHMcp10NI9rhpcoiI1i8CFQEvrR9b1SyCA9wN6sCAhoioLMvuqsYCwvVr21+AXb+XTvs65Kc70n5P7bEDYsvvWAFC5L+jdAQ+mLlcDTWF7twH2Lg1vYQAbxcje8OnbTDSldM2IGsWltH4ii1h73ZYPqlcTMWf/uh9AbKAlk+x50YQ1bUkTGdl+HZgulE6crPxHOqy4Q2PbXi2QwgylnYG9VTkmMzCnLi+clfWFQVuTz1i85x+YO9B4/eV3VHTYgFFk/SEmerp0kZbmzhT/RdFneLSaOOjg0KfHFR0tsKrlY1Ys=;), which is why you would want to get a new cookie each time you do a batch of these requests. I tested it on an online regex tester, so it should work.

; GET COOKIE IDEA (EDIT)
Global reqCookie
secReq := getReq("www.sec.gov")
If (foundCookie := regexMatch(secReq.getAllResponseHeaders(), "U)Set\-?Cookie:[\s\r\n]+\K(\S+\;)", cookie)) {
    reqCookie := cookie1
} Else {
    Msgbox, Didn't find a cookie!
    Return
}

itWorked := urlDownloadToFileSEC(A_Desktop . "\SEC Download.xml", "1548527/000154852712000001")

Msgbox % (itWorked ? "It Worked!" : "Something went wrong")
Return

urlDownloadToFileSEC(FilePath, docID, timeoutMS=60000, bAsync=false)
    r := comObjCreate("WinHttp.WinHttpRequest.5.1")
    r.Open("GET", "https://www.SEC.gov/Archives/edgar/data/" . docID . "/xslFormDX01/primary_doc.xml", bAsync)
    r.SetTimeouts(timeoutMS, timeoutMS, timeoutMS, timeoutMS)
    r.SetRequestHeader("User-Agent", "Sample Company Name AdminContact@<sample company domain>.com")
     ; DO NOT KNOW WHAT YOU WOULD ACTUALLY WANT TO PUT IN THE ABOVE USER AGENT.
    r.SetRequestHeader("Accept-Encoding", "gzip, deflate")
    r.SetRequestHeader("Host", "www.sec.gov")
    r.SetRequestHeader("cookie", reqCookie)
    r.Send()
    if (bAsync) {
        Return r
    ; you have to use WaitForResponse method to check for it later.
    }
    if (r.Status="200") {
        fileText := r.ResponseText
        fileAppend, %fileText%, %filePath%
    } ; ERRORLEVEL CONTAINS WRITE SUCCESS.
    Return (r.Status="200" ? true : false)
 
 ; NEW FUNCTION!
getReq(URL, bAsync=false, timeouts=60000, reqHeadersMap="") {
    Req := comObjCreate("WinHttp.WinHttpRequest.5.1")
    Req.Open("GET", URL, bAsync)
    Req.SetTimeouts(timeouts, timeouts, timeouts, timeouts)
    if (isObject(reqHeadersMap)) {
        For key, value in reqHeadersMap {
            Req.SetRequestHeader(Key, Value)
        }
    }
    Req.Send()
    if (bAsync) {
        Return Req
    }
    ErrorLevel := (Req.Status==200 ? true : false)
    Return Req
}

如何将AutoHotkey UrldownLoadTofile请求的请求标头设置为SEC?

北座城市 2025-02-16 07:16:36

这是一种可能的方法 - 仅根据索引替换文本,并在出现后不断更改索引。

Tested with Xcode 13.4 / iOS 15.5

demo

Main part:

private func next() {
    var next = textIndex + 1
    if next == texts.count {
        next = 0
    }
    withAnimation(Animation.linear(duration: 2)) {
        textIndex = next
    }
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        self.next()
    }
}

and text itself

Text(texts[textIndex]).bold()
    .font(.title).id(textIndex)
    .onAppear(perform: {
        next()
    })

Here is a possible approach - just to replace Text depending on index and continuously change index after appear.

Tested with Xcode 13.4 / iOS 15.5

demo

Main part:

private func next() {
    var next = textIndex + 1
    if next == texts.count {
        next = 0
    }
    withAnimation(Animation.linear(duration: 2)) {
        textIndex = next
    }
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        self.next()
    }
}

and text itself

Text(texts[textIndex]).bold()
    .font(.title).id(textIndex)
    .onAppear(perform: {
        next()
    })

Test module on GitHub

有没有一种方法可以自动使用动画更改文本值?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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