我正在使用带有ansible playbook的vagrant在ubuntu映像上自动安装一堆程序.一个程序无法在vagrant VM上安装.在Vagrant我的文件中
config.vm.provision :ansible do |ansible|
ansible.verbose = "vvv"
ansible.playbook = "provisioning/playbook.yml"
end
Run Code Online (Sandbox Code Playgroud)
但是详细输出不包括apt-get输出.我的playbook.yml看起来像
---
- hosts: all
sudo: true
tasks:
- name: get vi
apt: state=latest name=vim
Run Code Online (Sandbox Code Playgroud)
如何apt-get install在VM上查看单个(或所有)的控制台输出,因为ansible会以格式输出每个安装
TASK: [Install vim] ***********************************************************
failed: [default] => {"failed": true}
...
Run Code Online (Sandbox Code Playgroud) 我有一个类,我将它与路由参数一起注入控制器。然后我使用 setter 在类中设置路由参数。
路线
Route::get('path/of/url/with/{paramVar}', 'testController@testFunc)
Run Code Online (Sandbox Code Playgroud)
控制器
class testController
{
public function testFunc(MyClassInterface $class, $routeParamVar)
{
$class->setParam($routeParamVar);
//do stuff here
...
Run Code Online (Sandbox Code Playgroud)
服务提供者
public function register()
{
$this->bind('path\to\interface', 'path\to\concrete');
}
Run Code Online (Sandbox Code Playgroud)
相反,我想将路由参数注入到我注入控制器的类的构造函数中。我从这个问题知道我需要使用 laravel 容器。
我可以使用 注入其他路由参数Request::class,但如何注入路由路径参数?
我想我最终会得到这样的结果
class testController
{
public function testFunc(MyClassInterface $class)
{
//do stuff here
...
Run Code Online (Sandbox Code Playgroud) 我正在使用带有php单元的laravel 5来创建一个laravel包.我有Repository...
namespace Myname\Myapp\Repositories;
use Myname\Myapp\Models\PersonModel;
class PersonRepository
{
protected $personModel;
public function __construct(PersonModel $personModel)
{
$this->personModel = $personModel;
}
public function testFunction($var)
{
return $this->personModel->find($var);
}
}
Run Code Online (Sandbox Code Playgroud)
..实现了Model.
namespace Myname\Myapp\Models;
use Illuminate\Database\Eloquent\Model;
class PersonModel extends Model
{
protected $table = 'person';
}
Run Code Online (Sandbox Code Playgroud)
Laravels IoC自动注入PersonModel到构造函数中PersonRepository.
我正在编写单元测试,我想使用mock来模拟PersonModel模型,所以我在测试期间没有访问数据库.
namespace Myname\Myapptests\unit;
use Mockery;
class PersonRepositoryTest extends \Myname\Myapptests\TestCase
{
/**
* @test
*/
public function it_returns_the_test_find()
{
$mock = Mockery::mock('Myname\Myapp\Models\PersonModel')
->shouldReceive('find')
->with('var');
$this->app->instance('Myname\Myapp\Models\PersonModel', $mock); …Run Code Online (Sandbox Code Playgroud) 我在Dockerfile.
FROM node:9.11-alpine
COPY ./ /usr/src/app/
WORKDIR /usr/src/app/
RUN npm install && npm run build
ENTRYPOINT [ "npm", "run", "watch"]
Run Code Online (Sandbox Code Playgroud)
当我这样做时,docker build .成功完成构建的机会很小。在几分钟内,如果我定期运行相同的命令而不对我的Dockerfile或其他任何内容进行任何更改,则构建将会成功。大多数时候我都明白这一点;
...
npm WARN tar ENOENT: no such file or directory, open '/usr/src/app/node_modules/.staging/bluebird-5b126a50/js/browser/bluebird.js'
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/json-bigint/-/json-bigint-0.2.3.tgz failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are …Run Code Online (Sandbox Code Playgroud) 我正在学习承诺,因此我绝对希望在继续之前先了解它们的用法。我正在使用在线服务库,该库具有返回承诺的功能。
我读过的几乎所有示例都在链接then()函数中使用了已解析的数据
const result = Library.functionReturningAPromise()
result.then(function(res) {
const obj = new Example(res)
return obj
}).then(function(ob) {
// do the rest of the logic within these then() functions
})
Run Code Online (Sandbox Code Playgroud)
或在async函数中使用解析的数据
async function test() {
const result = await Library.functionReturningAPromise()
const obj = new Example(result)
// do the rest of the logic
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有任何方法可以使用“正常”同步代码中已解决的承诺中的数据
const result = Library.functionReturningAPromise()
// do something to resolve the promise
const obj = new Example(result)
Run Code Online (Sandbox Code Playgroud)
或者,如果您需要始终“包装” 使用函数中已解决的承诺中的数据的所有逻辑async。
我正在使用修改 pika 标头
properties.headers = {
'myheader': myheader
}
Run Code Online (Sandbox Code Playgroud)
但我对 delivery_tag
channel.basic_nack(delivery_tag=delivery_tag, requeue=False)
Run Code Online (Sandbox Code Playgroud)
如何将带有标头的更新属性传递给 ack 和 nack 响应函数?或者这样做的 pika 方式是什么?
我在 linux 上运行 i3 窗口管理器,我的 sublime text 刚刚更新到版本 4。
现在菜单上方有一个(相当大的)标题栏,显示了我无法删除的当前文件路径。我认为这是非标准的,因为由于 i3,我机器上的所有其他程序都没有显示标题栏。
无干扰模式和全屏模式将其隐藏,但这违背了平铺窗口管理器的目的。
我怎样才能禁用它?
我可以看到选项
"themed_title_bar": false,
Run Code Online (Sandbox Code Playgroud)
但这不会隐藏标题栏。我没有看到像菜单或状态栏那样的切换选项。
我想知道如何将一个区域设置为画布中定义的半复杂形状(圆形),因此当用户将鼠标悬停在形状上时,将调用一个函数.
我根本不想使用库,比如KineticJS等.
目前我已经向canvas元素添加了一个事件监听器,以便在鼠标移动时调用多个函数; 其中一个计算出相对于画布的鼠标x/y坐标.因此,任何矩形形状都很容易"监听"使用基本的if语句(因为画布是交互式的,并且每次鼠标移动都会重新绘制).
对于圆形对象,以及三角形对象,有没有办法使用类似的方法使用三角函数和if语句?
或者有更好的方法在画布上有多个区域,鼠标悬停,调用函数?
干杯
我在角度方式上看了这个线程获得元素高度,但作为一个有角度的新手,我需要一些帮助将我自己的js转换为正确的角度.
app.js
var AppModule = angular.module('App', ['ngAnimate', 'ngRoute']);
AppModule.config(function($routeProvider) {
$routeProvider
.when('/page:pageNumber', {
templateUrl: function ($routeParams) {
return '/app/..../assets/html/page' + $routeParams.pageNumber + '.php';
},
controller: "PageCtrl"
})
.otherwise({
redirectTo: "/page1"
});
});
Run Code Online (Sandbox Code Playgroud)
controller.js
AppModule.controller("ViewCtrl", function($scope, $timeout) {
$scope.$on("$routeChangeSuccess", function(event, current, previous) {
$timeout(function() {
$scope.animationStyle = "slideRight";
height = document.getElementById('page' + $routeParams.pageNumber).offsetHeight;
document.getElementById('document').setAttribute("style","height:" + height + "px");
document.getElementById('document').style.height='"' + height + 'px"';
});
});
});
Run Code Online (Sandbox Code Playgroud)
首先,我不知道怎么打电话$routeParams来得到pagenumber.我尝试注入$routeProvider控制器,但这没有帮助.它似乎也没有$scope.
其次,我不知道是否应该在控制器中放置DOM操作的代码.我只是坚持在那里尝试让它工作(如果我替换它,它会为一页height = document.getElementById('page' …
我想与社交媒体分享网页.如果我能提供帮助,我不想使用插件或添加JS脚本.我只想在每种情况下使用一个链接.
我找到了一个页面,解释了如何通过链接在facebook上分享网页;
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fhuebris.com%2Ffacebook-share-button&t=How+to+Share+Content+from+Your+Website+on+Facebook" target="_blank">this link</a>
Run Code Online (Sandbox Code Playgroud)
我还发现了如何在谷歌+上分享链接;
<a href="https://plus.google.com/share?url=' . $url . '" ...
Run Code Online (Sandbox Code Playgroud)
但是,我正在寻找如何共享页面
同样,但我很短暂.似乎有关于共享按钮的复制/粘贴脚本的指南,以及使用每个相应API的指南,但对于使用链接发布这么简单的东西,我似乎根本找不到多少.
javascript ×2
laravel ×2
php ×2
angularjs ×1
ansible ×1
asynchronous ×1
canvas ×1
docker ×1
header ×1
html5 ×1
laravel-5 ×1
laravel-5.2 ×1
mockery ×1
node.js ×1
npm ×1
phpunit ×1
pika ×1
promise ×1
python ×1
python-3.x ×1
sublimetext ×1
sublimetext4 ×1
synchronous ×1
vagrant ×1