我正在使用rbenv,Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2当我bundle install在项目中运行命令时出现错误.奇怪的是我实际安装了2.2.2版本(我的Gemfile指定),而不是2.0.0版本.(见下图).
我尝试了这个线程中提供的解决方案:你的Ruby版本是2.0.0,但是你的Gemfile指定了2.1.0,但它没有效果.
如果这有任何区别的话,我会使用优胜美地的MacBook Air.
更新:
which ruby - > Users/myuser/.rbenv/shims/rubyruby -v - > ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14] rbenv global 2.2.2并且rbenv rehash,没有效果which bundle - > /usr/bin/bundlegem env- > - GEM PATHS:
/Users/myuser/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/Users/myuser/.gem/ruby/2.2.0我是Travis CI的新手,我只是想了解为什么以及这里发生了什么.我尽我所能遵循他们的文档中的设置说明.我得到的是:
我无法理解的是为什么我在构建完成后得到这个:
HEAD detached from 2a3b308
Changes not staged for commit:
.......
modified: script/travis.sh
Untracked files:
(use "git add <file>..." to include in what will be committed)
vendor/bundle/
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
我before_install: - chmod +x script/travis.sh在我的.travis.yml中做了一个,然后chmod +x script/travis.sh进入我的构建日志.我有git版本2.7.4
为什么我的script/travis.sh编辑?我应该添加这些更改还是我的设置有问题?在script/travis.sh我已经得到了构建之前要执行一些小的命令,设置自己的Github的身份和.
为什么要vendor/bundle/添加此文件夹?
我正在学习bash并试图理解这两种从文件中读取行的方法之间的区别.
1.
while IFS= read -r line
do
echo $line
done < "$file"
Run Code Online (Sandbox Code Playgroud)
2.
cat $file |
while read data
do
echo $i
done
Run Code Online (Sandbox Code Playgroud)
所以基本上我想知道的是:它们中的任何一种比其他更常见吗?是否存在性能差异?等等
此外,还有其他方法从文件中读取甚至更好,特别是从大文件读取时?
我正在尝试使用该lean()选项以加快查询速度.但是当它添加到这样的查询时:
Pets.aggregate({ $match: { 'Name': 'Floofkins', 'lastMealDate': {$gt: today}}}, function (err, pets){
if (err) {
res.status(500).json({'error': err});
console.log('Could not fetch pets: ' + err);
return;
}
petsHadMealsToday = pets.length;
}).lean();
Run Code Online (Sandbox Code Playgroud)
我得到的是TypeError: Cannot read property 'lean' of undefined虽然pets.length收益宠物匹配查询的数量.
如果我删除该match选项并运行如下所示的内容,它就像一个魅力.
Pets.aggregate({ 'Name': 'Floofkins', 'lastMealDate': {$gt: today}}, function (err, pets){
if (err) {
res.status(500).json({'error': err});
console.log('Could not fetch pets: ' + err);
return;
}
petsHadMealsToday = pets.length;
}).lean();
Run Code Online (Sandbox Code Playgroud)
我想我错过了一些关于如何使用的基本观点match,所以请随时教育我!
我对 MongoDB 相当陌生,需要帮助根据另一个集合的数据对一个集合进行选择或某种左连接。
我有两个集合,动物和膳食,我想获取在某个日期(假设是 20171001)之后上次注册膳食的动物,以确定该动物是否仍然活跃。
collection animals:
{
name: mr floof,
id: 12345,
lastMeal: abcdef
},
{
name: pluto,
id: 6789,
lastMeal: ghijkl
}
collection meals:
{
id: abcdef,
created: 20171008,
name: carrots
},
{
id: ghijkl,
created: 20170918,
name: lettuce
}
Run Code Online (Sandbox Code Playgroud)
因此,在这种情况下查询的预期输出将是:
{
name: mr floof,
id: 12345,
lastMeal: abcdef
}
Run Code Online (Sandbox Code Playgroud)
由于 Floof 先生在 20171008 年(即 20171001 年之后)吃过最后一顿饭。
希望我说得足够清楚,但如果没有,请随时询问。
我想通过在每 4 个单词后插入一个换行符来清理 .txt 文件,使其更具可读性。该文件已填充来自数组的数据。
<?php
require "simple_html_dom.php";
$html = file_get_html("http://www.lipsum.com/");
$data = array();
$counter = 0;
foreach($html->find("div") as $tr){
$row = array();
foreach($tr->find("div") as $td){
$row[] = $td->plaintext;
}
$data[] = $row;
}
ob_start();
var_dump($data);
$data = preg_replace('~((\w+\s){4})~', '$1' . "\n", $data);
file_put_contents('new_text_file.txt', $data);
//$handlefile = fopen("newfile.txt", "w") or die("Unable to open file!");
//file_put_contents('newfile.txt', $data);
//$output = ob_get_clean();
//$outputFile = "newfile.txt";
//fwrite($handlefile, $output);
//fclose($handlefile);
?>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我创建了一个 for 循环和两个 if 语句来“计算”单词之间的间距,当变量counter达到 3 时,将插入换行符。但它不起作用,因为首先没有将网站上的数据打印到文本文件中。但是,如果我删除 …