Skip to content

Instantly share code, notes, and snippets.

package wordcount;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
@dapurv5
dapurv5 / Image Processing Code
Created January 19, 2012 22:38
Image Processing Code
package com.deepu.digitalimage;
import java.awt.Color;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@dapurv5
dapurv5 / FunWithEnum.java
Created January 2, 2013 12:17
Fun with Java Enums
enum Algorithm{
A("a"){
private transient String msg = "I am A returned";
public String f(){
System.out.println("This is algo A");
return msg;
}
},
B("b"){
@dapurv5
dapurv5 / git-on-googlecode.sh
Created January 2, 2013 16:32
tutorial git on googlecode
➜ ~ git clone https://code.google.com/p/my-git-dummy-project/
➜ ~ cd my-git-dummy-project
➜ ~ echo "README" > README
➜ ~ git add .
➜ ~ git commit -m "first commit"
➜ ~ git push -u origin master
@dapurv5
dapurv5 / netrc.sh
Created January 2, 2013 16:36
editing the .netrc
➜ ~ vim ~/.netrc
@dapurv5
dapurv5 / FFT.java
Created January 2, 2013 16:53
Decorator over JTransforms for computing FFTs in NumPy fashion in Java
import edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D;
/**
* Wrapper class over JTransforms library for fourier transforms.
* @author apurv
*
*/
public class FFT {
public static Complex[] fft1D(Complex[] signal){
@dapurv5
dapurv5 / Complex.java
Created January 2, 2013 19:34
Complex Number representation
import java.lang.Math;
public class Complex {
protected double re;
protected double im;
public Complex(double real, double imag) {
re = real;
im = imag;
@dapurv5
dapurv5 / TreeBuilder.java
Created January 2, 2013 19:45
Tree Builder Preorder and Inorder
class TreeBuilder{
public Node buildTree(String[] preOrder, String[] inOrder){
assert(preOrder.length == inOrder.length);
if(preOrder.length == 0){
return null;
}
String rootData = preOrder[0];
Node root = new Node();
root.data = rootData;
int rootIndex = Array.<String>search(inOrder, rootData);
@dapurv5
dapurv5 / TreePlot.java
Created January 2, 2013 19:54
Binary Tree Visualization
import com.trolltech.qt.core.QPoint;
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QBrush;
import com.trolltech.qt.gui.QColor;
import com.trolltech.qt.gui.QFont;
import com.trolltech.qt.gui.QPaintEvent;
import com.trolltech.qt.gui.QPainter;
import com.trolltech.qt.gui.QWidget;
/**
@dapurv5
dapurv5 / 2DMatrixSample.java
Created January 3, 2013 21:33
Sorted 2d Matrix
int[][] G = {
{1, 4, 7, 11, 15},
{2, 5, 8, 12, 19},
{3, 6, 9, 16, 22},
{10, 13, 14, 17, 24},
{18, 21, 23, 26, 30}
};
System.out.println(Arrays2D.contains(G, -1));