我有这两个班:
class Customer
{
public string Name;
public string City;
public Order[] Orders;
}
class Order
{
public int Quantity;
public Product Product;
}
Run Code Online (Sandbox Code Playgroud)
然后在Main我做以下事情:
Customer cust = new Customer
{
Name = "some name",
City = "some city",
Orders = {
new Order { Quantity = 3, Product = productObj1 },
new Order { Quantity = 4, Product = productObj2 },
new Order { Quantity = 1, Product = producctObj3 }
}
};
Run Code Online (Sandbox Code Playgroud)
但是我无法初始化数组... with a …
在文档中我看到了这个
string:value
The field under validation must be a string type.
Run Code Online (Sandbox Code Playgroud)
但据我所知(从稀缺的解释+给出的例子)我必须用某个字符串值进行验证。但我想要的是简单地验证输入值仅包含字母表中的字母。
显然
'name' => 'required|string'
Run Code Online (Sandbox Code Playgroud)
不会削减它,因为它必须是 string:SomeValue
那么,在针对字符串进行验证的模型类中设置验证规则的正确方法是什么?
如果在依赖项中没有指定分支,npm是否总是从主分支中拉出来?如果我有另一个分支,比如说develop我在那里标记提交怎么办?我知道npm会从特定的分支更新,如果写的话
"private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#develop"
Run Code Online (Sandbox Code Playgroud)
但是如果我想从该分支中提取特定标签呢?因为只是指定标签,就像
"private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#v1.0.1"
Run Code Online (Sandbox Code Playgroud)
没有工作(master分支没有标记的提交.只有develop分支有它).I got a fatal: ambiguous argument 'v1.0.1': unknown revision or path not in the working tree.这让我想到它试图在没有它的分支中找到指定的标签(必须是master分支,因为我只有这两个分支).
那么,有没有办法指定要更新的分支和git-tag?
config我想将环境变量加载到我的 Express 应用程序的常规中。在本地,我使用一个.env文件,但在部署时,我会将环境变量注入到 docker 容器中。
所以,我有default.json一些硬编码的配置值。然后我得到了custom-environment-variables.json这样的文件:
"app": {
"nodeEnv": "NODE_ENV",
"port": "PORT",
"hostname": "HOSTNAME"
}
"mongoDb": {
"connectionString": "MONGODB_CONNECTION_STRING"
},
"redis": {
"connectionString": "REDIS_CONNECTION_STRING"
},
"logDna": {
"key": "LOGDNA_KEY"
}
Run Code Online (Sandbox Code Playgroud)
以及.env我项目的根目录中的一个文件。
在服务器启动文件中我有:
import * as dotenv from 'dotenv';
dotenv.config();
import * as config from 'config';
console.log(process.env);
console.log(config);
Run Code Online (Sandbox Code Playgroud)
我还尝试将它们按正常顺序排列:
import * as config from 'config';
import * as dotenv from 'dotenv';
dotenv.config();
Run Code Online (Sandbox Code Playgroud)
我尝试的另一件事是将应用程序声明与服务初始化和应用程序启动分开。就像这样app.ts:
import * as App from 'express';
import …Run Code Online (Sandbox Code Playgroud) 我想手动触发 GitHub Actions 工作流程。通过文档,我发现我可以通过存储库调度事件来做到这一点。
问题是,当我在端点处调用 API 时/dispatches,出现以下错误:
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3/repos/#create-a-repository-dispatch-event"
}
Run Code Online (Sandbox Code Playgroud)
我拥有对该存储库的写入权限。我自己生成了一个访问令牌。
调度功能是默认启用的还是我需要以某种方式“启用”它,所以/dispatches可用?要么是我看起来不够好,要么是文档中没有描述这一点。
我不知道这是否有什么不同,但该存储库由组织拥有,而不是个人用户拥有。
所以我有这个大学任务解决数独...我读了算法X和跳舞算法,但他们没有帮助我.
我需要回溯.我用维基百科给出的位置上的数字硬编码了二维数组中的一些索引(所以我确信它是可解的).
我得到的代码如下:
public void solveSudoku(int row, int col)
{
// clears the temporary storage array that is use to check if there are
// dublicates on the row/col
for (int k = 0; k < 9; k++)
{
dublicates[k] = 0;
}
// checks if the index is free and changes the input number by looping
// until suitable
if (available(row, col))
{
for (int i = 1; i < 10; i++)
{
if (checkIfDublicates(i) == true)
{
board[row][col] …Run Code Online (Sandbox Code Playgroud) 我很满意整个Homestead的东西以及它与IDE的关系.假设我在~/Developer/PhpStormThe Homestead 安装了我的PhpStorm ~/Developer/Homestead.这就是我在Homestead中的YAML文件的样子:
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Developer/Homestead/workspace
to: /home/vagrant/Code
sites:
- map: helloworld.app
to: /home/vagrant/Code/Laravel/public
variables:
- key: APP_ENV
value: local
Run Code Online (Sandbox Code Playgroud)
所以,你看到我在Homestead目录中有一个工作区文件夹.我还有另一个目录:~/Developer/workspace/PHP我计划存储我的项目,而不是在Homestead文件夹中.
我在PhpStorm中安装了Laravel插件.并且,为了使Laravel插件在PhpStorm中工作,需要生成此文件.我的问题是:
_ide_helper.php文件,以便PhpStorm与Laravel正常工作?我应该将它粘贴到每个项目中还是只粘贴一次?我想检查两个变量是否都已设置或均未设置。我尝试了多种选择,这是我想出的最干净的解决方案:
if [ ! -z $A -a -z $B ] || [ -z $A -a ! -z $B ]; then
#error
fi
#success
Run Code Online (Sandbox Code Playgroud)
当我运行 A 和 B 设置的脚本时 - 它运行良好。但是当我在缺少 A 的情况下运行它时,我得到:
./test.sh: line 3: [: too many arguments
./test.sh: line 3: [: too many arguments
Run Code Online (Sandbox Code Playgroud)
第 3 行是条件语句。
当我在 B 缺失的情况下运行它时,我得到:
./test.sh: line 3: [: argument expected
./test.sh: line 3: [: argument expected
Run Code Online (Sandbox Code Playgroud)
是我的情况语法错误还是我错过了其他东西?
我很难弄清楚如何使管道使用 npm 模块恢复的缓存。
这是清单文件:
jobs:
setup-build-push-deploy:
name: Setup, Build, Push, and Deploy
runs-on: ubuntu-latest
steps:
# Checkout the repo
- name: Checkout
uses: actions/checkout@v2
- name: Setup NodeJS
uses: actions/setup-node@v1
with:
node-version: '12.14'
# Cache the npm node modules
- name: Cache node modules
uses: actions/cache@v1
id: cache-node-modules
env:
CACHE_NAME: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ env.CACHE_NAME }}-${{ hashFiles('app/package-lock.json') }}
restore-keys: |
${{ env.CACHE_NAME }}-
# Install NPM dependencies
- …Run Code Online (Sandbox Code Playgroud) github ×2
laravel-4 ×2
php ×2
algorithm ×1
arrays ×1
backtracking ×1
bash ×1
c# ×1
caching ×1
dotenv ×1
express ×1
git ×1
github-api ×1
if-statement ×1
java ×1
laravel ×1
next.js ×1
node-config ×1
node.js ×1
npm ×1
npm-install ×1
phpstorm ×1
shell ×1
sudoku ×1
validation ×1