How to count the amount of rows in MariaDB fast

If you need to find the fastest way to count the number of rows in a massive MariaDB, or MySQL table, then you can do the following instead of performing a select count() query: 1 show table status like '<TABLE_NAME>' This will provide you with a table of information about the table statistics, including the amount of rows.

How to find the Product of Consecutive Fib Numbers in Python

0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, … This is the Van Eck’s Sequence. Let’s go through it step by step. Term 1: The first term is 0. Term 2: Since we haven’t seen 0 before, the second term is 0. Term 3: Since we had seen a 0 before, one step back, the third term is 1 Term 4: Since we haven’t seen a 1 before, the fourth term is 0 Term 5: Since we had seen a 0 before, two steps back, the fifth term is 2.

How to Solve Van Eck's Sequence in Python

0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, … This is the Van Eck’s Sequence. Let’s go through it step by step. Term 1: The first term is 0. Term 2: Since we haven’t seen 0 before, the second term is 0. Term 3: Since we had seen a 0 before, one step back, the third term is 1 Term 4: Since we haven’t seen a 1 before, the fourth term is 0 Term 5: Since we had seen a 0 before, two steps back, the fifth term is 2.

How to Solve: Help the Bookseller Challenge in Python

A bookseller has lots of books classified in 26 categories labeled A, B, … Z. Each book has a code c of 3, 4, 5 or more characters. The 1st character of a code is a capital letter which defines the book category. In the bookseller’s stocklist each code c is followed by a space and by a positive integer n (int n >= 0) which indicates the quantity of books of this code in stock.

How to solve AWS MediaPackage PackagingGroup Quota Limit

If you are using AWS Elemental MediaPackage and hit the following error, then you need to either do one of the following: Error: error waiting for CloudFormation Stack (arn:aws:cloudformation:eu-west-1:800417762774:stack/dev-MediaPackage-Vod-1/511fc7a0-a092-11ed-b853-068baf6ac251) create: failed to create CloudFormation stack, delete requested (DELETE_COMPLETE): ["The following resource(s) failed to create: [PackagingGroup]. Delete requested by user." "Resource handler returned message: \"Limit exceeded for resource of type 'AWS::MediaPackage::PackagingGroup'. Reason: You reached the quota for resource=PackagingGroup. Delete the resources that you don?

How to Run Cdk Bootstrap

To bootstrap an AWS CDK environment, you simply need to do the following: 1 npx aws-cdk bootstrap …for each environment that you would like the CD to operate within. This will deploy all the required prerequisites to the AWS account, such as the: An Amazon S3 bucket for storing files and IAM roles that grant permissions needed to perform deployments. The required resources are defined in an AWS CloudFormation stack, called the bootstrap stack, which is usually named CDKToolkit.

How to Get Account Number from AWS Lambda

If you need to get the current Account Number, or Account ID from within a Lambda execution, then you can access invoked_function_arn from the context and return the associated value as follows: 1 aws_account_id = context.invoked_function_arn.split(":")[4]

Summary of the Frequently Used AWS STS API calls

AssumeRole – is useful for allowing existing IAM users to access AWS resources that they don’t already have access to. For example, the user might need access to resources in another AWS account. It is also useful as a means to temporarily gain privileged access—for example, to provide multi-factor authentication (MFA). You must call this API using existing IAM user credentials. AssumeRoleWithWebIdentity – returns a set of temporary security credentials for federated users who are authenticated through a public identity provider.

Understanding Locking and Conditional Writes in AWS DynamoDB

Optimistic locking is a strategy to ensure that the client-side item that you are updating (or deleting) is the same as the item in DynamoDB. Optimistic concurrency depends on checking a value upon save to ensure that it has not changed. If you use this strategy, then your database writes are protected from being overwritten by the writes of others — and vice-versa. By default, the DynamoDB write operations (PutItem, UpdateItem, DeleteItem) are unconditional: each of these operations will overwrite an existing item that has the specified primary key.

AWS CodeDeploy Deployment Type Options

CodeDeploy provides two (2) deployment type options: Option 1 – In-place Deployment In-place deployment: The application on each instance in the deployment group is stopped, the latest application revision is installed, and the new version of the application is started and validated. You can use a load balancer so that each instance is deregistered during its deployment and then restored to service after the deployment is complete. Only deployments that use the EC2/On-Premises compute platform can use in-place deployments.

Defining Amazon ECS Task Placement Strategies

Amazon ECS supports the following task placement strategies: binpack – Place tasks based on the least available amount of CPU or memory. This minimizes the number of instances in use. random – Place tasks randomly. spread – Place tasks evenly based on the specified value. Accepted values are attribute key-value pairs, instanceId, or host.

Deployment methods in AWS Elastic Beanstalk

– All at once – Deploy the new version to all instances simultaneously. All instances in your environment are out of service for a short time while the deployment occurs. – Rolling – Deploy the new version in batches. Each batch is taken out of service during the deployment phase, reducing your environment’s capacity by the number of instances in a batch. – Rolling with additional batch – Deploy the new version in batches, but first launch a new batch of instances to ensure full capacity during the deployment process.

How to update NTP to sync clock on Linux

If you need to sync the clock on Linux using the central NTP clock service, you can do the following: 1 2 3 sudo service ntp stop sudo ntpd -gq sudo service ntp start The -gg flags do the following: Tell g flag tells the NTP Daemon to correct the time regardless of the offset The q flag tells it to exit immediately after setting the time

How to Find IP Address Ranges used by Amazon S3

You can query the ip-ranges Amazon AWS URL, and parse the results through jq as follows: Generic S3 IP Ranges Query: 1 curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="S3")' Response: 1 2 3 4 5 6 7 8 9 10 11 { "ip_prefix": "3.5.140.0/22", "region": "ap-northeast-2", "service": "S3", "network_border_group": "ap-northeast-2" } { "ip_prefix": "52.219.170.0/23", "region": "eu-central-1", "service": "S3", <truncated> Region Specific S3 IP Ranges Query: 1 curl -s https://ip-ranges.

How to Find the nth Reverse Number in Java

The challenge Reverse Number is a number which is the same when reversed. For example, the first 20 Reverse Numbers are: 1 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101 Task You need to return the nth reverse number. (Assume that reverse numbers start from 0 as shown in the example.) Notes 1 < n <= 100000000000 The solution in Java Option 1:

How to Find the Sum of Intervals in Java

The challenge Write a function called sumIntervals/sum_intervals() that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once. Intervals Intervals are represented by a pair of integers in the form of an array. The first value of the interval will always be less than the second value. Interval example: [1, 5] is an interval from 1 to 5. The length of this interval is 4.

How to Find the Stray Number in Python

The challenge You are given an odd-length array of integers, in which all of them are the same, except for one single number. Complete the method which accepts such an array, and returns that single different number. The input array will always be valid! (odd-length >= 3) Examples 1 2 [1, 1, 2] ==> 2 [17, 17, 3, 17, 17, 17, 17] ==> 3 The solution in Python Option 1:

[Solved] jsii.errors.JSIIError: docker exited with status 1

If you get the following error while running AWS CDK: 1 2 raise JSIIError(resp.error) from JavaScriptError(resp.stack) jsii.errors.JSIIError: docker exited with status 1 Then you can resolve it as follows: How to solve docker exited with status 1 error Make sure that your local Docker client is running. Start docker on the local machine and CDK will be able to make the Docker connections required.

How to Filter a Number in C

The challenge The number has been mixed up with the text. Your goal is to retrieve the number from the text, can you return the number back to its original state? Task Your task is to return a number from a string. Details You will be given a string of numbers and letters mixed up, you have to return all the numbers in that string in the order they occur.