我创建了一个vagrant实例,每次我尝试psql在终端中执行此操作时我都会收到此错误.错误是状态:
psql:致命:角色"vagrant"不存在
我以为流浪汉会照顾这个?这是我的流浪文件:
Vagrant.require_plugin "vagrant-omnibus"
Vagrant.require_plugin "vagrant-berkshelf"
Vagrant.configure(2) do |config|
# Box config
config.vm.box = 'precise64'
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
# Plugin config
config.omnibus.chef_version = :latest
config.berkshelf.enabled = true
# Network config
config.vm.network :forwarded_port, guest: 3000, host: 3000
# Virtual config
config.vm.provider(:virtualbox) do |vb|
vb.customize [
"modifyvm", :id,
"--memory", "1024",
"--cpus", "4"
]
end
# Provisioner config
config.vm.provision :chef_solo do |chef|
chef.add_recipe 'apt'
chef.add_recipe 'postgresql::client'
chef.add_recipe 'postgresql::server'
chef.add_recipe 'build-essential'
chef.add_recipe 'rvm::system'
chef.add_recipe 'git'
chef.json = {
:postgresql => { …Run Code Online (Sandbox Code Playgroud) Composer在我的json文件中提供的存储库中找不到我想要克隆的分支.我得到的错误是:
[UnexpectedValueException]
Could not parse version constraint development: Invalid version string "dev
elopment"
Run Code Online (Sandbox Code Playgroud)
我想我不能说,去这个地方,从这个分支克隆?
{
"repositories": [
{
"type":"package",
"package": {
"name": "AdamKyle/Aisis-Core",
"version":"development",
"source": {
"url": "https://github.com/AdamKyle/Aisis-Core.git",
"type": "git",
"reference":"development"
}
}
}
],
"require": {
"AdamKyle/Aisis-Core": "development"
}
}
Run Code Online (Sandbox Code Playgroud) 我已经读了一段时间关于C并决定让我们写一点添加程序,没什么好看的.我对C头的理解是它们是"接口"(比如java和其他语言),但你也可以定义具有设置值的变量.
所以我写了这个:
#include <stdio.h>
#include <stdlib.h>
#include "sample.h"
int main(int argc, char** argv) {
printf("hello World\n");
add(12, 18);
return (EXIT_SUCCESS);
}
int add(int a, int b){
int value = a+b;
printf("value = %d\n", value);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它有一个头文件,如下所示:
#ifndef SAMPLE_H_GUARD
#define SAMPLE_H_GUARD
int add(int a, int b);
#endif
Run Code Online (Sandbox Code Playgroud)
我认为头文件,这是我在他们的定义上丢失的地方,假设定义add的使用,所以我要做的就是调用add - 从我的理解,我定义add的规则然后实现添加功能....
此外,我读过的很多材料显示了多个C文件的一个头文件.今天许多项目每个c都有一个标题,这意味着Sample.h属于Sample.c而没有别的.
有人可以对此有所了解吗?
我可以像这样做:
main.c中
#include <stdio.h>
#include <stdlib.h>
#include "sample.h"
int main(int argc, char** argv) {
printf("hello World\n");
add(12, 18);
return (EXIT_SUCCESS);
}
Run Code Online (Sandbox Code Playgroud)
add.c
#include <stdio.h>
#include <stdlib.h>
#include …Run Code Online (Sandbox Code Playgroud) 我很好奇如何通过终端将参数传递到 bash 脚本并读取它们并根据参数处理脚本函数。
所以如果我做了类似的事情:
./scriptname.sh install
#or
./scriptname.sh assets install
Run Code Online (Sandbox Code Playgroud)
我怎么说呢,好吧,第一个参数安装了一些东西,而第二个参数则表示根据第一个参数做其他事情。
所以我试着写一个bash脚本,声明:
如果文件存在且目录b存在,请运行composer install,检查vendor文件夹.如果我们找到它 - 回声并退出.
但它一直说:
./composerrun.sh: line 6: syntax error near unexpected token `fi'
./composerrun.sh: line 6: ` fi'
Run Code Online (Sandbox Code Playgroud)
我太新了,无法理解这个结束"支撑"是如何错误的:
#!/bin/bash
if checkForComposerJson && checkForAisisCore
composer install
if checkForVendor
echo "Found vendor"; exit;
fi
fi
function checkForAisisCore {
if [-d "AisisCore/"]
then
return 0;
else
echo "would you like us to create the directory?" yn,
case $yn in
Yes )
mkdir "AisisCore/";
if [-d "AisisCore/"]
return 0;;
else
echo "We could not create the directory as you requested";
return …Run Code Online (Sandbox Code Playgroud) 使用!important非常糟糕,所以我试图尽可能地避免它,当我下载Bootstrap 3.0时,我将调用放在.css文件后我的核心样式表被调用.因此,我对类似元素所做的任何修改都.h1, h1{}应该在调用Bootstraps之前呈现.
但事实并非如此.Chrome中的Bootstrap正在应用它的样式并将其挖出.只有通过应用!important它来工作 - 这是错误的.
任何想法如何绕过这个!important?我不能只修改bootstrap.css因为那也是错的 - 网站的其他部分按原样使用bootstrap,而某些部分则改变了一些功能.
我正在尝试编写一个执行以下操作的简单备份脚本:
#!/bin/bash
#backupScript
mysqldump mysql -uxxxxx -pxxxxx Database1 Database2 | gzip > "MainWordPress.gz"
time_stamp = `date +%Y%m%d.%H%M`
file_name = 'backup-{$time_stamp}.tar.gz'
sources = 'DIR/ MainWordPress.gz'
tar -cvf file_name sources
rm MainWordPress.gz
cp file_name some/destination
Run Code Online (Sandbox Code Playgroud)
但问题是它不喜欢:
./runBackup.sh: line 6: time_stamp: command not found
./runBackup.sh: line 7: file_name: command not found
./runBackup.sh: line 8: sources: command not found
tar: sources: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Run Code Online (Sandbox Code Playgroud)
而且我很困惑......
是否可以查看某个类是否已被扩展或者某个类是否有父类?我问的原因是因为如果我想查看某个方法是否已在具有父级的类中被覆盖,然后返回该父类名.
所以:
class A{
public function method(){ ... }
}
class B extends A{
public function method(){ ... }
}
Run Code Online (Sandbox Code Playgroud)
method()已被定义,然后被覆盖class B.在PHP中是否有一些反思或方法,我可以这么说,"哦,你的主叫的功能是什么?你在一个有父母的班级,父母的名字是A"
这是一个简单的命令:rm -rf dir但我有一个有趣的问题需要解决.我的bash脚本调用composer install一个composer脚本,然后vendor/app-name/在composer install运行的目录中生成.这很好,问题是我现在做的事情如下:
cp -R /vendor/ .
# I believe this is correct for copying everything
# out out of vendor and into root
Run Code Online (Sandbox Code Playgroud)
从供应商复制一切.确定这是确定的,但有可能是在那里300的应用程序名称的文件夹(显然都具有不同的名称等,然后应用程序名),每个可能有一个.gitignore,.git目录或文件目录.我想说:
浏览每个文件夹,查找.git /,.gitignore或文档,如果找到则删除它们.
我怎么能用bash做到这一点?
注意:所有正在下拉的软件包都是通过git下拉的,用户可以选择添加从作曲家软件包下拉的其他软件包.相同的概念仍然适用.
我写了一个bash脚本,它接受一组参数,并根据我们做不同的事情.所以在这种情况下我想说:
./acorn.sh aisiscore install
Run Code Online (Sandbox Code Playgroud)
但它转到我的错误消息,指出第一个参数没有重新组合,我应该使用aisiscore或资产.我检查了拼写,我是对的,我没有正确检查参数吗?
#!/bin/bash
set -e
function checkCoreArgument(){
if [[ $1 == 'aisiscore' ]]
then
checkAisisArguments
elif [[ $1 == 'assets' || $1 == 'asset' ]]
then
checkAssetsArguments
else
echo "$1 is not recognized. Please try aisiscore or assets"
fi
}
function checkAisisArguments(){
if [[ $2 == 'install' ]]
then
installAisisCore
elif [[ $2 == 'update' ]]
then
updateAisisCore
elif [[ $2 == 'components' ]]
then
callCompomnentsCheck
else
echo "$2 is not recognized. Please try install or update." …Run Code Online (Sandbox Code Playgroud) bash ×5
git ×2
c ×1
composer-php ×1
css ×1
header-files ×1
html ×1
inheritance ×1
php ×1
postgresql ×1
psql ×1
shell ×1
vagrant ×1