Skip to content

Instantly share code, notes, and snippets.

@bchetty
bchetty / Series.java
Created March 25, 2016 21:26
Highcharts Sample Model Class
package com.bchetty.charts.model;
import java.util.List;
/**
*
* @author Babji Prashanth, Chetty
*/
public class Series {
private String name;
@bchetty
bchetty / ChartController.java
Created March 25, 2016 21:25
Highcharts Chart Controller
package com.bchetty.charts.controller;
import com.bchetty.charts.model.Series;
import com.google.gson.Gson;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@bchetty
bchetty / highcharts_demo.xhtml
Created March 25, 2016 21:20
highcharts_demo.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
@bchetty
bchetty / Run.java
Created May 31, 2013 21:19
Simple Java program to execute Mac-OS commands (For Ex: To open a Finder Window) through a Java program.
import java.io.IOException;
/**
* Simple Java program to execute Mac-OS command (For Ex: To open a Finder Window) through a Java program.
*
* @author Babji, Chetty
*/
public class Run {
public static void main(String[] params) throws IOException {
Runtime.getRuntime().exec(new String[] {"open", params[0]});
@bchetty
bchetty / SpiralWalking.java
Created May 24, 2013 21:26
Spiral Walking in a rectangular grid.
public class SpiralWalking {
public static void main(String[] args) {
SpiralWalking sw = new SpiralWalking();
String res[][] = sw.walkSpirally(10,10);
for(int i=0;i<10;i++) {
System.out.println();
for(int j=0;j<10;j++) {
System.out.print(res[i][j] + " ");
}
@bchetty
bchetty / DatabaseResourceLoader.java
Created May 24, 2013 20:55
Seam v2 Database Resource Loader.
@Scope(ScopeType.STATELESS)
@BypassInterceptors
@Install(precedence = Install.APPLICATION, dependencies = "org.jboss.seam.security.identity")
@Name("org.jboss.seam.core.resourceLoader")
public class DatabaseResourceLoader extends ResourceLoader {
@Override
public ResourceBundle loadBundle(String bundleName) {
return new ResourceBundle() {
public Enumeration<String> getKeys() {
//Locale locale = org.jboss.seam.core.Locale.instance();
@bchetty
bchetty / pom.xml
Created May 24, 2013 20:40
Plugin repository for Maven YUI compressor plugin.
<pluginrepositories>
<pluginrepository>
<name>oss.sonatype.org</name>
<id>oss.sonatype.org</id>
<url>http://oss.sonatype.org/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
@bchetty
bchetty / pom.xml
Created May 24, 2013 20:39
Maven plugin for YUI compressor.
<build>
<plugins>
<plugin>
<groupid>net.alchim31.maven</groupId>
<artifactid>yuicompressor-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
@bchetty
bchetty / pom.xml
Created May 24, 2013 20:35
Maven-Shade plugin usage
<build>
<plugins>
<plugin>
<groupid>org.apache.maven.plugins</groupId>
<artifactid>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
@bchetty
bchetty / BigIntTest.java
Created May 24, 2013 20:22
Looping through a range of BigInteger values.
import java.math.BigInteger;
public class BigIntTest {
public static void main(String[] args) {
BigInteger bigInt1 = new BigInteger("1000000000000000");
BigInteger bigInt2 = new BigInteger("1000000000000500");
//Loop from bigInt1 to bigInt2
for(BigInteger bigInt = bigInt1; bigInt.compareTo(bigInt2) < 0; bigInt = bigInt.add(BigInteger.ONE)) {
System.out.println("I'm so big now : " + bigInt);