小编Tin*_*a J的帖子

如何在 Boto3 中正确创建并附加 ELB

我是亚马逊Boto3API 的新手。我创建了如下所示的示例架构的基本图,其中包含一个 ELB、4 个实例、2 个子网和 2 个不同可用区中的 2 个目标组(每个目标组中有 2 个实例)。

在此输入图像描述

我知道如何创建 EC2 实例、目标组、子网和 ELB。但我并不清楚要使用什么ELB功能。

如何将 ELB 连接到其他组件?基本上,如何向 ELB 添加实例?我不确定现在需要什么后续步骤和功能。

到目前为止,这是我的简单代码:

def create_load_balancer(load_balancer_name, vpcid, subnets, security_group):
    command = "aws elbv2 create-load-balancer --name " + load_balancer_name + " --subnets " + subnets + " --security-groups " + security_group+" --scheme internet-facing --type application"
    response = os.popen(command).read()

// ....created 4 instances, subnets, and security groups ...

//now ELB:
#Load Balancer
elb = boto3.client('elbv2')
elb.create_target_group( Name='boto3-target-a', Protocol='HTTP',  Port=80, VpcId=vpc.id)
elb.create_target_group( Name='boto3-target-b', Protocol='HTTP', …
Run Code Online (Sandbox Code Playgroud)

python amazon-web-services amazon-elb boto3 aws-elb

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

在Python 3.6中从CSV绘制纬度经度

我正在尝试从CSV地图上的文件中绘制具有这种格式(第一列和第二列)的大量纬度经度值:

在此处输入图片说明

我正在使用python 3.6(显然有些库Basemap在此版本上不起作用)。

我怎样才能做到这一点?

python google-maps geolocation google-maps-api-3 folium

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

使用 FFmpeg 在特定时间将一个视频叠加在另一个视频上

我正在尝试将一个视频与另一个视频叠加。我遵循了此处发布的原始命令OP 。它有效,但它覆盖了从时间 0 开始的视频:

ffmpeg -i 720480.mp4 -i sdbug.mov -filter_complex "[0:0][1:0]overlay[out]" -shortest -map [out] -map 0:1 -pix_fmt yuv420p -c:a copy -c:v libx264 -crf 18  new.mp4 
Run Code Online (Sandbox Code Playgroud)

我尝试了正确的答案来指定时间,但它对我不起作用:1)覆盖大约在第二个开始12,2)覆盖完成后不播放视频。

ffmpeg -i 720480.mp4 -i sdbug.mov -filter_complex "[1:v]setpts=PTS+10/TB[a]; [0:v][a]overlay=enable=gte(t\,5):shortest=1[out]" -map [out] -map 0:a -c:v libx264 -crf 18 -pix_fmt yuv420p -c:a copy new.mp4
Run Code Online (Sandbox Code Playgroud)

最近有什么变化吗FFmpeg?!为什么它不起作用?

这是该命令的输出(它完成得非常快):

ffmpeg version N-92906-g54109b1d14 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181201
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype …
Run Code Online (Sandbox Code Playgroud)

video overlay ffmpeg video-processing

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

不兼容的类型:List<ArrayList<Integer>> 不能转换为 List<List<Integer>>

我正在尝试运行以下代码,它打印给定集合的所有子集。当我将subsets(int[] nums)函数的返回类型更改为ArrayList<ArrayList<Integer>> subsets(int[] nums),但不适用于List<List<Integer>> subsets(int[] nums). 我需要将返回类型设为List<List<Integer>>. 我该如何解决?

public class TestPractice {
    public static void main(String[] args){
        int[] x = {1,2};
        System.out.println(subsets(x));
    }
    
    public static List<List<Integer>> subsets(int[] nums) {
        List<ArrayList<Integer>> subsets = new ArrayList<ArrayList<Integer>>();
        if (nums.length ==1){
            ArrayList<Integer> subset1 = new ArrayList<Integer>();
            ArrayList<Integer> subset2 = new ArrayList<Integer>();
            subset2.add(nums[0]);
            subsets.add(subset1);
            subsets.add(subset2);
            return subsets;
        }
        int[] nums_1 = new int[nums.length-1];
        for(int i = 0; i< nums.length-1; i++) {
        nums_1[i]=nums[i];
        }
        
        List<ArrayList<Integer>> subsets2= subsets(nums_1); 
        ArrayList<ArrayList<Integer>> …
Run Code Online (Sandbox Code Playgroud)

java arraylist

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

使用 AWS Java SDK v2.x 的 Cognito SRP

我需要使用 AWS cognito 获取令牌,然后调用秘密 API。我有这个可以运行的 python 脚本。如何将其转换为 Java SDK v2?

我找到了一个使用 Java SDK V1 的示例,但它不适用于 v2。

from warrant.aws_srp import AWSSRP
username = "user"
password = "pass"
client_id = "xxxxxxxxxxxxxxxxx"
user_pool_id = "us-east-1_xxx123445"
region = "us-east-1"
aws = AWSSRP(username=username, password=password, pool_id=user_pool_id, client_id=client_id)
tokens = aws.authenticate_user()
print(tokens)
Run Code Online (Sandbox Code Playgroud)

java amazon-web-services amazon-cognito aws-java-sdk-2.x

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

我的Java项目的gradle构建错误

我正在尝试构建位于此处的Java项目:https : //github.com/garlicPasta/dotServer

我是Gradle的新手。我现在下载了最新的Gradle(v4.0)。我在路径中添加了binGradle文件夹(包括gradle.bat),以便可以在任何地方运行gradle命令。该项目似乎需要Google protobuf,并会自动下载。但是,当我启动命令时gradle build,出现以下错误:

> Configure project :
You are using Gradle 4.0:  This version of the protobuf plugin works with Gradle version 2.12+


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'dotServer'.
> No signature of method: org.gradle.api.internal.tasks.DefaultTaskInputs.source() is applicable for argument types: (com.google.protobuf.gradle.ProtobufSourceDirectorySet_Decorated) values: [main Proto source]
  Possible solutions: collect(), use([Ljava.lang.Object;)
Run Code Online (Sandbox Code Playgroud)

问题出在哪里?有人可以尝试构建项目并让我知道吗?

java classpath gradle build.gradle

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

在Java中深度复制NavigableMap

我有NavigableMap以下格式:

NavigableMap <Long, String> mymap = new ConcurrentSkipListMap <Long, String> ();
//.......some operations

NavigableMap <Long, String> newmap;
//clone mymap into newmap;
Run Code Online (Sandbox Code Playgroud)

如何将内容深层复制/克隆mymapnewmap?Java 8应该可以正常使用.

java hashmap deep-copy concurrenthashmap java-stream

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

使用String.Split()方法的Java异常:悬空元字符

我正在尝试解析URL字符串(我通过HTML Get方法接收)并提取嵌入的选项.我想知道它为什么会抛出异常s=s.split("?")[0];

Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0

public static void main(String[] args) {
    String s= "run.html?yse=yse1&tracefile=capacity.1Mbps_c50.txt&fd=100&rd=100&down=1&up=1&per=0.00001";
    s=s.split("?")[0];  //drops error
    String ss[]=s.split("&");
//this is a class I have that receives the array of splitted options.
    JavaRunEmulator j = new JavaRunEmulator(ss);
    System.out.println(j.getOutput());
}
Run Code Online (Sandbox Code Playgroud)

java regex

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