小编Aid*_*len的帖子

重启postgres

有危险/etc/init.d/postgresql restart吗?我们刚刚发生了一些事情,一些关系"消失了",我跑了上述命令.刚刚被系统管理员搞砸了,但是他没有证明为什么这是一件坏事.我确实把webapp置于维护模式,因此当时没有任何事务/查询.


谢谢你们......总之它不会损坏任何东西,但它可能会丢失许多有价值的诊断信息.

postgresql

49
推荐指数
2
解决办法
9万
查看次数

在 terraform 12/13 中动态传递地图作为模块属性?

问题

如何动态地将地图解包到模块/资源属性中?我知道您可以在 terraform 12/13 中执行动态资源属性块,但是您可以对整个资源/模块的所有属性执行此操作吗?例如:

module "this" {
  for_each = {
    att0 = "attr0"
    attr1 = "attr1"
    attr2 = "attr2"
  }

  each.key = each.value
}

# my hope is that this would do the equivalent of this code below

module "this" {
  attr0 = "attr0"
  attr1 = "attr1"
  attr2 = "attr2"
}
Run Code Online (Sandbox Code Playgroud)

与在 python 中使用 splat kwargs 到函数中的方式类似。例如

module "this" {
  for_each = {
    att0 = "attr0"
    attr1 = "attr1"
    attr2 = "attr2"
  }

  each.key = each.value
} …
Run Code Online (Sandbox Code Playgroud)

foreach module dynamic terraform0.12+

7
推荐指数
0
解决办法
753
查看次数

保护 .Rprofile 中私有 R 存储库的凭据

与 python pip 不同,R 似乎公开了为.Rprofile. 我想这是因为 R 将字符串视为 URL。

local({r <- getOption("repos")
       r["Nexus"] <- "https://username:password@my-private-r-repo.com/repository/r-group"
       options(repos=r)
})
Run Code Online (Sandbox Code Playgroud)

然后当我安装包时:

> install.packages("shinydashboard")
trying URL 'https://username:password@my-private-r-repo.com/repository/r-group/bin/macosx/el-capitan/contrib/3.6/shinydashboard_0.7.1.tgz'
Content type 'application/x-tgz' length 326031 bytes (318 KB)
==================================================
downloaded 318 KB


The downloaded binary packages are in
    /var/folders/7_/pt_pgg2j531f2jc_n5znht600000gn/T//RtmpZkpXkN/downloaded_packages
Run Code Online (Sandbox Code Playgroud)

R 是否有配置选项来防止凭据泄露?

authentication authorization r credentials cran

6
推荐指数
1
解决办法
360
查看次数

在python中,如何使用正则表达式有条件地模式匹配

我试图用python的正则表达式库解析以下字符串:

recipe_a = 'run_list[sm_collectd::default@1.0.0]'
Run Code Online (Sandbox Code Playgroud)

使用http://pythex.org/,我正在尝试以下正则表达式:

\[(.*)::(.*)@(.*)\]
Run Code Online (Sandbox Code Playgroud)

产量:

Match 1
    1.  sm_collectd
    2.  default
    3.  1.0.0
Run Code Online (Sandbox Code Playgroud)

这是问题所在:

recipe_a可以与此正则表达式进行模式匹配,但是,当字符串中不再指定@version时,它会失败.以下示例将无法匹配模式:

recipe_b = 'run_list[sm_collectd::default]'
Run Code Online (Sandbox Code Playgroud)

\\[(.\*)::(.\*)@(.\*)\\]在这种情况下失败,因为@从未匹配.有python逻辑,\\[(.\*)::(.\*)@(.\*)\\]试图并尝试后一个正则表达式\\[(.\*)::(.\*)\\].但这很愚蠢.如果我能用一个正则表达式模式完成这个,那就太好了.

我试过用条件正则表达式语句解决这个问题.我尝试过的一般语法如下:

(?(?=regex)then|else)
Run Code Online (Sandbox Code Playgroud)

首先 ?是先行断言:没有消费的匹配.所以我们可以对@符号进行条件匹配.

如果@匹配则执行\\[(.\*)::(.\*)@(.\*)\\],否则执行\\[(.\*)::(.\*)\\].

程序化解决方案

kitchen_recipe = 'recipe[my_cookbook::default@0.1.0]'

recipe = kitchen_recipe.strip('recipe[').strip(']')
if '@' in recipe:
    cookbook, recipe, cookbook_version = tuple(re.split('::|@', recipe))
else:
    cookbook, recipe = tuple(re.split('::', recipe))
    cookbook_version = None   # no version specified
Run Code Online (Sandbox Code Playgroud)

REGEX解决方案

kitchen_recipe = 'recipe[my_cookbook::default@0.1.0]'

run_list_pattern = '\[(.*)::([^@]*)@?([0-9.]*)\]' …
Run Code Online (Sandbox Code Playgroud)

python regex conditional conditional-regex

3
推荐指数
1
解决办法
1239
查看次数