小编agu*_*ina的帖子

Atom编辑器缩进大小空格?

我使用的是OSX El Capitan和Atom 1.2.4.我还安装了"tabs-to-spaces"软件包.

我试图设置编辑器缩进并使标签为2个空格.但是我无法完成这项工作,这是我的设置

在此输入图像描述

在此输入图像描述

谢谢

atom-editor

2
推荐指数
1
解决办法
7453
查看次数

如何在 GKE ingress nginx 中设置域

我在 GKE 中有一个集群,它正在运行,一切似乎都在运行。如果我转发端口,我可以看到容器正在工作。

我无法从 namecheap 设置我拥有的域。

这些是我遵循的步骤

  1. 在 Namecheap 中,我为域设置了一个自定义 dns
ns-cloud-c1.googledomains.com.
ns-cloud-c2.googledomains.com.
ns-cloud-c3.googledomains.com.
ns-cloud-c3.googledomains.com.
Run Code Online (Sandbox Code Playgroud)

我使用这封信c是因为集群位于一个c区域中(我不确定这是否正确)

  1. 因为我试图设置为安全网站,所以我安装了 nginx 入口控制器
kubectl create clusterrolebinding cluster-admin-binding \
  --clusterrole cluster-admin \
  --user $(gcloud config get-value account)
Run Code Online (Sandbox Code Playgroud)

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.46.0/deploy/static/provider/cloud/deploy.yaml
Run Code Online (Sandbox Code Playgroud)
  1. 我应用了issuer.yml
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
 name: letsencrypt-prod
 namespace: cert-manager
spec:
 acme:
   # The ACME server URL
   server: https://acme-v02.api.letsencrypt.org/directory
   # Email address used for ACME registration
   email: example@email.com
   # Name of a secret used to store the ACME …
Run Code Online (Sandbox Code Playgroud)

kubernetes google-kubernetes-engine kubernetes-ingress nginx-ingress gke-networking

2
推荐指数
1
解决办法
1909
查看次数

typescript 谷歌地图错误

我正在通过Udemy 课程学习打字稿。我做了一个使用谷歌地图的练习。

然后,当我使用时nvm,我将节点版本更新为 16。当我更新节点时,我执行了将 typescript 安装到较新版本的命令

$ npm install -g typescript ts-node
$ npm install -g @types/node @types/google.maps
Run Code Online (Sandbox Code Playgroud)

我开始了一项新练习,我只需编写控制台日志

索引.ts

console.log('Hi there')
Run Code Online (Sandbox Code Playgroud)

那么我应该编译该文件

$ ts index.ts
Run Code Online (Sandbox Code Playgroud)

生成index.js了,但我也听到了错误的声音

...
../../../../../../node_modules/@types/googlemaps/reference/polygon.d.ts:51:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'path' must be of type '(LatLngLiteral | LatLng)[] | MVCArray<any>', but here has type 'LatLng[] | MVCArray<LatLng> | LatLngLiteral[]'.

51         path?: MVCArray<LatLng> | LatLng[] | LatLngLiteral[];
           ~~~~

  ../../../../../../node_modules/@types/google.maps/index.d.ts:5066:5
    5066     path?: google.maps.MVCArray<any>|null|
             ~~~~
    'path' was …
Run Code Online (Sandbox Code Playgroud)

google-maps npm typescript

2
推荐指数
1
解决办法
2586
查看次数

AngularJS $ http.post服务器不允许使用方法OPTIONS的请求

我正在尝试对服务器进行HTTP POST.

我必须发送的数据是一个json对象.

问题是$ http.post在角度覆盖带有选项的方法.

我可以做这个配置

.config(['$httpProvider', function ($httpProvider) {
  //Reset headers to avoid OPTIONS request (aka preflight)
  $httpProvider.defaults.headers.common = {};
  $httpProvider.defaults.headers.post = {};
  $httpProvider.defaults.headers.put = {};
  $httpProvider.defaults.headers.patch = {};
}])
Run Code Online (Sandbox Code Playgroud)

并从选项更改为POST,但我无法将内容类型设置为"application/json",并且我收到"415不支持的媒体类型"

谢谢

angularjs angular-http

1
推荐指数
1
解决办法
1万
查看次数

Nodejs 将日志与 PM2 和 Winston 合并

我只想将所有信息记录在一个文件中。我正在使用 pm2“0.12.1”和“winston”:“0.8.3”。

这是我的温斯顿代码

var winston = require('winston');

var customLoggerLevels = {
  levels: {
    trace: 0,
    debug: 1,
    info: 2,
    warn: 3,
    error: 4
  },
  colors: {
    trace: 'blue',
    debug: 'green',
    info: 'grey',
    warn: 'yellow',
    error: 'red'
  }
};

var logger = new (winston.Logger)({
  levels: customLoggerLevels.levels
});
Run Code Online (Sandbox Code Playgroud)

和我的生态系统.json 的一部分

 "apps" : [
    {
      "name"      : "myapp",
      "script"    : "server.js",
      "instances"  : "1",
      "err_file"    : "myapp.log",
      "out_file"    : "myapp.log",
      "env": {
        "NODE_ENV": "development",
        "PORT": 4000
      },
      "env_production" : {
        "NODE_ENV": "production",
        "PORT": …
Run Code Online (Sandbox Code Playgroud)

node.js winston pm2

1
推荐指数
1
解决办法
7582
查看次数

如何建模与Slick的反向关系?

我试图在Slick 3.1.0-M1中模拟多对多的关系

这是Slick文档的示例

// Definition of the SUPPLIERS table
class Suppliers(tag: Tag) extends Table[(Int, String, String, String, String, String)](tag, "SUPPLIERS") {
  def id = column[Int]("SUP_ID", O.PrimaryKey) // This is the primary key column
  def name = column[String]("SUP_NAME")
  def street = column[String]("STREET")
  def city = column[String]("CITY")
  def state = column[String]("STATE")
  def zip = column[String]("ZIP")
  // Every table needs a * projection with the same type as the table's type parameter
  def * = (id, name, street, city, state, zip)
}
val …
Run Code Online (Sandbox Code Playgroud)

scala slick

1
推荐指数
1
解决办法
141
查看次数

Scala,用于理解和EitherT

我的技术堆栈是

  • Play Framework 2.6
  • Scala 2.12.6
  • Play-Slick 3.0.0
  • 猫1.4.0

我试图实现此功能来更新数据库中的行

def update(userId: Long, user: User) = {
  (for {
    _ <- EitherT(updateUser(userId, user))
    user: User <- EitherT(findById(userId))
    userProfile: userProfile <- EitherT(userProfileRepository.findById(user.userProfileId))
  } yield (user, userProfile).map {
    case (user: User, userProfile: UserProfile) =>
      val response = new UserResponse(user, userProfile)
      Right(response)
    case error =>
      val str = s"update failure: $error"
      Left(str)
  }
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用EitherT编译此代码时,我得到了

value withFilter不是cats.data.EitherT的成员

scala scala-cats

1
推荐指数
1
解决办法
268
查看次数

转储在 docker 容器上运行的 mongo 数据库

我有这个docker-compose.yml文件,我在其中运行 mongo 容器

version: '3'

services:

  appapi:
    container_name: appapi
    image: strapi/strapi:3.1.3
    environment:
      DATABASE_CLIENT: ${APPAPI_DATABASE_CLIENT}
      DATABASE_HOST: ${APPAPI_DATABASE_HOST}
      DATABASE_PORT: ${APPAPI_DATABASE_PORT}
      DATABASE_NAME: ${APPAPI_DATABASE_NAME}
      DATABASE_USERNAME: ${APPAPI_DATABASE_USERNAME}
      DATABASE_PASSWORD: ${APPAPI_DATABASE_PASSWORD}
    ports:
      - 1337:1337
    volumes:
      - ./app:/srv/app
    depends_on:
      - appmongo

  appmongo:
    container_name: appmongo
    image: mongo:4.4.0
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${APPDB_MONGO_INITDB_ROOT_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${APPDB_MONGO_INITDB_ROOT_PASSWORD}
    ports:
      - "27027:27017"
    volumes:
      - ./data/db:/data/db
Run Code Online (Sandbox Code Playgroud)

我想备份运行转储的数据库

docker run -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin --rm mongo mongodump --host mongoapp:27027 --archive --gzip | cat > ./mongodumps/dump_$(date '+%d-%m-%Y_%H-%M-%S').gz
Run Code Online (Sandbox Code Playgroud)

我尝试修改前面的命令,但无法连接并进行转储,我得到

2020-08-15T19:27:04.870 + 0000失败:无法创建会话:无法连接到服务器:服务器选择错误:服务器选择超时,当前拓扑:{类型:单,服务器:[{地址:mongoapp:27027 ,类型:未知,状态:已连接,平均 RTT:0,最后一个错误:connection() :拨打 tcp:在 …

mongodb docker

1
推荐指数
1
解决办法
5451
查看次数

Prisma Typescript 里面包含 where 子句?

我正在尝试通过 Prisma 查询数据库(Postgres)。我的查询是

const products = await prisma.products.findMany({
  where: { category: ProductsCategoryEnum[category] },
  include: {
    vehicles: {
      include: {
        manufacturers: { name: { in: { manufacturers.map(item => `"${item}"`) } } },
      },
    },
  },
});
Run Code Online (Sandbox Code Playgroud)

错误信息是

输入 '{ name: { in: { 制造商: string; ““: 任何; }; }; }' 不可分配给类型 'boolean | 制造商Args'。对象文字只能指定已知属性,并且“manufacturersArgs”类型中不存在“name”。ts(2322)

厂家有领域name,有独特性;我不确定为什么这不起作用或者如何更新此代码以便能够查询数据库。这就像我应该将这些值转换为 Prisma 参数。

prisma prisma2

1
推荐指数
1
解决办法
8287
查看次数