小编ryn*_*nop的帖子

如何为node.js实施AWS Elasticache自动发现

我是一个节点菜鸟,并试图了解如何在node.js应用程序中实现自动发现.我将使用群集模块,并希望每个工作进程保持最新(并持久连接到)弹性缓存节点.

由于没有共享内存的概念(如PHP APC),您是否必须拥有在每个工作程序中运行的代码,每隔X秒唤醒一次并以某种方式更新IP列表并重新连接内存缓存客户端?

今天人们如何解决这个问题?示例代码将非常感激.

amazon-web-services node.js amazon-elasticache

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

Angular2:如何在响应式表单输入上显示字符数

我正在使用Angular2反应形式,我希望textarea在用户输入时显示a的字符数.

我希望能够name.length在我的html中包含表单控件,如下所示:

<div class="form-group">
  <label for="incidentDescription">Brief Description of Incident</label>
  <textarea id="incidentDescription" formControlName="incidentDescription" required [attr.maxLength]="maxIncidentDescriptionLength"></textarea>
  <small><code>{{alaynaPage.incidentDescription.length}}</code> of <code>{{maxIncidentDescriptionLength}}</code> characters</small>
</div>
Run Code Online (Sandbox Code Playgroud)

这"工作"然而length形式控制滞后一个键击.因此,例如,如果我输入atextarea {{alaynaPage.incidentDescription.length}}是0.如果我然后键入b(所以字符串是ab){{alaynaPage.incidentDescription.length}}现在是1.

如何让它按预期工作?

我通过黑客工作,但必须有一个更简单的方法:

//in component:  
theLength: number = 0;
ngOnInit(): void {
    this.buildForm();

    (this.alaynaPageForm.controls['incidentDescription'] as FormControl).valueChanges.subscribe(value => {
      // do something with value here
      this.theLength = value.length;
    });
  }

//in my html:
<small class="form-text text-muted"><code>{{theLength}}</code> of <code>{{maxIncidentDescriptionLength}}</code> characters</small>
Run Code Online (Sandbox Code Playgroud)

javascript angular

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

如何通过SystemJs在Angular2中使用moment-timezone

我通过angular2-seed(使用SystemJS)使用Angular2并尝试加载时刻 - 时区并moment.tz.guess()专门使用.

我导入:

import * as moment from 'moment-timezone';
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我在浏览器中收到以下错误:

GET /node_modules/moment-timezone/data/packed/latest.json.js 404 (Not Found)

anuglar2种子的用途defaultJSExtensions我想这是为什么不正确的.js被加入,所以我想我可能只是将其关闭了moment-timezone在tools/config/project.config.ts像这样:

this.SYSTEM_BUILDER_CONFIG.packages['moment-timezone'] = {
  defaultExtension: false

//I have also tried:
      map: {
        '/node_modules/moment-timezone/data/packed/latest.json.js': '/node_modules/moment-timezone/data/packed/latest.json',
        '/node_modules/moment-timezone/data/packed/latest.json': '/node_modules/moment-timezone/data/packed/latest.json'
      }
};
Run Code Online (Sandbox Code Playgroud)

但是,这不起作用.我究竟做错了什么?

javascript momentjs systemjs angular

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

如何在 AWS CodeBuild 规范文件中为`parameter-store` 使用动态密钥?

我的 CodeBuild 中有一个 buildspec.yml 文件,我想从 EC2 Systems Manager Parameter Store 中读取值。CodeBuild 支持通过parameter-store规范文件中的属性执行此操作。

问题是,我不知道如何使用在执行 buidlspec 之前设置的环境变量。

下面是一个例子:

version: 0.2
env:
  variables:    
    RUNTIME: "nodejs8.10"
  #parameter-store vars are in the format /[stage]/[repo]/[branch]/[eyecatcher]/key
  parameter-store: #see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-syntax
    LAMBDA_EXECUTION_ROLE_ARN: "/${STAGE}/deep-link/${BRANCH}/GetUri/lambdaExecutionRoleArn"
    ENV_SAMPLE_KEY: "/${STAGE}/deep-link/${BRANCH}/GetUri/key1"

phases:
  install:
    commands:  
      ...
Run Code Online (Sandbox Code Playgroud)

如您所见,我正在执行 AWS 最佳实践,以对 EC2 Systems Manager Parameter Store 密钥进行命名间距。我想在我的所有阶段重复使用这个构建规范,所以硬编码不是一种选择。我在Value字符串中使用的变量EnvironmentVariables在我的 CodeBuild 项目中填充- 因此它们在规范运行之前可用。

如何使用非硬编码的东西动态填充Value参数存储Keys?

amazon-ec2 amazon-web-services aws-codepipeline aws-codebuild aws-parameter-store

5
推荐指数
2
解决办法
5294
查看次数

Angular 6 材质表原理图:如何从远程加载数据?

我正在使用材料表原理图,但不知道如何

我认为重要的部分是文件connect()中的方法datasource.ts。this.data只是一个数组。

  /**
   * Connect this data source to the table. The table will only update when
   * the returned stream emits new items.
   * @returns A stream of the items to be rendered.
   */
  connect(): Observable<any[]> {
    // Combine everything that affects the rendered data into one update
    // stream for the data-table to consume.
    const dataMutations = [
      observableOf(this.data),
      this.paginator.page,
      this.sort.sortChange
    ];

    // Set the paginators length
    this.paginator.length = this.data.length; …
Run Code Online (Sandbox Code Playgroud)

observable angular-material angular-material2 angular2-observables angular

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

AWS Athena:`msck repair table` 会产生费用吗?

我在 S3 中有 ORC 数据,如下所示:

s3://bucket/orc/clientId=client-1/year=2017/month=3/day=16/hour=20/
s3://bucket/orc/clientId=client-2/year=2017/month=3/day=16/hour=21/
s3://bucket/orc/clientId=client-3/year=2017/month=3/day=16/hour=22/
Run Code Online (Sandbox Code Playgroud)

我每小时运行一个 EMR 作业,将 S3 中的原始 JSON 转换为 ORC,并使用路径分区约定(上文)将其写出以供 Athena 摄取。EMR 作业完成后,我运行msck repair table以便 Athena 可以选择新分区。

我有3个相关的问题:

  1. msck repair table在这种情况下运行是否会在 AWS 中花费我的钱?
  2. AWS Docs 说 msck repair table可以超时。有没有办法可以在数据管道中迈出一步以继续运行此命令直到它成功完成?
  3. 我更愿意将分区手动添加到 Athena(因为我知道我正在处理的年、月、日、小时)。但是我不知道,clientId因为它们可能有 1-X 个,而且我不知道在运行 EMR 时存在哪些。是否有解决此问题的最佳实践方法(使用 Hive 或其他方法)?我可以进行 s3 api 调用以获取列表s3://bucket/org/并编写代码以迭代列表并手动添加。我希望有更简单的方法...

注意:当我说“手动添加分区”时,我的意思是做这样的事情:

ALTER TABLE <athena table> 
ADD PARTITION (clientId='client-1',year=2017,month=3,day=16,hour=20) 
location 's3://bucket/orc/clientId=client-1/year=2017/month=3/day=16/hour=20/';
Run Code Online (Sandbox Code Playgroud)

hive amazon-emr emr amazon-athena

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

如何在 NativeScript &lt;Button&gt; 中使用字体图标

尝试在<Button>.

例如:

<Button class="btn btn-primary fas" text="{{'fa-film' | fonticon}} Test"></Button>
Run Code Online (Sandbox Code Playgroud)

CSS:

.fas {
  font-family: 'Font Awesome 5 Free Solid', fa-solid-900;
}
Run Code Online (Sandbox Code Playgroud)

当使用Nativescript主题,它定义了font-family为.btn类。如您所知,iconfonts 也依赖于此font-family。

那么在上面的按钮中,如何将一个font-family应用于字符串 Test 而将另一个font-family应用于图标?

如果您使用 NativeScript Angular SASS 入门应用程序并在其中定义 .fas_app-common.scss并使用我上面的按钮,您将看到图标显示为 ?。这是因为.btn覆盖了font-family.

我可以通过为图标font-family提供更高的优先级来解决这个问题- 但这会阻止我为按钮上的文本字体设置样式。

按钮内字体图标的非原生脚本实现通过将元素(如<span>)作为子元素放置到<Button>. 示例在这里。

你怎么能用 NativeScript 做到这一点<Button>?

nativescript angular2-nativescript

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

无法从VPC中的实例连接到面向ELB的Internet

我有一个面向互联网的V2 ELB.当我从笔记本电脑连接到VPC时,它将请求路由到VPC中的实例.但是,当我尝试从同一VPC内的另一个实例连接到它时,安全组防火墙规则会阻止连接.

我可以将VPC中的实例连接到ELB的唯一方法是打开https端口(443)到世界各地.

我究竟做错了什么?

ELB(https://elb.domain.com)有以下attrs:

  • 面向互联网,V2(不是经典的ELB)
  • VPC:vpc-aaa
  • AZs:subnet-a,subnet-b
  • 监听器:443 - > 8080实例端口
  • 源安全组:my-vpc-elb,带有入站规则:
    • 443,来源:1.2.3.170/32(我的笔记本电脑IP)
    • 443,source:sg-a(我的vpc实例,无法连接的sg的名称)
    • 443,来源 <CIDR of vpc-aaa, 1.2.0.0/16>

从我的笔记本电脑,我可以放入https://elb.domain.com,一切正常.

我现在有另一个实例,其中以下的attrs无法连接到https://elb.domain.com:

  • 子网ID:subnet-a
  • 安全组:sg-a

为什么ELB安全组规则443, source: sg-a不允许连接?为什么只有在ELB安全组中允许443入站"所有流量"时它才有效?

amazon-web-services amazon-elb amazon-vpc

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

将压缩(lzo)数据从s3导入到hive

我将DynamoDB表导出为s3作为备份方式(通过EMR).当我导出时,我将数据存储为lzo压缩文件.我的hive查询如下,但基本上我在http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/EMR_Hive_Commands.html上执行了 "使用数据压缩将Amazon DynamoDB表导出到Amazon S3存储桶".

我现在想要反过来 - 拿走我的LZO文件并将它们放回蜂巢表中.你怎么做到这一点?我希望看到一些hive配置属性用于输入,但没有.我用Google搜索并发现了一些提示,但没有任何确定性,也没有任何效果.

s3中的文件格式为:s3:// [mybucket] /backup/year=2012/month=08/day=01/000000.lzo

这是我的HQL导出:

SET dynamodb.throughput.read.percent=1.0;
SET hive.exec.compress.output=true;
SET io.seqfile.compression.type=BLOCK;
SET mapred.output.compression.codec = com.hadoop.compression.lzo.LzopCodec;      

CREATE EXTERNAL TABLE hiveSBackup (id bigint, periodStart string, allotted bigint, remaining bigint, created string, seconds bigint, served bigint, modified string)
STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler' 
TBLPROPERTIES ("dynamodb.table.name" = "${DYNAMOTABLENAME}", 
"dynamodb.column.mapping" = "id:id,periodStart:periodStart,allotted:allotted,remaining:remaining,created:created,seconds:seconds,served:served,modified:modified");

CREATE EXTERNAL TABLE s3_export (id bigint, periodStart string, allotted bigint, remaining bigint, created string, seconds bigint, served bigint, modified string)
 PARTITIONED BY (year string, month string, …
Run Code Online (Sandbox Code Playgroud)

hive lzo amazon-web-services elastic-map-reduce emr

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

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

仅使用 Golang 中的环境变量初始化 Firebase Admin SDK

我正在尝试仅使用环境变量(无法访问文件系统)来初始化 Firebase Admin SDK 。

我有该service-account-file.json文件,并且可以通过以下方式使其在本地工作:

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-file.json"

...

myfile.go:
app, err := firebase.NewApp(context.Background(), nil)
Run Code Online (Sandbox Code Playgroud)

但是,我想将 的内容service-account-file.json放入环境变量中,并使用其值初始化 firebase Admin SDK。

有一个未解决的问题声称您可以通过CredentialsFromJSON来完成此操作,但我不太明白。

有人有这个工作吗?如果可以,您能举个例子吗?

go firebase firebase-admin

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