Skip to content

Instantly share code, notes, and snippets.

Praveen pmanvi

Block or report user

Report or block pmanvi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pmanvi / OffsetCommand
Last active Jul 26, 2019
For resetting offset command
View OffsetCommand
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.zeroturnaround.exec.ProcessExecutor;
View jvm-heap-thread-dump-analyze_tips - Use this tool for analyzing the dumps
Make sure to have these parameters defined
lets say that you are experiencing OOM, but you still don't determine the root cause of the issue.
You might probably need to restart as soon as you see performance issues or even better daily.
$JAVA_HOME/bin/jmap -dump:format=b,file=~\heap.hprof <PID>
View myDotProfile
export JAVA_HOME=$(/usr/libexec/java_home)
export GRADLE_HOME=/opt/gradle
export M2_HOME=/opt/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH:$GRADLE_HOME/bin
export MYSQL_HOME=/usr/local/bin/mysql
alias ll="ls -lptr"
alias cd..="cd .."
pmanvi / dateStringToDate
Created Dec 22, 2015
utility to extract date from unknown format
View dateStringToDate
public static LocalDate getLocalDateWithUnknownFormat(String dString) {
LocalDate[] localDate = {null};
Arrays.asList("yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd'T'HH:mm:ssZ",
"yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
"yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd HH:mm:ss",
"MM/dd/yyyy HH:mm:ss", "MM/dd/yyyy'T'HH:mm:ss.SSS'Z'",
"MM/dd/yyyy'T'HH:mm:ss.SSSZ", "MM/dd/yyyy'T'HH:mm:ss.SSS",
"MM/dd/yyyy'T'HH:mm:ssZ", "MM/dd/yyyy'T'HH:mm:ss",
"yyyy:MM:dd HH:mm:ss", "yyyyMMdd")
.stream().parallel().forEach(f-> {
pmanvi /
Created Aug 2, 2015
List<Integer> numbers = asList(1, 2, 3, 4, 5);
List<Integer> even_numbers = -> num % 2 == 0).collect(Collectors.toList());
// will print [2,4]
View aggregate_results.json
buckets: [
key: 0KB to 1KB
from: 0
from_as_string: 0.0
to: 1024
to_as_string: 1024.0
doc_count: 124181
pmanvi / enron_email_size_aggregator.json
Created Oct 18, 2014
enron_email_size_aggregator ES query
View enron_email_size_aggregator.json
"aggs": {
"enron_size_ranges": {
"range": {
"field": "content_size_in_bytes",
"ranges": [
"key": "0KB to 1KB",
"from": 0,
"to": 1024
pmanvi /
Last active Aug 29, 2015
Searching enron mails with ES
__author__ = 'pmanvi'
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search, Q
es = Elasticsearch([{'host': 'localhost'},{'port': 9200}])
count = Search(using=es).index("enron-email").count()
pmanvi /
Last active Aug 29, 2015
Exporting enron email to ES friendly JSONs
__author__ = 'pmanvi'
import os
import sys
from email.parser import Parser
from elasticsearch import Elasticsearch
from datetime import date
import traceback
p = Parser()
pmanvi / Eclipse_equals_hashcode
Created Feb 9, 2012
View Eclipse_equals_hashcode
// IntelliJ generated
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ElementNameKey)) return false;
ElementNameKey that = (ElementNameKey) o;
if (field1 != that.field1) return false;
if (field2 != that.field2) return false;
You can’t perform that action at this time.