Skip to content

Instantly share code, notes, and snippets.

@pmanvi
pmanvi / enron_email_to_es_exporter.py
Last active August 29, 2015 14:07
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
pmanvi / Eclipse_equals_hashcode
Created February 9, 2012 04:56
Eclipse_equals_hashcode
// IntelliJ generated
@Override
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;
@pmanvi
pmanvi / ObjectInputReaderTemplate.java
Created September 30, 2011 14:15
ObjectInputReaderTemplate - A generic class supporting all the data types
// Follows the template pattern to provide container for ObjectInput
static abstract class ObjectInputReaderTemplate<T> {
private ObjectInput objectInput;
public ObjectInputReaderTemplate(final ObjectInput objectInput){
this.objectInput=objectInput;
}
public final T execute() throws IOException {
T t = get();
@pmanvi
pmanvi / ObjecrInputDecorator.java
Created September 25, 2011 17:04
Class used for implementing the forward compatability of serialized java objects
// A wrapper classes delegating the execution of method into the container that can handle forward compatibility
// This class implements all the methods ObjectInput & moves the cursor
// whenever it sees skippable data from future versions
// WARNING : Currently for POC only 2 methods are implemented
class ObjectInputDecorator{
ObjectInput input;
ObjectInputDecorator(ObjectInput input){
this.input=input;
}
VERSION = 0;
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(VERSION);
out.writeInt(number);
out.writeObject(name);
}
@Override
public void readExternal(ObjectInput _in) throws IOException, ClassNotFoundException {
ObjectInputWrapper in = new ObjectInputWrapper(_in);