我的目标是创建一个响应网格,其中包含未知数量的项目,其长宽比保持在16:9。现在看起来像这样:
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, 160px);
grid-template-rows: 1fr;
grid-gap: 20px;
}
.item {
height: 90px;
background: grey;
}Run Code Online (Sandbox Code Playgroud)
<div class="grid">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>Run Code Online (Sandbox Code Playgroud)
问题在于,这些项目不会随屏幕尺寸缩放,从而在正确的位置留出空白。但是,当使用例如:使网格适应屏幕尺寸grid-template-columns: repeat(auto-fit, minmax(160p, 1fr))并删除时height: 90px;,长宽比不会持久。
如果没有CSS网格,也许有更好的解决方案?(也许使用JavaScript)
我通过aws-sdkNodejs发送电子邮件,如下所示:
const params = {
Destination: {
ToAddresses: [... ],
},
Message: {
Body: {
Html: {
Data: `...`,
Charset: 'utf-8'
},
},
Subject: {
Data: `...`,
Charset: 'utf-8'
}
},
Source: 'support@mydomain.com',
ReturnPath: 'support@mydomain.com',
};
awsConfig.ses.sendEmail(params, (err, data))
Run Code Online (Sandbox Code Playgroud)
目前support发件人名称是,因为发件人电子邮件是support@mydomain.com。但我希望它被GitHub下面的公司取代。
在此先感谢您的帮助!
email amazon-web-services node.js aws-sdk amazon-simple-email-service
我有一个页面,用户可以上传文件的帮助下FormData和XMLHttpRequest。上传文件效果很好。但upload.onprogress在只有工作时上传一个HTTP连接。
我已经在Heroku和Amazon EC2实例上对此进行了测试。但是总是一样的:
const xhr = new XMLHttpRequest();
let progress = 0;
/** THIS EVENT IS NOT WORKING WITH HTTPS */
xhr.upload.onprogress = (event: ProgressEvent) => {
if (event.lengthComputable) {
progress = 100 * (event.loaded / event.total);
}
};
xhr.responseType = 'json';
xhr.open('POST', `${API_URL}/${this.API_PATH}/upload`, true);
xhr.setRequestHeader('authorization', this.authService.getAuthToken());
xhr.send(payload);
xhr.onload = () => {
observer.next(xhr.response);
observer.complete();
};
Run Code Online (Sandbox Code Playgroud)
const busboyBodyParser = require('busboy-body-parser');
app.use(busboyBodyParser())
Run Code Online (Sandbox Code Playgroud)
const …Run Code Online (Sandbox Code Playgroud) 我正在使用Visual Studio Code开发一个打字稿项目,其中包括多个结构如下的npm软件包:
/src/index.ts/dist/...当我右键单击导入的对象并选择“转到定义”时,或者F12在按住的同时单击或单击该对象CTRL,Visual Studio Code将在其中打开相应的.d.ts文件。/dist
但是,我想VSCode在中打开相应的.ts文件/src
是否可以更改此行为,因为手动搜索源文件确实很烦人。
我创建了git repo,以便您可以自己尝试:https : //github.com/flolude/stackoverflow-typescript-go-to-definition
yarn bootstrap即可复制问题。javascript typescript visual-studio-code monorepo vscode-settings
我有一个ConfigMap为我的Pod提供必要的环境变量:
apiVersion: v1
kind: ConfigMap
metadata:
name: global-config
data:
NODE_ENV: prod
LEVEL: info
# I need to set API_URL to the public IP address of the Load Balancer
API_URL: http://<SOME IP>:3000
DATABASE_URL: mongodb://database:27017
SOME_SERVICE_HOST: some-service:3000
Run Code Online (Sandbox Code Playgroud)
我正在Google Cloud上运行Kubernetes集群,因此它将自动为我的服务创建一个公共端点:
apiVersion: v1
kind: Service
metadata:
name: gateway
spec:
selector:
app: gateway
ports:
- name: http
port: 3000
targetPort: 3000
nodePort: 30000
type: LoadBalancer
Run Code Online (Sandbox Code Playgroud)
我有一个Web应用程序,需要从客户端浏览器向gateway服务发出HTTP请求。但是为了向外部服务发出请求,Web应用程序需要知道它的IP地址。
因此,我设置了pod,该pod以某种方式为Web应用程序提供服务,它选择了一个环境变量“ API_URL”,从而使所有HTTP请求都对该URL进行了请求。
因此,我只需要一种方法即可将API_URL环境变量设置为服务的公共IP地址,gateway以便在启动时将其传递到pod中。
environment-variables google-cloud-platform kubernetes google-kubernetes-engine
我想在Google Cloud Build和Google Kubernetes Engine的帮助下完全自动化许多服务的部署。这些服务位于monorepo 中,它有一个名为.services
所以我cloudbuild.yaml为每个服务创建了一个并创建了一个构建触发器。这样cloudbuild.yaml做:
随着服务数量的增加,构建触发器的数量也会增加。也有越来越多的服务被构建,即使它们没有改变。
因此我想要一种机制,它只有一个构建触发器并自动确定需要重建哪些服务。
假设我有一个具有此文件结构的 monorepo:
??? packages
? ??? enums
? ??? components
??? services
??? backend
??? frontend
??? admin-dashboard
Run Code Online (Sandbox Code Playgroud)
然后我对frontend服务进行了一些更改。由于frontend和admin-dashboard服务依赖于components包,因此需要重建多个服务:
但不是后端!
为每个服务设置多个构建触发器。但是这些构建中有 80% 是多余的,因为代码中的大多数更改仅与个人服务相关。管理许多看起来几乎相同的构建触发器也越来越复杂。单个cloudbuild.yaml文件如下所示:
steps: …Run Code Online (Sandbox Code Playgroud) build-automation google-cloud-platform kubernetes monorepo google-cloud-build
我有一个可用的 Bazel BUILD文件,如下所示:
\n\npackage(default_visibility = ["//visibility:public"])\n\nload("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")\nload("@npm_bazel_typescript//:index.bzl", "ts_library")\n\n# TODO run jest tests and stop build if test not passes\n# TODO also run tests from dependent packages\nload("@lbm//:jest.bzl", "jest_test")\njest_test(\n name = "test",\n srcs = glob(\n include = ["**/*.ts"],\n ),\n jest_config = "@lbm//:jest.config.js",\n deps = [\n "//packages/enums/src:lib",\n "//packages/hello/src:lib",\n "@npm//faker",\n "@npm//@types/faker",\n "@npm//express",\n "@npm//@types/express",\n "@npm//jest",\n "@npm//ts-jest",\n "@npm//@types/jest",\n ],\n)\n\nts_library(\n name = "lib",\n srcs = glob(\n include = ["**/*.ts"],\n exclude = ["**/*.spec.ts"]\n ),\n deps = [\n "//packages/enums/src:lib",\n "//packages/hello/src:lib",\n "@npm//faker",\n "@npm//@types/faker",\n "@npm//express",\n "@npm//@types/express",\n ],\n)\n\nnodejs_image(\n name = …Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 9 应用程序,刚刚向组件添加了一个小型单元测试。describe但 VSCode 无法识别, beforeEach,等类型it。虽然我有一个tsconfig.spec.json文件,jasmine其types定义如下:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": ["jasmine", "node", "jest"]
},
"files": ["src/test.ts", "src/polyfills.ts"],
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}
Run Code Online (Sandbox Code Playgroud)
我得到的实际错误如下:
Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.ts(2582)
Run Code Online (Sandbox Code Playgroud)
@types/jasmine通过重新安装yarn add -D @types/jasminejasmine到tsconfig.jsontypestypes从tsconfig.spec.json中删除定义我想为我的 Angular 应用程序设置 Jest 测试。所以我按照jest-preset-angular 的说明进行操作。但是当我使用 Bazel (此目标)测试应用程序时,出现以下错误:
\n\nFAIL services/client/src/app/app.component.spec.ts\n \xe2\x97\x8f AppComponent \xe2\x80\xba should create the app\n\n TypeError: Cannot read property \'ngModule\' of null\n\n at isModuleWithProviders (../packages/core/src/render3/jit/module.ts:530:37)\n at expandModuleWithProviders (../packages/core/src/render3/jit/module.ts:523:7)\n at Array.map (<anonymous>)\n at Function.get (../packages/core/src/render3/jit/module.ts:124:29)\n at getNgModuleDef (../packages/core/src/render3/definition.ts:761:27)\n at verifySemanticsOfNgModuleDef (../packages/core/src/render3/jit/module.ts:183:19)\n at Function.get (../packages/core/src/render3/jit/module.ts:147:22)\n at R3TestBedCompiler.Object.<anonymous>.R3TestBedCompiler.applyProviderOverridesToModule (../../packages/core/testing/src/r3_test_bed_compiler.ts:398:49)\n at R3TestBedCompiler.Object.<anonymous>.R3TestBedCompiler.compileTestModule (../../packages/core/testing/src/r3_test_bed_compiler.ts:622:10)\n at R3TestBedCompiler.Object.<anonymous>.R3TestBedCompiler.finalize (../../packages/core/testing/src/r3_test_bed_compiler.ts:243:10)\n at TestBedRender3.get [as testModuleRef] (../../packages/core/testing/src/r3_test_bed.ts:371:43)\n at TestBedRender3.Object.<anonymous>.TestBedRender3.inject (../../packages/core/testing/src/r3_test_bed.ts:270:25)\n at TestBedRender3.Object.<anonymous>.TestBedRender3.createComponent (../../packages/core/testing/src/r3_test_bed.ts:326:40)\n at Function.Object.<anonymous>.TestBedRender3.createComponent (../../packages/core/testing/src/r3_test_bed.ts:176:33)\n at services/client/src/app/app.component.spec.ts:14:29\n at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (../npm/node_modules/zone.js/dist/zone.js:386:30)\n …Run Code Online (Sandbox Code Playgroud) 我有一个 monorepo,我正在使用yarn 工作区和lerna来管理它。直到现在我都没有问题。我需要知道自上次发布以来所有更改的包。
所以我运行lerna changed(docs),但这是它返回的内容:
info cli using local version of lerna
lerna notice cli v3.16.4
lerna info Looking for changed packages since v0.3.0
lerna info No changed packages found
Run Code Online (Sandbox Code Playgroud)
同样,lerna 在运行时也找不到任何包lerna list(docs):
info cli using local version of lerna
lerna notice cli v3.16.4
lerna success found 0 packages
Run Code Online (Sandbox Code Playgroud)
好像有什么东西坏了。但是我在我的设置中找不到任何问题。
??? lerna.json
??? package.json
??? packages
? ??? enums
? ??? event-sourcing
? ??? …Run Code Online (Sandbox Code Playgroud) monorepo ×4
typescript ×3
angular ×2
bazel ×2
javascript ×2
jestjs ×2
kubernetes ×2
node.js ×2
unit-testing ×2
amazon-simple-email-service ×1
aws-sdk ×1
busboy ×1
css ×1
css-grid ×1
email ×1
html ×1
https ×1
jasmine ×1
lerna ×1
npm-package ×1
sass ×1