Skip to content

Instantly share code, notes, and snippets.

View 2sbsbsb's full-sized avatar

Santosh Bhushan 2sbsbsb

  • Fremont, CA, USA
View GitHub Profile
@2sbsbsb
2sbsbsb / StopWatch.java
Created March 30, 2013 08:07
Simple StopWatch to use. Prints time and task in descending order. Very easy 2 use. Check main()
/**
* Created on Jan 4, 2012
* @author sbsbsb
*/
package util.stopWatch;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
package util.text;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.text.DecimalFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Parses longitude or latitude to double
*/
public class LongitudeLatitudeUtil {
private static String EXPRESSION = "^(?<deg>[-+0-9]+)[^0-9]+(?<min>[0-9]+)[^0-9]+(?<sec>[0-9.,]+)[^0-9.,ENSW]+(?<pos>[ENSW]*)$";
@2sbsbsb
2sbsbsb / TracingScript.java
Created August 15, 2012 21:57
BTrace script for profiling method
/* BTrace Script Template */
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.Profiler;
@BTrace
public class TracingScript {
// Initiate the profiler instance
public static Profiler p = com.sun.btrace.BTraceUtils.Profiling.newProfiler();
@2sbsbsb
2sbsbsb / TestRunner.java
Created August 15, 2012 21:03
TestRunner is a simple java program with two threads and executing a common method
package com.test;
public class TestRunner {
// Set the running time here
public static long RUNNING_TIME_MIN = 10;
class Runnable1 implements Runnable {
@2sbsbsb
2sbsbsb / HtmlColor.java
Created June 18, 2012 23:59
Simple HTML Color Names
public static enum HtmlColor {
GREEN, BLUE, RED, BROWN, BLACK
}
@2sbsbsb
2sbsbsb / HTMLTableBuilder.java
Created June 18, 2012 23:55
Modified HTML Builder
/**
* Use:
*
* HTMLTableBuilder htmlBuilder = new HTMLTableBuilder(null, true, 2, 3);
* htmlBuilder.addTableHeader("1H", "2H", "3H");
* htmlBuilder.addRowValues("1", "2", "3");
* htmlBuilder.addRowValues("4", "5", "6");
* htmlBuilder.addRowValues("9", "8", "7");
* String table = htmlBuilder.build();
@2sbsbsb
2sbsbsb / HTMLTableBuilder.java
Created June 18, 2012 23:43
Simple HTML Table Builder
/**
* Uses:
* HTMLTableBuilder htmlBuilder = new HTMLTableBuilder(null, true, 2, 3);
* htmlBuilder.addTableHeader("1H", "2H", "3H");
* htmlBuilder.addRowValues("1", "2", "3");
* htmlBuilder.addRowValues("4", "5", "6");
* htmlBuilder.addRowValues("9", "8", "7");
* String table = htmlBuilder.build();
* System.out.println(table.toString());
*/
@2sbsbsb
2sbsbsb / LineWithDifferentColorAndSize.r
Created June 9, 2012 00:07
How to draw a line with different color and size
library("ggplot2")
> x = c(1:10)
> y = c(1:10)
> colours = rainbow(10)
> size <- c(1,2,3,4,5,5,4,3,2,1)
> tt <- data.frame(x=x,y=y,colours=colours,size=size)
> tt
x y colours size