爱冒险

文章 评论 浏览 29

爱冒险 2025-02-06 19:02:39
  1. 创建一个自定义部署键
    • 生成键
      ssh-keygen -f decoly_key -n“”
     

  2. 编码部署密钥作为base64编码ENV变量以振幅
      cat deploy_key | base64 | tr -d \\ n 
     
    • 将其添加为托管环境变量(例如Deverlovy_key)
  3. 修改 amplify.yml 文件以使用部署密钥
    • 有两个关键步骤
      • 将部署密钥添加到 ssh-agent
        • 警告:此实现将打印 $ devoly_key stdout
      • 禁用 stricthostkeychecking
        • 注意:放大没有 $ home/.ssh 文件夹,因此您需要创建一个作为部署过程的一部分
    • 相关摘录
       -  ...
     - 评估“ $(ssh -agent -s)”
    -ssh -add<(echo“ $ devoly_key” | base64 -d)
    
     - 回声“禁用严格的主机钥匙检查”
    -mkdir〜/.ssh
     - 触摸〜/.ssh/config
    
     - 'echo -e“主机 *\ n \ tstricthostkeychecking no \ n \ n”> 〜/.ssh/config'
     -  ...
     

现在您应该能够使用git克隆私人仓库。

有关更详细的书面以及替代方案和陷阱,请参见在这里

  1. Create a custom deploy key for the private repo in github
    • generate the key
    ssh-keygen -f deploy_key -N ""
    
  2. Encode the deploy key as a base64 encoded env variable for amplitude
    cat deploy_key | base64 | tr -d \\n 
    
  3. Modify the amplify.yml file to make use of the deploy key
    • there's 2 key steps
      • adding deploy key to ssh-agent
        • WARNING: this implementation will print the $DEPLOY_KEY to stdout
      • disabling StrictHostKeyChecking
        • NOTE: amplify does not have a $HOME/.ssh folder by default so you'll need to create one as part of the deployment process
    • relevant excerpt below
    - ...
    - eval "$(ssh-agent -s)"
    - ssh-add <(echo "$DEPLOY_KEY" | base64 -d)
    
    - echo "disable strict host key check"
    - mkdir ~/.ssh
    - touch ~/.ssh/config
    
    - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - ...
    
    • full build file here

Now you should be able to use git to clone the private repo.

For a more detailed writeup as well as alternatives and gotchas, see here

如何在Amplify中吸收其他私人存储库

爱冒险 2025-02-06 14:01:14

有了您的 Forge应用,您可以获得所有轮毂

的列表
(1)用户可以访问(2)您的 forge app 已提供

get/get/get/get/strong>中hubs endpoint 'LL获取有关上述两个缺少的信息 - 请参见

这是有关如何为给定的 forge应用程序提供的信息,以适用于给定的 bim 360 / acc accem 帐户:

With your Forge app you can get a list of all the hubs that
(1) the user has access to AND (2) your Forge app has been provisioned for

In the reply from the GET /hubs endpoint you'll get information about which of the above two are missing - see Errors when retrieving hubs

And here is info on how to provision your Forge app for a given BIM 360/ACC account: BIM 360 Docs Provisioning for Forge Apps

获取用户拥有访问tol的所有项目

爱冒险 2025-02-06 12:18:35

如果要并行发送两个HTTP请求,请获取其值,应使用CombineLatest RXJS操作员。
您的邮政服务将是这样的:

getPost(id: string) {
  $postDataHttpRequest = this.http.get(`posts/${id}`);
  $commentsDataHttpRequest = this.http.get(`posts/${id}/comments`);
  return combineLatest($postDataHttpRequest, $commentsDataHttpRequest)
}

///

这就是评论类的样子:

  private constructor(private postService: PostService) {

  }
      getComments() {
            this.postService.getPost( '1' )
              .subscribe( (posts,comments) => {
                console.log(posts);
                console.log(comments);
              },(error)=>{console.log(error)})
             
      }

If You want to send two http request in parallel then get their values You should use combineLatest rxjs operator.
Your post service will be like this:

getPost(id: string) {
  $postDataHttpRequest = this.http.get(`posts/${id}`);
  $commentsDataHttpRequest = this.http.get(`posts/${id}/comments`);
  return combineLatest($postDataHttpRequest, $commentsDataHttpRequest)
}

///

This is how the Comments class look like:

  private constructor(private postService: PostService) {

  }
      getComments() {
            this.postService.getPost( '1' )
              .subscribe( (posts,comments) => {
                console.log(posts);
                console.log(comments);
              },(error)=>{console.log(error)})
             
      }

无法调用一个从另一个Singleton类中声明的方法

爱冒险 2025-02-06 06:55:54

长度 String 对象中 convertto convertto toto-html 看到的唯一属性。作为解决方法,您可以将服务器名称包裹在另一个只有一个包含名称的属性的对象中,然后将其输出实际名称。像这样:

$failedConn | foreach{[pscustomobject]@{"Failed Servers" = $_}} | ConvertTo-Html | Out-File -Append C:\Path\To\html.html

请注意,我已经删除了 $ combinedBody += ,因为外文件不会返回任何输出,因此不会做任何事情。

Length is the only property in the String object that ConvertTo-Html sees so that's what gets output. As a workaround, you can wrap the server names in another object that only have a single property containing the name, then it should output the actual names. Like this:

$failedConn | foreach{[pscustomobject]@{"Failed Servers" = $_}} | ConvertTo-Html | Out-File -Append C:\Path\To\html.html

Note that I've removed $CombinedBody += since Out-File doesn't return any output so that won't do anything.

powershell阵列 - &gt; html为字符串,而不是。

爱冒险 2025-02-06 03:16:35

您已经添加了外键,但是您没有添加字段本身。

因此,您应该添加:

$table->unsignedBigInteger('user_id');

在URL表中。

You have added the foreign key, But you didn't add the field itself.

So you should add:

$table->unsignedBigInteger('user_id');

to urls table.

Laravel迁移中的外键约束错误

爱冒险 2025-02-06 02:34:53

使用 numpy argmin()查找索引:

然后使用 numpy put_along_axis() val (-1)。

val = -1
arr_mins = np.expand_dims(np.argmin(arr, axis=1), axis=1)
np.put_along_axis(arr, arr_mins , val , axis=1)

如果您只想仅替换每行最小值的第一次出现,则上述代码有效。

如果要替换每行最小值的多次出现,请执行以下操作:

arr_mins = np.argwhere(arr == np.expand_dims(np.min(arr, axis=1),axis=1))
rows = a [:,0]
cols = a [:,1]
arr[rows, cols] = -1

<

a a href =“ https://stackoverflow.com/questions/17568612/17568612/how-to-to-make-make-numpy-numpy-numpy-argmax-return-return- all-currences-of-the-maximum“>如何使numpy.argmax返回最大的所有出现?

获取所有等于max的列索引,并使用它们索引另一个数组:numpy vs稀疏csr_matrix

Using numpy argmin() to find the indices:

Then use numpy put_along_axis() to update values with val (-1).

val = -1
arr_mins = np.expand_dims(np.argmin(arr, axis=1), axis=1)
np.put_along_axis(arr, arr_mins , val , axis=1)

The above code works if you want to replace just the first occurrence of the minimum value in each row.

If you want to replace multiple occurrences of the minimum value in each row, do the following:

arr_mins = np.argwhere(arr == np.expand_dims(np.min(arr, axis=1),axis=1))
rows = a [:,0]
cols = a [:,1]
arr[rows, cols] = -1

Sources:

How to make numpy.argmax return all occurrences of the maximum?

Get all column indices of equal to max and use them to index another array: numpy vs sparse csr_matrix

Numpy修改每行指定的值

爱冒险 2025-02-05 19:53:31

您的值列表从0到10,因此配色栏将达到10。您可以将映射器“高”值更改为“ 9”:

mapper = LinearColorMapper(palette=colors, low=0, high=9, nan_color = 'gray')

或一个从1到10:

mapper = LinearColorMapper(palette=colors, low=1, high=10, nan_color = 'gray')

Your list of values goes from 0 to 10, so ColorBar will go up to 10. You can change mapper 'high' value to '9':

mapper = LinearColorMapper(palette=colors, low=0, high=9, nan_color = 'gray')

Or a ColorBar that goes from 1 to 10:

mapper = LinearColorMapper(palette=colors, low=1, high=10, nan_color = 'gray')

散装配色杆,分配每种颜色的滴答

爱冒险 2025-02-05 19:40:50

您不能在thatreturn语句中使用任何(...),这就是错误的来源。

此代码应该有效:

Mockito.when(service.authenticateUser(test)).thenReturn(new Player(...));
assertNotNull(service.authenticateUser(test));

现在,如果您要根据登录值进行模拟结果,则可以使用wher()部分中的参数匹配者:

Mockito.when(service.authenticateUser(any(User.class))
  .thenThrow(AuthenticationException.class);
Mockito.when(service.authenticateUser(argThat(login -> list.contains(login))
  .thenReturn(new Player(...));

assertNotNull(service.authenticateUser(test));

此处的顺序很重要:莫科托(Mockito)将尝试以Stubs的反向顺序匹配您的参数,因此,这里将首先检查登录是否在给定列表中,如果该存根失败,它将落后于第一个存根,这将为其他任何东西抛出AuthenticationException。

如果您希望返回的播放器取决于登录用户,则可以使用 .thenanswer()而不是 .thenreturn()。参见 oighito:doanswer vs theReturn

You can't use any(...) in the thenReturn statement, that's where the error comes from.

This code should work:

Mockito.when(service.authenticateUser(test)).thenReturn(new Player(...));
assertNotNull(service.authenticateUser(test));

Now if you want to stub different results depending on the value of the login, you can use argumentMatchers in the when() part:

Mockito.when(service.authenticateUser(any(User.class))
  .thenThrow(AuthenticationException.class);
Mockito.when(service.authenticateUser(argThat(login -> list.contains(login))
  .thenReturn(new Player(...));

assertNotNull(service.authenticateUser(test));

Here the order is important: Mockito will try to match your argument in reverse order of stubs, so here it will first check if the login is in the given list, and if that stub fails, it will fall back to the first stub, which will throw an AuthenticationException for anything else.

If you want the returned Player to be dependent on the login User, you can use .thenAnswer() instead of .thenReturn(). See Mockito : doAnswer Vs thenReturn

是否可以使用预定义的ArrayList作为DB模拟身份验证?

爱冒险 2025-02-05 00:41:02

我能够使用 @torek的解释来将这种解决方案拼凑在一起,该解决方案可以在 用户bob dockerfile的“ pectry”中工作:

FROM debian as base
RUN apt-get update && \
    apt-get -qy full-upgrade && \
    apt-get install -qy git && \
    apt-get install -qy openssh-server && \
    sed -i 's|session    required     pam_loginuid.so|session    optional pam_loginuid.so|g' /etc/pam.d/sshd && \
    mkdir -p /var/run/sshd && \
    groupadd builders -g 1111111112 && \
    useradd -l -u 1111111111 -g 1111111112 -m -s /bin/bash bob && \
    echo "bob ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
    echo "bob:youruncle" | chpasswd

EXPOSE 22

USER bob
RUN git config --global user.name "bob" && \
    git config --global user.email "[email protected]"

USER root
CMD /usr/sbin/sshd -D

我不知道如何清洁/适当/符合该解决方案的现行实践,但确实满足了原始帖子的需求。

I was able to use @torek's explanation to cobble together this solution that does the git config work in a USER bob "section" of the Dockerfile:

FROM debian as base
RUN apt-get update && \
    apt-get -qy full-upgrade && \
    apt-get install -qy git && \
    apt-get install -qy openssh-server && \
    sed -i 's|session    required     pam_loginuid.so|session    optional pam_loginuid.so|g' /etc/pam.d/sshd && \
    mkdir -p /var/run/sshd && \
    groupadd builders -g 1111111112 && \
    useradd -l -u 1111111111 -g 1111111112 -m -s /bin/bash bob && \
    echo "bob ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
    echo "bob:youruncle" | chpasswd

EXPOSE 22

USER bob
RUN git config --global user.name "bob" && \
    git config --global user.email "[email protected]"

USER root
CMD /usr/sbin/sshd -D

I have no idea how clean/proper/conformant to prevailing practice that solution is, but it does satisfy the need of the original post.

如何将dockerfile“ git config”值应用于非根用户的ssh会话?

爱冒险 2025-02-04 14:45:03

您不一定需要使用导入来使用python-shell的 pythonshell 类,您可以只使用 require() ,因此您的代码看起来像这样

const fs = require('fs');
const PythonShell = require('python-shell').PythonShell;

// ...

You don't necessarily need to use import to use the PythonShell class from python-shell, you can just use require() so your code would look like this

const fs = require('fs');
const PythonShell = require('python-shell').PythonShell;

// ...

“类型”:“模块”导入问题

爱冒险 2025-02-04 13:49:49

要执行操作,例如通过PowerShell Runbook从Azure Ad Group中添加/删除用户,您的自动化帐户应具有所有者/贡献者分配的角色。

所有者角色允许访问自动化帐户中的所有资源和操作,包括提供对其他用户,组和应用程序来管理自动化帐户的访问。

贡献者角色允许您管理所有内容,除了修改其他用户的访问权限对自动化帐户。

根据您的要求,您可以分配角色如下 msdoc

https://learn.microsoft.com/en-us/azure/azure/automation/automation/automation-lole-基于基于role-lole -Access-Control#角色在Automation-Accounts

  • 通过Azure Portal,

转到Azure Portal-&gt;自动化帐户 - &GT;您的帐户 - &gt;访问控制(IAM) - &GT;添加角色

”“在此处输入图像描述”

  • 确保给出目录读者角色如下:

转到Azure Portal -&gt; Azure ad -&gt;角色和管理员 - &gt;目录读者角色 - &gt;将此角色分配给运行簿帐户名称

”在此处输入图像描述

有关更多详细信息,请 下面的链接:

tryinging以与Automation Runbook的Azure AD连接,但获得代码: - 堆栈溢出

https://www.buchatech.com/2018/07/the-argument-is-is-is-null-er-rementy-erment-error-in-ror-in-azure-automation-automation-runbook/

To perform operations like adding/removing a user from Azure Ad group via PowerShell runbook, your Automation account should have owner/contributor role assigned.

The Owner role allows access to all resources and actions within an Automation account including providing access to other users, groups, and applications to manage the Automation account.

The Contributor role allows you to manage everything except modifying other user’s access permissions to an Automation account.

Based on your requirement you can assign roles as provided in the below MsDoc:

https://learn.microsoft.com/en-us/azure/automation/automation-role-based-access-control#roles-in-automation-accounts

  • To assign roles to your Azure Automation Account via Azure Portal,

Go to Azure Portal -> Automation Accounts -> Your Account -> Access Control (IAM) -> Add Role

enter image description here

  • Make sure to give Directory Readers role like below:

Go to Azure portal -> Azure AD -> Roles and Administrator ->Directory Readers role -> Assign this role to the runbook account name

enter image description here

For more in detail, please refer below links:

Trying to connect with Azure AD from Automation runbook account but getting Code: Authorization_RequestDenied - Stack Overflow

https://www.buchatech.com/2018/07/the-argument-is-null-or-empty-error-in-azure-automation-runbook/

https://learn.microsoft.com/en-us/azure/virtual-desktop/delete-host-pool?tabs=azure-portal

Azure自动化帐户访问 - ad&amp; WVD Hostpool(添加/删除)操作

爱冒险 2025-02-04 05:08:38

这是一个更具体的示例:

您需要首先加载

library(stargazer)

@john Garland,Stargazer2是Cimentadaj开发的实用程序函数。您可以从这里加载它:

这是从上面的github存储库中复制的函数:

stargazer2 <- function(model, odd.ratio = FALSE, ...) {
  if(!("list" %in% class(model))) model <- list(model)

  if (odd.ratio) {
    coefOR2 <- lapply(model, function(x) exp(stats::coefficients(x)))
    seOR2 <- lapply(model, function(x) exp(stats::coefficients(x)) * summary(x)$coef[, 2])
    p2 <- lapply(model, function(x) summary(x)$coefficients[, 4])
    stargazer::stargazer(model, coef = coefOR2, se = seOR2, p = p2, ...)

  } else {
    stargazer::stargazer(model, ...)
  }
}

现在,让我们拟合一个logit回归模型以查看其工作原理。我正在此处建立一个示例: https://stats.oarc。 ucla.edu/r/dae/logit-regression/

# load some data 
mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
    
# fit model
mylogit <- glm(admit ~ gre + gpa + factor(rank), data = mydata, family = "binomial")

具有优势比的Stargazer输出看起来像这样(请注意,参数为 odd.ratio !),

stargazer2(mylogit, odd.ratio=TRUE, type='text')

=============================================
                      Dependent variable:
                  ---------------------------
                             admit
---------------------------------------------
gre                         1.002**
                            (0.001)

gpa                         2.235**
                            (0.741)

factor(rank)2               0.509**
                            (0.161)

factor(rank)3              0.262***
                            (0.090)

factor(rank)4              0.212***
                            (0.089)

Constant                   0.019***
                            (0.021)

---------------------------------------------
Observations                  400
Log Likelihood             -229.259
Akaike Inf. Crit.           470.517
=============================================
Note:             *p<0.1; **p<0.05; ***p<0.01

我也想抓住机会to plug the excellent modelsummary package (https://vincentarelbundock.github.io/modelsummary/articles /modelsummary.html ),您可以通过 install.packages(modelsummary)安装。

您可以通过运行与上述相同

modelsummary(mylogit, exponentiate=TRUE)

Here's a more concrete example:

You will need to first load the stargazer package

library(stargazer)

As mentioned by @John Garland, stargazer2 is an utility function developed by cimentadaj. You can load it from here: https://github.com/cimentadaj/cimentadaj/blob/master/R/stargazer2.R

Here's the function copy-pasted from the github repo above:

stargazer2 <- function(model, odd.ratio = FALSE, ...) {
  if(!("list" %in% class(model))) model <- list(model)

  if (odd.ratio) {
    coefOR2 <- lapply(model, function(x) exp(stats::coefficients(x)))
    seOR2 <- lapply(model, function(x) exp(stats::coefficients(x)) * summary(x)$coef[, 2])
    p2 <- lapply(model, function(x) summary(x)$coefficients[, 4])
    stargazer::stargazer(model, coef = coefOR2, se = seOR2, p = p2, ...)

  } else {
    stargazer::stargazer(model, ...)
  }
}

Now, let's fit a logit regression model to see how it works. I am building on an example from here: https://stats.oarc.ucla.edu/r/dae/logit-regression/

# load some data 
mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
    
# fit model
mylogit <- glm(admit ~ gre + gpa + factor(rank), data = mydata, family = "binomial")

Stargazer output with odds ratios looks like this (note that the parameter is odd.ratio!)

stargazer2(mylogit, odd.ratio=TRUE, type='text')

=============================================
                      Dependent variable:
                  ---------------------------
                             admit
---------------------------------------------
gre                         1.002**
                            (0.001)

gpa                         2.235**
                            (0.741)

factor(rank)2               0.509**
                            (0.161)

factor(rank)3              0.262***
                            (0.090)

factor(rank)4              0.212***
                            (0.089)

Constant                   0.019***
                            (0.021)

---------------------------------------------
Observations                  400
Log Likelihood             -229.259
Akaike Inf. Crit.           470.517
=============================================
Note:             *p<0.1; **p<0.05; ***p<0.01

I would also like to take the chance to plug the excellent modelsummary package (https://vincentarelbundock.github.io/modelsummary/articles/modelsummary.html), which you can install by install.packages(modelsummary).

You could accomplish the same as above by running

modelsummary(mylogit, exponentiate=TRUE)

Stargazer2-自动返回赔率比

爱冒险 2025-02-03 18:49:38

p2.c 应具有全局变量的正常定义:

#include "./p2.h"
int b = 6;
int square(int x) {
    return x * x;
}

p2.c should have a normal definition of the global variable:

#include "./p2.h"
int b = 6;
int square(int x) {
    return x * x;
}

如何修复在Fedora的C程序编译期间发生警告

爱冒险 2025-02-02 22:28:30

IMO,后者是一种普遍的更安全的方法。如果输入视频流使用恒定的帧率,则两者都应导致相同的输出。如果输入帧量是可变的,则 -r 输入选项会弄乱时间,我认为。

IMO, the latter is a universal safer approach. If the input video stream uses a constant framerate, then both should result in the identical output. If the input framerate is variable, -r input option will mess up the timing, I presume.

ffmpeg用-r vs -filter和setpts更改视频速度

爱冒险 2025-02-02 22:22:59

我能够实现以下内容

<Grid>
    <Grid.Resources>
        <ObjectDataProvider x:Key="FooBar"
                            ObjectType="{x:Type system:String}"
                            MethodName="Format">
            <ObjectDataProvider.MethodParameters>
                <x:Static Member="res:Resources.Foo" />
                <x:Static Member="res:Resources.Bar" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Grid.Resources>

    <TextBlock
        Text="{Binding Source={StaticResource FooBar}, StringFormat={x:Static res:Resources.Baz}}" />
</Grid>

  • x xmlns:x =“ http://schemas.microsoft.com/winfx/2006/xaml” < /code>
  • res 是.NET名称空间(和汇编)
    • eg xmlns:res =“ clr-namespace:myApp; assembly = myApp”

I was able to achieve what I wanted with the following:

<Grid>
    <Grid.Resources>
        <ObjectDataProvider x:Key="FooBar"
                            ObjectType="{x:Type system:String}"
                            MethodName="Format">
            <ObjectDataProvider.MethodParameters>
                <x:Static Member="res:Resources.Foo" />
                <x:Static Member="res:Resources.Bar" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Grid.Resources>

    <TextBlock
        Text="{Binding Source={StaticResource FooBar}, StringFormat={x:Static res:Resources.Baz}}" />
</Grid>

In the above:

  • x is xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  • res is the .NET namespace (and assembly)
    • e.g. xmlns:res="clr-namespace:MyApp;assembly=MyApp"

如何在XAML中嵌套格式化的字符串?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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