This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseQueryValidator { | |
private static List<String> extractTableAliases(SqlNode node) { | |
final List<String> tables = new ArrayList<>(); | |
// If order by comes in the query. | |
if (node.getKind().equals(SqlKind.ORDER_BY)) { | |
// Retrieve exact select. | |
node = ((SqlSelect) ((SqlOrderBy) node).query).getFrom(); | |
} else { | |
node = ((SqlSelect) node).getFrom(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class AppConfig { | |
@Bean | |
public ScheduledExecutorService getScheduledExecutorService() { | |
return Executors.newSingleThreadScheduledExecutor(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PresignedLinkGenerator { | |
private static final int EXPIRATION_TIME_IN_MILLISECONDS = 1000 * 60 * 60; // 1 hour | |
private static final String SIGNER_TYPE = "AWSS3V4SignerType"; | |
private String KmsKeyARN = "<EncryptionKeyARN>"; | |
public URL generatePresignedLink(final String bucketName, final String objectKey, final HttpMethod httpMethod) throws Exception { | |
final Region currentRegion = Regions.getCurrentRegion() == null ? Region.getRegion(Regions.US_WEST_2) : Regions.getCurrentRegion(); | |
final AmazonS3 s3client = AmazonS3ClientBuilder.standard() | |
.withClientConfiguration(new ClientConfiguration().withSignerOverride(SIGNER_TYPE)) | |
.withRegion(currentRegion.getName()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public S3FileWriter { | |
public String write(final ResultSet resultSet) { | |
HttpURLConnection connection = null; | |
try { | |
StringBuilder csvContent = new StringBuilder(); | |
connection = httpURLConnectionHelper.newHttpURLConnection("<PRESIGNED_PUT_URL_FOR_FILE>"); | |
try (OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream()); | |
BufferedWriter writer = new BufferedWriter(out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script generate comma separated dates for last month in yyyy-mm-dd format. | |
# Ex: | |
# "2018-04-01,2018-04-02,2018-04-03,2018-04-04,2018-04-05,2018-04-06,2018-04-07, | |
# 2018-04-08,2018-04-09,2018-04-10,2018-04-11,2018-04-12,2018-04-13,2018-04-14, | |
# 2018-04-15,2018-04-16,2018-04-17,2018-04-18,2018-04-19,2018-04-20,2018-04-21, | |
# 2018-04-22,2018-04-23,2018-04-24,2018-04-25,2018-04-26,2018-04-27,2018-04-28, | |
# 2018-04-29,2018-04-30" | |
set `date +%m" "%Y` | |
CURMTH=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gson.Gson; | |
import com.google.gson.JsonArray; | |
import com.google.gson.JsonObject; | |
import org.apache.http.client.ClientProtocolException; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.impl.client.HttpClientBuilder; | |
import org.apache.http.util.EntityUtils; | |
import org.springframework.http.MediaType; | |
import org.springframework.web.util.UriComponents; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from datetime import datetime, timedelta | |
client = boto3.client('iam') | |
users = client.list_users() | |
flaggedUsers = [] | |
flaggedUserThreshold = 90 | |
for key in users['Users']: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set +x; | |
SHOW_THRESHOLD_BREACHED_ONLY=$1; | |
SEPARATOR=","; | |
LAST_ACTIVITY="LastActivity:"; | |
ACCESS_KEY_AGE="AccessKeyAge:"; | |
flagged="true"; | |
notFlagg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: 'A sample template for VPC with one public and one private subnet' | |
Parameters: | |
petClinicPublicSSHKey: | |
Default: pc-public | |
Description: 'Name of an existing EC2 KeyPair to enable SSH access into ec2 instance on public subnet' | |
Type: 'AWS::EC2::KeyPair::KeyName' | |
petClinicPrivateSSHKey: | |
Default: pc-private | |
Description: 'Name of an existing EC2 KeyPair to enable SSH access into ec2 instance on private subnet' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using AWS Route 53 DNS: | |
1. As active and passive failover setup: Make 2 record sets with the same domain name and set one as primary and the other as secondary under Routing Policy Type "Failover". | |
2. As round-robin DNS setup: Make 2 record sets with same domain name and set weight to 50 percent on both under Routing Policy Type "Weighted". | |
OlderNewer