Skip to content

Instantly share code, notes, and snippets.

View satendrakumar's full-sized avatar
:octocat:

Satendra Kumar satendrakumar

:octocat:
View GitHub Profile
@satendrakumar
satendrakumar / app.py
Created October 3, 2023 10:37 — forked from btotharye/app.py
AWS CDK ECS Fargate with ALB and VPC Flow Logs Including Cloudwatch logs for ECS - Locked down to custom peer IP
from aws_cdk import (
aws_ec2 as ec2,
aws_ecs as ecs,
aws_iam as iam,
aws_logs as logs,
aws_elasticloadbalancingv2 as elbv2,
core,
)
apiVersion: druid.apache.org/v1alpha1
kind: Druid
metadata:
name: cluster
spec:
commonConfigMountPath: /opt/druid/conf/druid/cluster/_common
rollingDeploy: true
image: "apache/druid:0.19.0"
startScript: /druid.sh
log4j.config: |-
@satendrakumar
satendrakumar / s3_utils.py
Last active November 8, 2018 12:58
Upload and download from/to S3 using boto3 Api
import boto3
s3 = boto3.resource('s3')
def download(bucket_name, key, filePath):
try:
s3.meta.client.download_file(bucket_name, key, filePath)
except ValueError as err:
print('Error:', err)
@satendrakumar
satendrakumar / Authentication.scala
Created January 17, 2018 10:03 — forked from ian-kent/Authentication.scala
Akka based authentication and authorisation for Play Framework
package wrappers
import play.api._
import play.api.mvc._
import scala.concurrent._
import scala.concurrent.Future
import play.mvc.Http.Status
import ExecutionContext.Implicits.global
import play.libs.Akka
import akka.actor.{Actor, Props}
@satendrakumar
satendrakumar / S3Api.scala
Created January 12, 2018 06:03
Scala S3 Api
import java.io._
import com.amazonaws.ClientConfiguration
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.model._
object S3Api {
private val config = new ClientConfiguration() //in milliseconds
# confluent kafka(.8.2) producer
import json
from confluent_kafka import Producer
class KafkaProducer:
def __init__(self, hosts):
self.hosts = hosts
self.producer = Producer(
# confluent Kafka(.8.2) consumer
from confluent_kafka import Consumer
from confluent_kafka import TopicPartition
class KafkaConsumer:
def __init__(self,topic, hosts, partitions):
@satendrakumar
satendrakumar / AkkaHttpService.scala
Created November 26, 2017 07:10
Log your Http request and response into log file with time taken by server to process that request.
import akka.event.LoggingAdapter
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.RouteResult.{Complete, Rejected}
import akka.http.scaladsl.server.directives.{DebuggingDirectives, LoggingMagnet}
import akka.stream.ActorMaterializer
@satendrakumar
satendrakumar / ExecutorServices.scala
Last active September 20, 2017 21:15
Choosing an ExecutorService for application(use own thread pool instead of Scala default )
import java.util.concurrent.{Executors, ForkJoinPool}
import scala.concurrent.ExecutionContext
//For IO intensive applications
object MyExecutionContext {
private val concurrency = Runtime.getRuntime.availableProcessors()
implicit val commonThreadPool: ExecutionContext = ExecutionContext.fromExecutor(Executors.newCachedThreadPool())
@satendrakumar
satendrakumar / XLSX2CSV.scala
Created August 15, 2017 14:27
Convert excel file into csv file
import org.apache.http.annotation.NotThreadSafe
import org.apache.poi.ss.usermodel._
import scala.collection.JavaConversions._
import scala.util.control.NonFatal
object IXLS2CSV {
private val df = new DataFormatter(true)