小编mno*_*tka的帖子

我可以将chef.json的部分内容移动到数据库吗?

我正在使用vagrant + chef-solo + barkshelf插件.在我的Vagrantfile中我有这个:

chef.json = {
  "postgresql" => {
    "password" => {
      "postgres" => "password"
    }
  },
  "database" => {
    "create" => ["chembl_18"]
  },
  "build_essential" => {
    "compiletime" => true
  }
}
Run Code Online (Sandbox Code Playgroud)

如果我在这里添加更多配置,我的Vagrantile将很快变得凌乱.我试图改变这一点,所以我创建了databags/postgresql/json_attribs.json包含以下内容的文件:

{
  "postgresql": {
    "password": {
      "postgres": "iloverandompasswordsbutthiswilldo"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

和我的Vagrantfile中修改的内容:

chef.json = {
  :postgresql => ["json_attribs"],
  "database" => {
    "create" => ["chembl_18"]
  },
...
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我得到:

==> default:  58>>   default['postgresql']['dir'] = "/etc/postgresql/#{node['postgresql']['version']}/main"
...
==> default: [2014-05-14T12:36:51+00:00] ERROR: Running exception handlers
==> default: …
Run Code Online (Sandbox Code Playgroud)

chef-infra vagrant chef-solo berkshelf vagrantfile

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

熊猫 - 两列直方图?

我有这些数据:

data = pd.DataFrame().from_dict([r for r in response])
print data

     _id  total
0    213      1
1    194      3
2    205      156
...
Run Code Online (Sandbox Code Playgroud)

现在,如果我打电话:

data.hist()
Run Code Online (Sandbox Code Playgroud)

我会得到两个单独的直方图,每列一个.这不是我想要的.我想要的是使用这两列制作的单个直方图,其中一列被解释为值,另一列被解释为该值的出现次数.我该怎么做才能生成这样的直方图?

我试过了:

data.hist(column="_id", by="total")
Run Code Online (Sandbox Code Playgroud)

但这会生成更多(空)直方图和错误消息.

python plot histogram pandas

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

使用Visual Studio 2010在Vista上安装boost 1.42(或任何其他版本)

我想在带有Vista和Visual Studio 2010的ma PC上安装boost库.

首先从官方网站下载升级1.42并解压缩到c:\ boost_1_42_0然后我调用了bootstrap.bat但是我得到了一些错误:

c:\boost_1_42_0>bootstrap.bat
Building Boost.Jam build engine

Failed to build Boost.Jam build engine.
Please consult bjam.log for furter diagnostics.

You can try to obtain a prebuilt binary from

   http://sf.net/project/showfiles.php?group_id=7586&package_id=72941

Also, you can file an issue at http://svn.boost.org
Please attach bjam.log in that case.

在bjam.log中我发现:

Setting environment for using Microsoft Visual Studio 2010 x86 tools.
ERROR: Cannot determine the location of the VS Common Tools folder.
###
### Using 'vc10' toolset.
###

c:\boost_1_42_0\tools\jam\src>if exist bootstrap …

c++ boost build-process

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

Shibboleth - 它是如何运作的?

我尝试了解 Shibboleth 身份验证的工作原理。用户必须提供什么才能进行身份验证?是登录名和密码吗?如果是这样,这是唯一的选择吗?如何为新用户创建新的登录名/密码?如果某些用户在其组织内已经拥有一些登录名/密码怎么办?我在哪里可以阅读一些涵盖使用 Shibboleth 进行身份验证的实际方面的“高级”教程?

authentication authorization shibboleth

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

将函数应用于可迭代?

我刚刚写了这个函数:

def _apply(mols, fn, *args, **kwargs):
    return [fn(m, *args, **kwargs) for m in mols if m ]
Run Code Online (Sandbox Code Playgroud)

我开始思考:

  1. 可以使用 重写吗map
  2. 这已经在Python的某个地方实现了吗?

据我所知,map无法将参数传递给函数,另一方面,它可能会以某种方式进行优化,并且使用一些部分绑定或 lambda 我可以使用map. 这会有好处吗?

python algorithm functional-programming list-comprehension function

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

在python中,如何按元素的频率对列表进行排序

我有一个元素列表:[ 3, 3, 6, 6, 6, 5, 5, 8 ]需要按元素的频率对其进行排序才能得到这个:[ 6, 6, 6, 3, 3, 5, 5, 8 ]几个元素具有相同的频率按值排序.你能找到比这更短的路吗?

import collections
from operator import itemgetter, attrgetter

def freq_sort(arr):
    counter=collections.Counter(arr)
    com = sorted(counter.most_common(), key=itemgetter(1,0), reverse=True)
    com = map(lambda x: [x[0]] * x[1], com)
    return [item for sublist in com for item in sublist]
Run Code Online (Sandbox Code Playgroud)

python sorting algorithm python-itertools

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