Skip to content

Instantly share code, notes, and snippets.

@notionquest
notionquest / ScanTable.java
Created May 25, 2017 15:34
AWS DynamoDB Full Table Scan using Java
import java.util.List;
import java.util.Map;
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.ScanRequest;
import com.amazonaws.services.dynamodbv2.model.ScanResult;
@notionquest
notionquest / PrimeNumber.java
Created May 30, 2017 21:00
Prime Number using Java 8 Stream
public boolean isPrime(int inputValue) {
if (inputValue <= 1) {
return false;
}
if (inputValue == 2) {
return true;
}
@notionquest
notionquest / Git_create_branch_error_resolution.txt
Last active December 20, 2023 03:15
Git create branch error src refspec matches more than one
If you get the below error when you try to create branch, you can use the below command to resolve it.
Error:
error: src refspec 9.0.1 matches more than one.
Solution:
git push origin refs/heads/branchName:refs/heads/branchName
@notionquest
notionquest / DynamoDB_CloudFormation_Autoscaling_Policy.json
Created July 6, 2017 22:21
DynamoDB CloudFormation Policy for Auto scaling
{
"Type" : "AWS::ApplicationAutoScaling::ScalingPolicy",
"Properties" : {
"PolicyName" : "MyScalingPolicy",
"PolicyType" : "TargetTrackingScaling",
"ResourceId" : "arn:aws:dynamodb:us-east-1:123456789012:table/books_table",
"ScalableDimension" : "dynamodb:table:WriteCapacityUnits",
"ServiceNamespace" : "dynamodb",
"TargetTrackingScalingPolicyConfiguration" : {
"PredefinedMetricSpecification": {
//Run the below script on http://localhost:8000/shell/
var dynamodb = new AWS.DynamoDB({
region: 'us-east-1',
endpoint: "http://localhost:8000"
});
var params = {
};
@notionquest
notionquest / DescribeTable.js
Last active October 19, 2017 15:47
Describe table present in dynamodb local
//Run the below script on http://localhost:8000/shell/
var dynamodb = new AWS.DynamoDB({
region: 'us-east-1',
endpoint: "http://localhost:8000"
});
var params = {
TableName: "Movies"
};
@notionquest
notionquest / largest_file_in_dir.ksh
Created October 20, 2017 09:14
Unix command to find the largest file in directory
du -hsx ridf* | sort -rh | head -10
@notionquest
notionquest / Creating DynamoDB using Cloudformation.yml
Last active November 16, 2017 13:58
Creating DynamoDB using Cloudformation
Resources:
ItemsTable:
Type: "AWS::DynamoDB::Table"
Properties:
TableName: "InvoiceConfig"
AttributeDefinitions:
- AttributeName: "providerName"
AttributeType: "S"
KeySchema:
- AttributeName: "providerName"
@notionquest
notionquest / ArrayRotate.java
Created March 3, 2018 08:11
Rotate the integer array by n positions by left
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
@notionquest
notionquest / dynamodb_scan_table_local.js
Created June 1, 2018 12:53
dynamodb scan table local in shell
var dynamodb = new AWS.DynamoDB({
region: 'us-east-1',
endpoint: "http://localhost:8000"
});
var params = {
TableName: "Movies",
};
function doPrint(response) {