Skip to content

Instantly share code, notes, and snippets.

View ketankhairnar's full-sized avatar
🎯
Focusing

Ketan Khairnar ketankhairnar

🎯
Focusing
View GitHub Profile
@ketankhairnar
ketankhairnar / romanConverter.java
Created October 23, 2010 11:20
romanConverter
package dojo1_Roman;
public class RomanConverter
{
public enum Digit
{
UNIT, DECIMAL, HUNDRED, THOUSAND
};
@ketankhairnar
ketankhairnar / scalaexample
Created November 17, 2010 09:55
Scala Covariance and Contravariance
object ParameterizedType {
//class definitions
class Pet(val name: String) {
override def toString = name
}
class Dog(override val name: String) extends Pet(name)
//covariance example
@ketankhairnar
ketankhairnar / forts lat long
Created November 19, 2010 07:52
gps coords for gmap
[
{"name":"Alang","lat":"19.58268","long":"73.66229","elevationFeet":"4852","elevationMeter":"1479"},
{"name":"Chanderi","lat":"19.06369","long":"73.24495","elevationFeet":"2605","elevationMeter":"794"},
{"name":"Chavand","lat":"19.23500","long":"73.75083","elevationFeet":"3240","elevationMeter":"988"},
{"name":"Dhak","lat":"18.90093","long":"73.40618","elevationFeet":"2326","elevationMeter":"709"},
{"name":"Duke's Nose(Nagphani)","lat":"18.74166","long":"73.35928","elevationFeet":"2648","elevationMeter":"807"},
{"name":"Ghanchakkar","lat":"19.47540","long":"73.75065","elevationFeet":"5037","elevationMeter":"1535"},
{"name":"Hadsar","lat":"19.26806","long":"73.80500","elevationFeet":"4680","elevationMeter":"1426"},
{"name":"HarishchandraGad Balekilla ","lat":"19.39146","long":"73.79377","elevationFeet":"4560","elevationMeter":"1390"},
{"name":"HarishchandraGadTaramati Summit","lat":"19.38685","long":"73.77917","elevationFeet":"4695","elevationMeter":"1431"},
// ###########################################################
//
// Demonstrates how to supervise an Akka consumer actor.
//
// The consumer consumes messages from a file endpoint:
// - successful message processing by the consumer will
// positively acknowledge the message receipt, causing
// the file endpoint to delete the file.
// - an exception during message processing will cause a
// supervisor to restart the consumer. Before restart,
@ketankhairnar
ketankhairnar / Traits.scala
Created February 26, 2011 05:58
UsingTraits
class UsingTraits
//refer notes 1,2,3
trait Friend{
val name:String
def listen()=println("Your friend "+name+" is listening")
}
class Human(val name:String) extends Friend
@ketankhairnar
ketankhairnar / DecoratorTraits.scala
Created February 27, 2011 06:48
Decorator pattern using scala traits
package com.example.chapter7.traits
class DecoratorTraits
abstract class Check {
def check():String ="Checked application details"
}
trait employmentCheck extends Check {
override def check():String="Checked employment details " +super.check()
@ketankhairnar
ketankhairnar / AuditLogging.java
Created March 3, 2011 08:16
Logging Interceptor
@Configurable
@Aspect
public class LoggingInterceptor
{
Log log = LogFactory.getLog(LoggingInterceptor.class);
@Autowired
private AuditData auditData;
@Around("execution(* *(..)) && @annotation(com.xyz.portal.util.audit.Auditable)")
public Object profile(ProceedingJoinPoint pjp) throws Throwable
@Documented
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value ={ ElementType.METHOD })
public @interface Auditable
{
String operation();
}
@ketankhairnar
ketankhairnar / gist:852502
Created March 3, 2011 08:20
AuditableUsage
@Auditable(operation = "Save/Update Login Configuration")
public void save(Config loginConfig)
{
logger.debug("saving Login Config for terminalId=" + loginConfig.getTerminalId());
getSession().merge(loginConfig);
getSession().flush();
return;
}
@ketankhairnar
ketankhairnar / worldcups.scala
Created March 6, 2011 14:38
basic scala map features
object MapTests extends Application {
override def main(args: Array[String]) {
//reference http://www.scala-lang.org/api/current/scala/collection/immutable/Map.html
val worldCupWinners = Map(1975 -> "West Indies",
1979 -> "West Indies",
1983 -> "India",
1987 -> "Australia",
1992 -> "Pakistan",
1996 -> "Sri Lanka",
1999 -> "Australia",