Skip to content

Instantly share code, notes, and snippets.

View kelapure's full-sized avatar

Rohit Kelapure kelapure

View GitHub Profile
@kelapure
kelapure / code-refactor.md
Last active August 19, 2020 15:16
Code Rewrite Options For Removing Technical Debt
@kelapure
kelapure / Kafka-debug.java
Created October 20, 2019 03:48
How to print the Topology of a KStream or a KTable when you have no access to the topology
private void print(Object stream) throws IllegalAccessException {
Field field = ReflectionUtils.findField(KStreamImpl.class, "builder");
ReflectionUtils.makeAccessible(field);
InternalStreamsBuilder builder = (InternalStreamsBuilder) field.get(stream);
field = ReflectionUtils.findField(InternalStreamsBuilder.class, "internalTopologyBuilder");
ReflectionUtils.makeAccessible(field);
InternalTopologyBuilder internalTopologyBuilder = (InternalTopologyBuilder)field.get(builder);
TopologyDescription topologyDescription = internalTopologyBuilder.describe();
@kelapure
kelapure / config-props.sh
Last active March 9, 2019 03:35
Script to pull out the properties of your application from the config server. Name of the app is spring-music89 and the config service instance is called csi
#!/bin/bash
cf create-service-key csi config-server-key
cf service-key csi config-server-key | tail -n 6 > config-server-key.json
# Get details form config-server-key.json file
access_token_uri=$(cat config-server-key.json | jq -r ".access_token_uri")
client_id=$(cat config-server-key.json | jq -r ".client_id")
client_secret=$(cat config-server-key.json | jq -r ".client_secret")
@kelapure
kelapure / classloaderdebug.java
Created February 24, 2019 02:21
classloaderdebug
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(URL url: urls){
System.out.println(url.getFile());
}
@kelapure
kelapure / xml
Last active February 24, 2019 01:35
bouncy-castle
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
@kelapure
kelapure / task-wait.sh
Created February 11, 2019 21:59
The script that executes any batch job on the PCF as a task, waits for the result and prints out associated logs
#!/bin/bash
APP_NAME=$1
CMD=$2
task_id=$(cf run-task $APP_NAME "${CMD}" | grep "task id:" | awk '{print $3}')
task_name=$(cf tasks $APP_NAME | grep "^$task_id " | awk '{print $2}')
task_status=$(cf tasks $APP_NAME | grep "^$task_id " | awk '{print $3}')
@kelapure
kelapure / debugging-poor.rb
Last active December 5, 2018 14:29
Poor man's profiler for Ruby
# chp2/wrapper.rb
require ​"json"
require ​"benchmark"
def​ measure(&block)
no_gc = (ARGV[0] == ​"--no-gc"​)
@kelapure
kelapure / Application Tags.md
Last active November 30, 2018 16:30
Application Tags.md

Technical Stack Buckets/ Application Tags

  1. Modern Microservices with Spring and other microframeworks
  2. Batch
  3. ETL
  4. SPA
  5. Web MVC , Older REST - Server side rendering of UI
  6. Portlets based UI
  7. Cloud Native Eclipse Microprofile
  8. Service Composition / Data Integration / Data Munging
class DebugUtils {
private static final boolean transactionDebugging = true;
private static final boolean verboseTransactionDebugging = true;
public static void showTransactionStatus(String message) {
System.out.println(((transactionActive()) ? "[+] " : "[-] ") + message);
}
// Some guidance from: http://java.dzone.com/articles/monitoring-declarative-transac?page=0,1
public static boolean transactionActive() {