Skip to content

Instantly share code, notes, and snippets.

@harishb2k
harishb2k / Send_message_examole.md
Created July 8, 2022 18:38
Send message to Kafka

In your class autowire (@@Autowired for Spring or @Inject for Guice)

@Autowired
private  IMessagingFactory messagingFactory;
import io.gitbub.devlibx.easy.helper.json.JsonUtils;

Object logEvent = ...
@harishb2k
harishb2k / MessagingConfigs.md
Last active October 6, 2022 12:58
Messaging Properties - Kafka String Boot Integration
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Getter
@Setter
@harishb2k
harishb2k / sessionrecorder.py
Created December 11, 2021 09:53
Python Flask app - record request/response (see end of the file for usage)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
WSGI middleware to record requests and responses.
"""
from __future__ import print_function, unicode_literals
import logging
@harishb2k
harishb2k / GolangProto.md
Last active July 15, 2021 20:46
how to generate Proto file for Golang
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

This will read hello.proto and put both proto and grpc file inside folder "pb".

protoc --go_out=pb --go_opt=paths=source_relative --go-grpc_out=pb --go-grpc_opt=paths=source_relative hello.proto
@harishb2k
harishb2k / Write a AWS Lambda in go.md
Last active June 28, 2021 17:26
Write a AWS Lambda in go

Step 1 - Implement

package main

import (
	"context"
	"fmt"
	"github.com/aws/aws-lambda-go/lambda"
)
@harishb2k
harishb2k / LocalStack Pro on Mac.md
Last active June 24, 2021 22:27
Setup and run LocalStack Pro on Mac

Docker commad to run LocalStack

This is a working command whihc will run LocalStack. It allows "https://app.localstack.cloud/dashboard" to connect to running docker and expose UI to list all services.

docker run -it -e DEFAULT_REGION="ap-south-1" -e LOCALSTACK_HOSTNAME="localhost" -e LOCALSTACK_API_KEY="PUT_KEY_HERE" -e TEST_AWS_ACCOUNT_ID="000000000000" -e SERVICES="serverless,cognito,rds,sqs,s3,stepfunctions,firehose,es,athena,sns,secretsmanager" -p 0.0.0.0:53:53 -p 0.0.0.0:53:53/udp -p 0.0.0.0:443:443 -p 0.0.0.0:443:443/udp  --rm --privileged --name localstack_main -p 4510-4540:4510-4540 -p 4566:4566 -p 4571:4571  -v "/private/var/folders/lm/m7znckm561771km0sj6jq8xw0000gn/T/localstack:/tmp/localstack" -v "/var/run/docker.sock:/var/run/docker.sock" -e DOCKER_HOST="unix:///var/run/docker.sock" -e HOST_TMP_FOLDER="/private/var/folders/lm/m7znckm561771km0sj6jq8xw0000gn/T/localstack" "localstack/localstack"
@harishb2k
harishb2k / Spark - Code Snippet.md
Last active June 24, 2021 11:52
Spark - Use spark JdbcUtils to check if table exists
package org.example;

import org.apache.spark.sql.catalyst.util.CaseInsensitiveMap;
import org.apache.spark.sql.catalyst.util.CaseInsensitiveMap$;
import org.apache.spark.sql.execution.datasources.jdbc.JdbcOptionsInWrite;
import org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils;
import scala.Tuple2;
import scala.collection.immutable.Map$;
@harishb2k
harishb2k / Local setup for DynamoDB and S3 using docker
Last active June 23, 2021 21:57
Run DynamoDd and S3 on local system for development
docker run --rm -it -p 8000:4566 -p 4571:4571 localstack/localstack
brew install astronomer/tap/astro
brew install astronomer/tap/[email protected]
mkdir some_dir
cd some_dir
astro dev init
>> If you want to install some python modules then put that in requirements.txt file
e.g. to add amazone airflow add following
apache-airflow-providers-amazon==1.1.0