小编awm*_*awm的帖子

反复出现的 Vagrant 错误:不允许对 NFS 资源上的“创建”操作进行操作

我有一个带有厨师供应商的流浪盒子。除非对 NFS 资源进行操作,否则一切正常。例如,我有以下同步文件夹:

"host_path": "/Users/User/devbox/vdd/data",
        "guest_path": "/var/www",
        "type": "nfs"
Run Code Online (Sandbox Code Playgroud)

在流浪文件中:

 # Synced Folders.
    config_json["vm"]["synced_folders"].each do |folder|
      case folder["type"]
      when "nfs"
        config.vm.synced_folder folder["host_path"], folder["guest_path"], type: "nfs"
        # This uses uid and gid of the user that started vagrant.
        config.nfs.map_uid = Process.uid
        config.nfs.map_gid = Process.gid
Run Code Online (Sandbox Code Playgroud)

我还有一个厨师食谱,可以create对 nfs 资源执行操作:

directory "/var/www" do
  owner "vagrant"
  group "vagrant"
end
Run Code Online (Sandbox Code Playgroud)

但是,我不断收到以下错误:

 default: Error executing action `create` on resource 'directory[/var/www]'
==> default: ================================================================================
==> default: 
==> default: 
==> default: Errno::EPERM
==> default: ------------
==> default: …
Run Code Online (Sandbox Code Playgroud)

provisioning chef-infra vagrant

8
推荐指数
2
解决办法
5599
查看次数

如何检查对象上是否存在多个属性而不会太冗长?

我正在尝试以以下方式验证配置对象上是否存在某些属性并且在 javascript 中具有值(真实?不一定像评论中指出的那样):

const verifyJanrainAppSettings = (options) => {
    return options.JanrainAppSettings
      && options.JanrainAppSettings.settings.tokenUrl
      && options.JanrainAppSettings.settings.capture.clientId
      && options.JanrainAppSettings.settings.capture.appId
      && options.JanrainAppSettings.settings.capture.appDomain
      && options.JanrainAppSettings.settings.capture.captureServer
      && options.JanrainAppSettings.settings.httpLoadUrl
      && options.JanrainAppSettings.settings.httpsLoadUrl
}
Run Code Online (Sandbox Code Playgroud)

我觉得这太冗长了,我很好奇是否有更好的模式。也许像 if (['my', 'options'] in myObject) ...

javascript

8
推荐指数
1
解决办法
1266
查看次数

如果目录已满,则file_put_contents失败时,将创建大小为0的文件.怎么避免呢?

当tmp目录已满时,file_put_contents返回FALSE,但创建的文件大小为0. file_put_contents应该完成文件的创建或根本不起作用.例如:

$data = 'somedata';
$temp_name = '/tmp/myfile';
if (file_put_contents($temp_name, $data) === FALSE) {
    // the message print that the file could not be created.
    print 'The file could not be created.';
}
Run Code Online (Sandbox Code Playgroud)

但是当我进入tmp目录时,我可以找到在大小为0的目录中创建的文件"myfile".这使得难以维护.不应该创建该文件,我希望看到tmp目录已满的消息或警告.我错过了什么吗?这是正常的行为吗?

php temporary-files

5
推荐指数
1
解决办法
9337
查看次数

在Eclipse首选项中看不到PHP内容类型?

我用PDT安装了一个新的Eclipse Eclipse安装.我导入了我的首选项,除了在内容类型部分我没有看到PHP内容类型之外,一切似乎都正常工作.我看到php内容类型的"%content-typ.name0"; 如屏幕截图所示.这有什么问题?

在此输入图像描述

eclipse eclipse-plugin eclipse-pdt

4
推荐指数
1
解决办法
1986
查看次数

SVN st:这些状态意味着什么?

在我将一个主干合并到我的分支中以获得最新的更改后,我将我的分支合并到主干中.然后做了一个snv st,这是令我困惑的输出的一部分:

R  +    path/to/dirA
M      path/to/dirB
Run Code Online (Sandbox Code Playgroud)

对于我添加的目录,我也获得了"A"状态.但只有上面的状态,我不明白,特别是没有对这些目录进行任何更改.当我在其中一个目录上执行svn diff时,我得到了Property changes on: path/to/dirA

svn

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

如何使用preg_replace删除字符串中的所有后续样式标记/模式出现?

我试图找到一个匹配以下的正则表达式:

<style type="text/css"> .article-content{ position: relative;

padding-bottom: 140px;} .pane.pane-newsletter-contextual{ display: block;

bottom: 32px; position: absolute; left: 0px; margin-left: 0px; } </style>
Run Code Online (Sandbox Code Playgroud)

我需要正则表达式才能将它传递给preg_replace并从字符串中删除它.我有正则表达式的基本知识,并在审查了http://www.regular-expressions.info/examples.html上的基础后尝试了这一点.

preg_replace("/<style\b[^>]*>(.*?)</style>/", "", $body);
Run Code Online (Sandbox Code Playgroud)

但是这一行给出了以下错误 Unknown modifier 't' in ...

此外,我在提出问题之前尝试搜索,但找不到任何类似的问题.

php regex preg-replace

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

如何从树对象获取给定路径的子树?

我有一个树形对象:

var data = [{
    "root": true,
    "label": null,
    "question": "What product category?",
    "nodes": [{
        "label": "Clothes",
        "question": "What type of clothing?",
        "nodes": [{
            "label": "Jeans",
            "question": "Color of jeans?",
            "nodes": [{
                    "label": "Blue",
                    "question": null,
                    "nodes": null
                },

            ]
        }]
    }]
}];
Run Code Online (Sandbox Code Playgroud)

我试图返回给定数组 [0,0,0] 路径的子树,该路径将返回data[0].nodes[0].nodes[0]. 我正在尝试一种迭代方法,可以用递归方法来实现吗?

javascript angularjs

2
推荐指数
1
解决办法
718
查看次数

当55.8/9.3 = 6时,为什么fmod(55.8,9.3)返回9.3?

我正在尝试使用fmod函数,但我没有得到我期待的结果.

floating-point number-theory

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

如何将Scala列表用作堆栈?

我正在尝试解决Scala中的一个问题.传统的解决方案需要堆栈,但到目前为止还没有在类中引入堆栈.仅列出了清单.我的问题是如何将列表视为堆栈?换句话说,我如何模仿列表中的推送和弹出元素?

scala

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

去例程从URL下载到文件

我当前正在学习GO.在学习了一些基础知识后,我一直在尝试编写一个小程序,它使用goroutine同时将网页(切片中的网址)下载到不同的文件中.这是我写的一些代码:

func downloadFromUrl(url string) {
    tokens := strings.Split(url, "/")
    fileName := tokens[len(tokens)-1]
    // I took out the bit that download the file for testing.
    fmt.Println("Downloading", url, "to", fileName)

}
Run Code Online (Sandbox Code Playgroud)

我评论了实际下载页面以进行测试的位.在我的主要功能中,我这样做:

func main() {
    urls := []string{"http://www.google.com", "http://www.yahoo.com", "http://www.google.com"}

    for _, url := range urls {
        fmt.Println(url);
        go downloadFromUrl(url);
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是,当我使用表达式go downloadFromUrl(url);函数downloadFromUrl不运行时.但如果我只是downloadFromUrl(url)在循环中使用它工作正常.我究竟做错了什么?我是否必须在惯例中使用频道?

go goroutine

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

需要提示(而不是代码)将此递归函数转换为尾递归?

我有这个函数,它获取字符串和字符串列表的列表,然后返回每个列表中包含传递的字符串但没有传递字符串的所有元素的列表.

myfilter([["a","b"],["c","d"],["e","a","x"]], "a") -> ["b","e","x"]

fun myfilter(list : string list list, s : string) =
case list of
    [] =>  []
   |xs::xs' => case all_except_option(s, xs) of (* helper function that does it for a string and a list of strings *)
                   NONE => []
                  |SOME n => if n = xs
                             then myfilter(xs',s)
                             else n@myfilter(xs',s)
Run Code Online (Sandbox Code Playgroud)

现在这是你可以看到的一个递归函数,我想将它转换为尾递归函数.我熟悉尾递归的例子,但我没有看到如何在上面的函数中做到这一点

sml

0
推荐指数
1
解决办法
826
查看次数