歌入人心

文章 评论 浏览 32

歌入人心 2025-02-20 21:45:31

只需添加相关的标题,该网站似乎在没有有效标题的情况下阻止请求:

import requests

url = 'https://www.cmegroup.com/markets/energy/crude-oil/light-sweet-crude.quotes.html'
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
           'Accept-Encoding': 'gzip, deflate',
           'Accept-Language': 'en-US,en;q=0.9',
           'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'}

print(requests.get(url, headers=headers).text)

Just add relevant headers, the website seems to be blocking requests without valid headers:

import requests

url = 'https://www.cmegroup.com/markets/energy/crude-oil/light-sweet-crude.quotes.html'
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
           'Accept-Encoding': 'gzip, deflate',
           'Accept-Language': 'en-US,en;q=0.9',
           'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'}

print(requests.get(url, headers=headers).text)

Timeouterror:读取操作时机

歌入人心 2025-02-20 21:05:06

iiuc,您可以在(+)上使用自定义组和merge_asof,带有lone( - )值的背面插入:

cols = ['A', 'B', 'C', 'D', 'E']

df['ExecutionTimestamp'] = pd.to_datetime(df['ExecutionTimestamp'])

# identify + rows
m = df['F'].eq('(+)')

# merge
out = (pd
  .merge_asof(df[m].reset_index(), df[~m].reset_index(),
              by=cols, on='ExecutionTimestamp',
              direction='nearest', tolerance=pd.Timedelta('2.5min'),
              suffixes=(None, '_')
             )
  .assign(F=lambda d: np.where(d['F_'].isna(), d['F'], '(=)'),
          C=lambda d: np.where(d['F_'].isna(), d['C'], d['C']*2), 
         )
 )

# add missing (lone) (-) value
missing = df.index.difference(out[['index', 'index_']].stack())

out = (pd
       .concat([out.set_index('index'), df.loc[missing]])
       .drop(columns=['index_', 'F_'])
      )

输出:

      A      B    C         D        E    F  ExecutionTimestamp
15  130  3.123   77  0.975342  1.97808  (+) 2022-06-28 13:41:00
16  130  3.123  154  0.975342  1.97808  (=) 2022-06-28 16:41:00
17  130  3.223  152  0.975342  1.97808  (=) 2022-06-28 16:41:00

IIUC, you can use a custom group and a merge_asof on (+) with back insertion of the lone (-) values:

cols = ['A', 'B', 'C', 'D', 'E']

df['ExecutionTimestamp'] = pd.to_datetime(df['ExecutionTimestamp'])

# identify + rows
m = df['F'].eq('(+)')

# merge
out = (pd
  .merge_asof(df[m].reset_index(), df[~m].reset_index(),
              by=cols, on='ExecutionTimestamp',
              direction='nearest', tolerance=pd.Timedelta('2.5min'),
              suffixes=(None, '_')
             )
  .assign(F=lambda d: np.where(d['F_'].isna(), d['F'], '(=)'),
          C=lambda d: np.where(d['F_'].isna(), d['C'], d['C']*2), 
         )
 )

# add missing (lone) (-) value
missing = df.index.difference(out[['index', 'index_']].stack())

out = (pd
       .concat([out.set_index('index'), df.loc[missing]])
       .drop(columns=['index_', 'F_'])
      )

output:

      A      B    C         D        E    F  ExecutionTimestamp
15  130  3.123   77  0.975342  1.97808  (+) 2022-06-28 13:41:00
16  130  3.123  154  0.975342  1.97808  (=) 2022-06-28 16:41:00
17  130  3.223  152  0.975342  1.97808  (=) 2022-06-28 16:41:00

熊猫 - 基于重复和相反的存在的组 /聚集行

歌入人心 2025-02-20 14:25:15

Moultipolygon采用一系列环 孔列表元素,或一系列多边形。您可以做:

MultiPolygon((x, None) for x in jk['geometry'])

MultiPolygon(Polygon(x) for x in jk['geometry'])

MultiPolygon takes a sequence of rings and holes list tuples, or a sequence of polygons. You can either do:

MultiPolygon((x, None) for x in jk['geometry'])

or

MultiPolygon(Polygon(x) for x in jk['geometry'])

即使所有多边形都是有效的,无效的多角形值即使

歌入人心 2025-02-20 14:08:56

您在这里摧毁克隆。

if Plr['Backpack']:findFirstChild(v.Name) then
   Plr['Backpack'][v.Name]:Destroy()
end

You are destroying the clones here.

if Plr['Backpack']:findFirstChild(v.Name) then
   Plr['Backpack'][v.Name]:Destroy()
end

如果玩家死亡,但有同一工具的克隆,而不是所有克隆只保存1只有1个,我遇到问题,我该如何解决此问题?

歌入人心 2025-02-20 08:06:23

您可以使用掩码和布尔索引:

m = df['values'].eq(1)
df.loc[m.cumsum().le(4)&m, 'text'] += 'o'

输出:

  text  values
0   Ao       1
1    B       0
2    C       0
3    D       0
4   Eo       1
5   Fo       1
6    G       0
7   Ho       1
8    I       0
9    J       1

You can use a mask and boolean indexing:

m = df['values'].eq(1)
df.loc[m.cumsum().le(4)&m, 'text'] += 'o'

Output:

  text  values
0   Ao       1
1    B       0
2    C       0
3    D       0
4   Eo       1
5   Fo       1
6    G       0
7   Ho       1
8    I       0
9    J       1

过滤数据框后如何替换第一n行的值?

歌入人心 2025-02-20 07:04:29

在Angular应用程序中处理可观察到的正确方法是在不再需要的情况下取消订阅。

一般而言,我们订阅了组件内可观察的一个。因此,当您破坏组件时,必须取消订阅订阅,如下所示:

class MyComponent implements OnInit, OnDestroy {
    // Variable used to hold subscription
    private subscription: Subscription;

    ngOnInit() {
       // Save subscription in a variable
       this.subscription = anyObservable.subscribe(...);          
    }

    ngOnDestroy() {    
      // Unsubscribe when the subscription is no more needed
      this.subscription.unsubscribe();
    }
    
    ...
}

可以观察到可以在整个应用程序中生存下来,而其他人必须尽快取消订阅,但通常在OnInit上订阅并在Ondestroy方法上取消订阅解决大多数问题的好方法。

The correct way to handle observables in an angular application is to unsubscribe when they are no more needed.

Generally speaking we subscribe to an Observable inside a component. So when you destroy the component you must unsubscribe the subscription as follow:

class MyComponent implements OnInit, OnDestroy {
    // Variable used to hold subscription
    private subscription: Subscription;

    ngOnInit() {
       // Save subscription in a variable
       this.subscription = anyObservable.subscribe(...);          
    }

    ngOnDestroy() {    
      // Unsubscribe when the subscription is no more needed
      this.subscription.unsubscribe();
    }
    
    ...
}

There can be are observables that survive through the whole application lifetime, while others must be unsubscribed as soon as possible, but often subscribing on the onInit and unsubscribing on the onDestroy methods is a good approach to solve most of the problems.

在不重新加载应用程序的情况下清空应用程序中的所有可观察到

歌入人心 2025-02-20 05:23:08

您正在尝试使用旧的compctl方式,该方式与FZF-TAB无法使用。

用以下内容替换.zshrc中的配置:

# zsh parameter completion for the dotnet CLI

_dotnet_zsh_complete()
{
  local completions=("$(dotnet complete "$words")")

  # If the completion list is empty, just continue with filename selection
  if [ -z "$completions" ]
  then
    _arguments '*::arguments: _normal'
    return
  fi

  # This is not a variable assignment, don't remove spaces!
  _values = "${(ps:\n:)completions}"
}

compdef _dotnet_zsh_complete dotnet

https://learn.microsoft.com/en-us/dotnet/core/core/tools/enable-tab-autocomplete

You are trying to use the old compctl way, which does not work with fzf-tab.

Replace your config in .zshrc with this:

# zsh parameter completion for the dotnet CLI

_dotnet_zsh_complete()
{
  local completions=("$(dotnet complete "$words")")

  # If the completion list is empty, just continue with filename selection
  if [ -z "$completions" ]
  then
    _arguments '*::arguments: _normal'
    return
  fi

  # This is not a variable assignment, don't remove spaces!
  _values = "${(ps:\n:)completions}"
}

compdef _dotnet_zsh_complete dotnet

source: https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete

ZSH完成fzf-tab do do dotnet命令不使用

歌入人心 2025-02-19 22:39:44

您可以使用 badgedrawable 由材料组件库提供。

类似:

    fab.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            BadgeDrawable badgeDrawable = BadgeDrawable.create(MainActivity.this);
            badgeDrawable.setNumber(2);
            //Important to change the position of the Badge
            badgeDrawable.setHorizontalOffset(30);
            badgeDrawable.setVerticalOffset(20);

            BadgeUtils.attachBadgeDrawable(badgeDrawable, fab, null);

            fab.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });

在此处输入图像描述“

当前(1.3.0-Alpha02)半径,但是您可以在项目中覆盖此尺寸(dimens.xml):

<dimen name="mtrl_badge_with_text_radius">12dp</dimen>

“在此处输入图像说明”

You can use the BadgeDrawable provided by the Material Components Library.

Something like:

    fab.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            BadgeDrawable badgeDrawable = BadgeDrawable.create(MainActivity.this);
            badgeDrawable.setNumber(2);
            //Important to change the position of the Badge
            badgeDrawable.setHorizontalOffset(30);
            badgeDrawable.setVerticalOffset(20);

            BadgeUtils.attachBadgeDrawable(badgeDrawable, fab, null);

            fab.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });

enter image description here

Currently (1.3.0-alpha02) there isn't a method to change the radius, but you can override this dimen in your project (dimens.xml):

<dimen name="mtrl_badge_with_text_radius">12dp</dimen>

enter image description here

徽章计数浮动动作按钮

歌入人心 2025-02-19 16:06:46

请在下面找到答案

        WITH teacher_student_rankings AS (
      SELECT
        t.teacher_id
        , t.first_name
        , t.last_name 
        , COUNT(DISTINCT sc.student_id) AS teacher_student_count
        , RANK() OVER (ORDER BY COUNT(DISTINCT sc.student_id) DESC) AS teacher_student_rank
      FROM teachers t
        LEFT JOIN courses c
        ON t.teacher_id = c.teacher_id
        LEFT JOIN student_courses sc
        ON c.course_id = sc.course_id
      GROUP BY
        t.teacher_id
        , t.first_name
        , t.last_name 
    )
    SELECT
     t.teacher_id
        , t.first_name
        , t.last_name
        ,t.teacher_student_count as "No of students per teacher"
        ,t.teacher_student_rank
    FROM teacher_student_rankings t
    where teacher_student_rank =1;

Please find the answer below

        WITH teacher_student_rankings AS (
      SELECT
        t.teacher_id
        , t.first_name
        , t.last_name 
        , COUNT(DISTINCT sc.student_id) AS teacher_student_count
        , RANK() OVER (ORDER BY COUNT(DISTINCT sc.student_id) DESC) AS teacher_student_rank
      FROM teachers t
        LEFT JOIN courses c
        ON t.teacher_id = c.teacher_id
        LEFT JOIN student_courses sc
        ON c.course_id = sc.course_id
      GROUP BY
        t.teacher_id
        , t.first_name
        , t.last_name 
    )
    SELECT
     t.teacher_id
        , t.first_name
        , t.last_name
        ,t.teacher_student_count as "No of students per teacher"
        ,t.teacher_student_rank
    FROM teacher_student_rankings t
    where teacher_student_rank =1;

教师教大多数学生

歌入人心 2025-02-18 22:22:46

根据您的要求,您需要根据CI管道阶段运行触发CD管道阶段。

恐怕没有盒子外的方法可以达到这一要求。

对于解决方法,我建议您可以自然定义发行管道中的变量,并且可以通过REST API修改CI管道中的释放管道变量:“ noreferrer”>“ deactions-update ”。

请参阅以下步骤:

步骤1:定义Release Pipeline变量。

步骤2:在每个阶段添加一个步骤以在CI管道中运行PowerShell脚本。当管道阶段运行时,它将在重酶管道中修改值。

例如:

stages:
  - stage: Dev
    jobs:
      - job: A 
        steps:
          - task: PowerShell@2
            inputs:
              targetType: 'inline'
              script: |
                $url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=5.1"
                
                Write-Host "URL: $url"
                $pipeline = Invoke-RestMethod -Uri $url -Method Get -Headers @{
                    Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
                }
                Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 100)"
                
                # Update an existing variable named TestVar to its new value 2
                $pipeline.variables.Dev.value = "Yes"
                
                ####****************** update the modified object **************************
                $json = @($pipeline) | ConvertTo-Json -Depth 99
                
                $updatedef = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}
                
                write-host "==========================================================" 
                Write-host "The value of Varialbe 'Dev' is updated to" $updatedef.variables.Dev.value


  - stage: Stg
    jobs:
      - job: B 
        steps:
          - task: PowerShell@2
            inputs:
              targetType: 'inline'
              script: |
                $url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=5.1"
                
                Write-Host "URL: $url"
                $pipeline = Invoke-RestMethod -Uri $url -Method Get -Headers @{
                    Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
                }
                Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 100)"
                
                # Update an existing variable named TestVar to its new value 2
                $pipeline.variables.stg .value = "Yes"
                
                ####****************** update the modified object **************************
                $json = @($pipeline) | ConvertTo-Json -Depth 99
                
                $updatedef = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}
                
                write-host "==========================================================" 
                Write-host "The value of Varialbe 'stg ' is updated to" $updatedef.variables.stg .value

step3:在Release Pipeline阶段中,您可以设置条件:eq(变量['dev'],'yes')

例如:

Based on your requiremnt, you need to trigger the CD Pipeline stage based on the CI Pipeline stage running.

I am afraid that there is no out-of-box method can achieve this requirement.

For a workaround, I suggest that you can manaully define the variable in Release Pipeline and you can modify the release pipeline variable in CI pipeline via Rest API:Definitions - Update .

Refer to the following steps:

Step1: Define Release Pipeline variable.

enter image description here

Step2: Add a step to run PowerShell script in CI pipeline to each stage. When the Pipeline stage run, it will modify the value in Relase Pipeline.

For example:

stages:
  - stage: Dev
    jobs:
      - job: A 
        steps:
          - task: PowerShell@2
            inputs:
              targetType: 'inline'
              script: |
                $url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=5.1"
                
                Write-Host "URL: $url"
                $pipeline = Invoke-RestMethod -Uri $url -Method Get -Headers @{
                    Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
                }
                Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 100)"
                
                # Update an existing variable named TestVar to its new value 2
                $pipeline.variables.Dev.value = "Yes"
                
                ####****************** update the modified object **************************
                $json = @($pipeline) | ConvertTo-Json -Depth 99
                
                $updatedef = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}
                
                write-host "==========================================================" 
                Write-host "The value of Varialbe 'Dev' is updated to" $updatedef.variables.Dev.value


  - stage: Stg
    jobs:
      - job: B 
        steps:
          - task: PowerShell@2
            inputs:
              targetType: 'inline'
              script: |
                $url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=5.1"
                
                Write-Host "URL: $url"
                $pipeline = Invoke-RestMethod -Uri $url -Method Get -Headers @{
                    Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
                }
                Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 100)"
                
                # Update an existing variable named TestVar to its new value 2
                $pipeline.variables.stg .value = "Yes"
                
                ####****************** update the modified object **************************
                $json = @($pipeline) | ConvertTo-Json -Depth 99
                
                $updatedef = Invoke-RestMethod -Uri $url -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"}
                
                write-host "==========================================================" 
                Write-host "The value of Varialbe 'stg ' is updated to" $updatedef.variables.stg .value

Step3: In Release Pipeline stage, you can set the condition:eq(variables['dev'], 'Yes')

For example:

enter image description here

针对特定环境的Azure DevOps管道

歌入人心 2025-02-17 21:00:42

我遇到了同样的错误。

降级节点 18 16 为我解决了这个问题。对于这个问题,我没有找到更好的解决方案。参考: prisma github empress 我不建议降级。

但是Prisma通常在节点16 LTS上工作。

I have faced the same error.

Downgrading node from 18 to 16 solves this problem for me. I did't find better solution for this problem. Reference: prisma github comment. I don't recommend to downgrade though.

But prisma works normally on node 16 lts.

错误:获取配置:无法在Prisma和NextJS中建立与查询引擎 - 节点库库的连接

歌入人心 2025-02-17 01:45:15

只需更改,您就可以这样做

#include <iostream>
#include <vector>

template <typename T>
void doSomeThing(std::vector<T> vec)
{
  for (element : vec)
  {
    // do Something different if it is in vector
  }
}

template <typename T>
void doSomeThing(T element)
{
  // do Something else if it was not a vector
}

With just little changes you can do so

#include <iostream>
#include <vector>

template <typename T>
void doSomeThing(std::vector<T> vec)
{
  for (element : vec)
  {
    // do Something different if it is in vector
  }
}

template <typename T>
void doSomeThing(T element)
{
  // do Something else if it was not a vector
}

为“ type”做一个共同的功能和“类型”的向量使用C&#x2B;&#x2B;

歌入人心 2025-02-16 17:15:14

为了运行package.json内定义的NPM脚本,您必须在字典中,package.json.json文件位于位置。您尝试从crud-app-frontend运行脚本,但是您的package.json实际上位于crud-app中。

您必须在那里导航,然后运行脚本。

$ cd crud-app
$ npm run serve

In order to run npm scripts that are defined inside of package.json you have to be in the dictionary, where the package.json file is located. You tried to run the script from crud-app-Frontend, but your package.json is actually located in crud-app.

You have to navigate there and then run the script.

$ cd crud-app
$ npm run serve

npm err!缺少脚本:“服务” npm err!可以在Vuejs中找到此运行的完整日志

歌入人心 2025-02-15 20:21:33

:您可以将“行悬停”存储在单独的变量中,然后基于“ HoveredRowid === thing.id”的样式。

<script>
    let things = [
        { id: 1, name: 'apple' },
        { id: 2, name: 'banana' },
        { id: 3, name: 'carrot' },
        { id: 4, name: 'doughnut' },
        { id: 5, name: 'egg' },
    ];
    
    let hoveredId = 0;
    
    function makePretty(somethings) {
        const prettyThings = somethings.map(thing => thing.name).join(' ');
        console.log(prettyThings);
        return prettyThings;
    }
    
    $: prettyThings = makePretty(things)
</script>

<ul>
{#each things as thing (thing.id)}
    <li 
            class:hover={thing.id === hoveredId}
            on:mouseenter={() => (hoveredId = thing.id)}
            on:mouseleave={() => (hoveredId = 0)}
    >
        {thing.name}
    </li>
{/each}
</ul>
<p>
    Hovered ID: {hoveredId}
</p>

<style>
    .hover {
        background-color: cyan;
    }
</style>

编辑 = 3.48.0“ rel =“ nofollow noreferrer”> https://svelte.dev/repl/e157abc95787874228983c9efb2246aaa3?version = 3.48.0

EDIT: You could store the "Row Hovered" in a separate variable, then apply the style based on "HoveredRowId === thing.id"

<script>
    let things = [
        { id: 1, name: 'apple' },
        { id: 2, name: 'banana' },
        { id: 3, name: 'carrot' },
        { id: 4, name: 'doughnut' },
        { id: 5, name: 'egg' },
    ];
    
    let hoveredId = 0;
    
    function makePretty(somethings) {
        const prettyThings = somethings.map(thing => thing.name).join(' ');
        console.log(prettyThings);
        return prettyThings;
    }
    
    $: prettyThings = makePretty(things)
</script>

<ul>
{#each things as thing (thing.id)}
    <li 
            class:hover={thing.id === hoveredId}
            on:mouseenter={() => (hoveredId = thing.id)}
            on:mouseleave={() => (hoveredId = 0)}
    >
        {thing.name}
    </li>
{/each}
</ul>
<p>
    Hovered ID: {hoveredId}
</p>

<style>
    .hover {
        background-color: cyan;
    }
</style>

REPL: https://svelte.dev/repl/e157abc957874228983c9eafb2246aa3?version=3.48.0

悬停在对象条目上触发Svelte中不必要的反应性

歌入人心 2025-02-15 19:01:31

我认为问题只是您的循环运行太快,无法显示中间值。使用future.delayed()放慢循环,应该让您查看所需的内容。

void _incrementCounter() async {
  for(int i=0; i<100000; ++i) {
    await Future.delayed(Duration(seconds: 1));
    setState(() {
      _counter++;
    });
  }
}

I think the issue is just that your loop is running too fast to show the intermediate values. Slowing the loop down with Future.delayed() should let you see what you want.

void _incrementCounter() async {
  for(int i=0; i<100000; ++i) {
    await Future.delayed(Duration(seconds: 1));
    setState(() {
      _counter++;
    });
  }
}

颤音:从异步函数中更新UI的ui

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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