Skip to content

Instantly share code, notes, and snippets.

View dedunumax's full-sized avatar

Dedunu Dhananjaya dedunumax

View GitHub Profile
@dedunumax
dedunumax / HelloWorld.java
Created November 20, 2013 13:57
Hello World!
public class HelloWorld {
public static void main(String []args) {
System.out.println("Hello World!");
}
}
public class Variable01 {
public static void main(String[] args) {
long startTime = System.nanoTime();
Method();
long endTime = System.nanoTime();
long duration = endTime - startTime;
System.out.println("Method runtime : " + duration + " ms");
public class Variable02 {
public static void main(String[] args) {
long startTime = System.nanoTime();
Method();
long endTime = System.nanoTime();
long duration = endTime - startTime;
System.out.println("Method runtime : " + duration + " ms");
public class Variable03 {
public static void main(String[] args) {
long startTime = System.nanoTime();
Method();
long endTime = System.nanoTime();
long duration = endTime - startTime;
System.out.println("Method runtime : " + duration + " ms");
public class Variable04 {
public static void main(String[] args) {
long startTime = System.nanoTime();
Method();
long endTime = System.nanoTime();
long duration = endTime - startTime;
System.out.println("Method runtime : " + duration + " ms");
@dedunumax
dedunumax / FindWorkPercentage.cs
Last active January 3, 2016 00:09
This class can compare two comma separated word lists and return the matching percentage.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WordCompare
{
class FindWorkPercentage
{
@dedunumax
dedunumax / hadoop-pom.xml
Last active January 3, 2016 05:29
This is a sample pom.xml for hadoop projects. You have to chnage groupId, artifactId, name and package.MainClass according to your project.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Name</name>
@dedunumax
dedunumax / DateMinusOne.java
Last active January 4, 2016 13:49
How to get the day prior to a particular date.
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Date -1
* Get the date prior to a specific date.
*/
public class DateMinusOne {
@dedunumax
dedunumax / Map.java
Last active May 3, 2017 21:47
Code shows how to implement a mapper only Hadoop Job
package org.dedunumax.mapperOnly;
import java.io.IOException;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class Map extends Mapper<LongWritable, Text, Text, Text> {
@dedunumax
dedunumax / DataHandler.java
Created February 7, 2014 16:41
This class shows how to save a list in a file. And how to load it back to memory.
package org.dedunumax.gist
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;
public class DataHandler {