Skip to content

Instantly share code, notes, and snippets.

View rajkrrsingh's full-sized avatar

Rajkumar Singh rajkrrsingh

View GitHub Profile
@rajkrrsingh
rajkrrsingh / Java DNS resolution.md
Last active March 21, 2026 06:10
how the java dns resolution work

lets take a sample code to demonste what happen when java tries to resolve the ip for the give hostname.


import java.net.InetAddress;
import java.net.UnknownHostException;

public class DNSClient {
    public static void main(String[] args) {
 InetAddress address = null;
@rajkrrsingh
rajkrrsingh / Kafka_Cheat_Sheet.md
Last active March 21, 2026 06:10
reference guide to run kafka command on CDP-DC cluster

CDP-DC kafka useful kafka commands

-- list topics
kafka-topics --list --bootstrap-server `hostname -f`:9092

-- create topic 
kafka-topics --create --bootstrap-server `hostname -f`:9092 --replication-factor 1 --partitions 1 --topic kafkatopic

-- produce messages
kafka-console-producer --broker-list `hostname -f`:9092 --topic kafkatopic
@rajkrrsingh
rajkrrsingh / Create_Bulk_Topic_In_Kafka.md
Last active March 21, 2026 06:10
create kafka bulk topic from admin client

import kafka.admin.AdminUtils;
import kafka.admin.RackAwareMode;
import kafka.utils.ZKStringSerializer$;
import kafka.utils.ZkUtils;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.ZkConnection;

import java.io.BufferedReader;
@rajkrrsingh
rajkrrsingh / Hive Kafka Integration
Last active March 21, 2026 06:10
a quick start guide to query kafka topic from hive table
#### ENV: HDP-3.1
#### Data setup:
```
cat sample-data.json
{"name": "Raj","address": {"a": "b","c": "d","e": "f"}}
{"name": "Raj1","address": {"a": "bb","c": "dd","e": "ff"}}
```
#### Create topic in Kafka and Ingest data into it.
@rajkrrsingh
rajkrrsingh / Kafka-Metrics.md
Last active March 21, 2026 06:10
Monitoring Kafka Broker JMX using jolokia JVM Agent
Download Jolokia JVM Agent from following location
https://jolokia.org/download.html
wget http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.3.7/jolokia-jvm-1.3.7-agent.jar

mv jolokia-jvm-1.3.7-agent.jar agent.jar
here is the small shell script to get metrics you are intersted in
@rajkrrsingh
rajkrrsingh / Llama3-on-EC2.md
Last active July 21, 2025 02:51
bash script to setup local llama3 model on EC2 instance using ollama and access through your machine
#!/usr/bin/env bash

set -o errtrace
set -o nounset
set -o pipefail

# Quick steps to create the VPC/Public Subnet/EC2 in the aws account.

output=$(aws sts get-caller-identity 2>&1)
@rajkrrsingh
rajkrrsingh / golang-web-app.md
Created December 29, 2019 01:55
simple golang webapp on docker to quick test

Golang App

mkdir golang-web-app
cd golang-web-app
vim main.go
package main

import (
	"fmt"
	"log"
@rajkrrsingh
rajkrrsingh / tcp_monitor.py
Created October 3, 2024 17:46
Python script using the Scapy library to monitor network traffic for given IP and Port
from scapy.all import *
def monitor_xpanse_requests(ip_address, port):
"""Monitors network traffic for client requests.
"""
# Filter for TCP packets from the specified IP address and port
filter_str = f"tcp and host {ip_address} and port {port}"
@rajkrrsingh
rajkrrsingh / PamAuthenticator
Created November 27, 2016 11:28
Java Program to use JPam Authentication
JPam is a Java-PAM bridge. PAM, or Pluggable Authentication Modules, is a standard security architecture used on Linux, Mac OS X, Solaris, HP-UX and other Unix systems. JPam is the missing link between the two.
JPAM permits the use of PAM authentication facilities by Java applications running on those platforms.
These facilities include:
account
auth
password
session
@rajkrrsingh
rajkrrsingh / Client.md
Created August 2, 2020 23:06
Java11 HttpClient to test the jwt authentication
package org.example;


import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;