Skip to content

Instantly share code, notes, and snippets.

Avatar

Rohit Kelapure kelapure

View GitHub Profile
@kelapure
kelapure / code-refactor.md
Last active Aug 19, 2020
Code Rewrite Options For Removing Technical Debt
View code-refactor.md
@kelapure
kelapure / Kafka-debug.java
Created Oct 20, 2019
How to print the Topology of a KStream or a KTable when you have no access to the topology
View Kafka-debug.java
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 Mar 9, 2019
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
View config-props.sh
#!/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")
View classloaderdebug.java
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(URL url: urls){
System.out.println(url.getFile());
}
@kelapure
kelapure / xml
Last active Feb 24, 2019
bouncy-castle
View xml
<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 Feb 11, 2019
The script that executes any batch job on the PCF as a task, waits for the result and prints out associated logs
View task-wait.sh
#!/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 Dec 5, 2018
Poor man's profiler for Ruby
View debugging-poor.rb
# chp2/wrapper.rb
require "json"
require "benchmark"
def​ measure(&block)
no_gc = (ARGV[0] == "--no-gc")
@kelapure
kelapure / Application Tags.md
Last active Nov 30, 2018
Application Tags.md
View 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
View DebugUtils.java
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() {