Skip to content

Instantly share code, notes, and snippets.

View agrahul89's full-sized avatar

RAHUL AGARWAL agrahul89

View GitHub Profile
@agrahul89
agrahul89 / _ multinode-kraft-cluster.md
Last active April 10, 2025 18:56
Multinode K-Raft cluster using docker-compose

This setup provides docker compose to configure a 3 node kafka cluster using kraft. Alongside, a kafdrop UI and an init process is stared that can be used to create topics on cluster startup.

@agrahul89
agrahul89 / maven-release.md
Created May 24, 2022 10:04
Create a release build using Maven
  1. Add maven release plugin to <build> section of your pom.xml
<build>
  <plugins>
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
      </plugin>
  </plugins>

Gradle

Gradle build stages

Initialisation

Loads all configuration related to project single/multi module build.

Configuration

Executes pieces of code in project scope or inside gradle tasks(s) not wrapped in doFirst() or doLast()

@agrahul89
agrahul89 / Page.java
Last active March 3, 2022 13:58
a simple page implementation for apis
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
@agrahul89
agrahul89 / sonarqube-docker-install-docker-compose.yml
Last active June 30, 2022 18:20
docker-compose.yml file for setting up sonarqube
version: "3.8"
services:
postgres-sonarqube:
image: postgres:10
container_name: sonarqube-db
ports:
- "15432:5432"
environment:
POSTGRES_DB: sonarqube
POSTGRES_USER: sonarqube
@agrahul89
agrahul89 / jenkins-docker-install.sh
Last active August 8, 2021 14:42
Install jenkins docker image with maven and gradle
# create a docker file
mkdir /tmp/jenkins && cd /tmp/jenkins && touch dockerfile
# write dockerfile to configure custom jenkins image
echo 'FROM jenkins/jenkins:lts-jdk11' >> dockerfile
echo 'USER root' >> dockerfile
echo 'RUN apt-get update && apt-get install -y gradle maven' >> dockerfile
echo 'USER jenkins' >> dockerfile
# build and run custom image
@agrahul89
agrahul89 / spring-boot-jackson-java-time-formatting.md
Last active August 5, 2021 11:27
Formatting Java Time with Spring Boot using JSON

Formatting Java Time with Spring Boot using JSON

The aim of this post is to summarize and review ways of formatting Java Time objects using Spring Boot and Jackson library.

This post is organized in five steps. Each step represents one aspect of the issue and it is also related to one commit in example project repository.

Step 0 – Prerequisites

Versions and dependencies

This tutorial is based on Spring Boot version 1.3.1.RELEASE with spring-boot-starter-web. It uses jackson-datatype-jsr310 from com.fasterxml.jackson.datatype in version 2.6.4, which is a default version of Spring Boot. All of these is based on Java 8.

The Code

In the example code repository, you can find one HTTP service made with Spring Boot. This service is a GET operation, which returns a class with Java Time objects. You can also find the integration test that deserializes the response.

Step 1 – The goal

I would like to return class Clock, containing

@agrahul89
agrahul89 / encoding-encryption-hashing-obfuscation.md
Last active August 8, 2021 16:26
Hashing vs. Encryption vs. Encoding vs. Obfuscation

https://danielmiessler.com/study/encoding-encryption-hashing-obfuscation/

Encoding

The purpose of encoding is to transform data so that it can be properly (and safely) consumed by a different type of system, e.g. binary data being sent over email, or viewing special characters on a web page. The goal is not to keep information secret, but rather to ensure that it’s able to be properly consumed.

Encoding transforms data into another format using a scheme that is publicly available so that it can easily be reversed. It does not require a key as the only thing required to decode it is the algorithm that was used to encode it.

Examples:

ascii, unicode, URL Encoding, base64

@agrahul89
agrahul89 / java-proxy-configuration-guidelines.java
Last active December 22, 2020 09:30
Java Proxy Configuration Guidelines
resources
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#Authentication_schemes
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authenticate
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization
- https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html
- https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html
- https://www.rgagnon.com/javadetails/java-0085.html
- https://stackoverflow.com/questions/1626549/authenticated-http-proxy-with-java
@agrahul89
agrahul89 / classes-in-classpath.java
Created December 4, 2020 09:13
get all classes in classpath
package com.tesco.rangeinprogress.reporting;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;