Skip to content

Instantly share code, notes, and snippets.

View ntantri's full-sized avatar
🔬

Nagaraj Tantri ntantri

🔬
View GitHub Profile
@ntantri
ntantri / SelectFiltersBuilderExample.java
Created January 10, 2022 13:29
Builder pattern usage with a real example
package org.java.sample.tutorials.designpatterns.builder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
public class SelectFiltersBuilderExample {
private final String advertiserID;
private final String campaignID;
@ntantri
ntantri / SelectFiltersComplexNonBuilderExample.java
Last active January 10, 2022 13:11
This class acts like a POJO for saving data for mandatory and optional parameters with multiple constructors or setters and getters
package org.java.sample.tutorials.designpatterns.builder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
/**
* SelectFiltersComplexClassExample class is a placeholder for storing information about UI
* based filter selection for fetching a set of results from backend.
* <p>
@ntantri
ntantri / get_s3_tags.py
Last active May 19, 2021 09:13
This script is useful to pull all the S3 bucket names and its relevant Tags from AWS S3 to a CSV file programmatically.
#!/bin/python
"""
This script is useful to pull all the S3 bucket names and it's relevant tags from AWS S3 to a CSV file programmatically.
Some highlights on this script:
* One has to provide all the tags which has to be read and converted to a CSV Header
* These tags are mentioned in TagSets class, wherein, the variables like: "OWNER", "TEAM" and all is available in S3 tags
* Create a CSV order in which format/sequence do you want the headers using "ORDER" array in TagSets
* Execute this script as `python get_s3_tags.py`
@ntantri
ntantri / process.sh
Created October 12, 2020 12:28 — forked from d6y/process.sh
Batch convert HTML to Markdown
#!/bin/bash
# Converts HTML from https://exportmyposts.jazzychad.net/ exports to Markdown
POSTS_DIR=/Users/richard/Desktop/d6y/posts
for file in $POSTS_DIR/*.html
do
echo $file
@ntantri
ntantri / trust_relationship.js
Created September 12, 2019 06:59
Trust Relationship for AssumeRole
{
"Version": "2018-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
@ntantri
ntantri / assume_role.js
Created September 12, 2019 06:56
Assume Policy For Cross AWS Account
{
"Version": "2019-08-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"sts:DecodeAuthorizationMessage",
"sts:GetAccessKeyInfo",
"sts:GetCallerIdentity"
@ntantri
ntantri / download_s3_files_cross_account_iam.py
Last active July 3, 2019 17:45
This file will help download files from S3 which uses IAM assume role for cross account collaboration
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import boto3
def fetch_s3_client_object(credentials):
"""
Return the s3 object that would be used.
@ntantri
ntantri / s3_executor.py
Last active December 3, 2023 18:09
An executor library which uses the select_runner.py to run queries on AWS S3 files.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import sys
import boto3
from select_runner import *
@ntantri
ntantri / select_runner.py
Last active April 22, 2021 04:45
AWS S3 Select Runner - used to execute queries on S3 files
import boto3
s3 = boto3.client('s3')
def write_to_file(r, output_file):
"""
This function would write the output to the file.