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 / simpleRoute.java
Created March 15, 2011 09:22
Sample Camel Route
@Override
protected RouteBuilder createRouteBuilder()
{
return new SpringRouteBuilder()
{
public void configure()
{
from("direct:input").to("bean:inputSql").to("jdbc:sourceDataSource").process(new ResultSetProcessor()).split(body()).to(
"jpa:com.abc.entity.MyJPAEntity");
}
@ketankhairnar
ketankhairnar / AbstractCamelProcessor.java
Created March 15, 2011 10:03
Abstract Camel Processor
public abstract class CamelProcessor<T> implements Processor
{
protected void process(Exchange exchange, ResultMapper<T> mapper) throws Exception
{
try
{
ArrayList<T> payloads = new ArrayList<T>();
ArrayList<HashMap<String, Object>> data = exchange.getIn().getBody(ArrayList.class);
if (data != null)
{
@ketankhairnar
ketankhairnar / ResultSetProcessor.java
Created March 15, 2011 10:09
ResultSet Processor
public class ResultSeProcessor extends CamelProcessor<MyJPAEntity>
{
public void process(Exchange exchange) throws Exception
{
process(exchange, getRowMapper());
}
private static ResultMapper<MyJPAEntity> getRowMapper()
{
ResultMapper<MyJPAEntity> mapper = new ResultMapper<MyJPAEntity>()
chapter 4: Expressions and Simple functions
===========================================================================================================================
There are 2 types of expressions.
1. def x = 5
2. val x = 5
Here # 1 represens definition and expression is at the right hand side of the = sign. It is not evaluated immediately.
Here # 2 represents value expression and its value is evaluated immediately and whenver val is being used; it replaces
it with pre-computed value of expression.
[{"address":{"street":"Oude Ebbingestraat","housenumber":"12","postalcode":"9712 HJ","city":"Groningen","geoLocation":{"lat":"53.219319","lng":"6.56671"}},"distance":0,"type":"ING"},{"address":{"street":"Amsterdamsestraat","housenumber":"9","postalcode":"2587 CN","city":"Den Haag","geoLocation":{"lat":"52.111805","lng":"4.287714"}},"distance":0,"type":"ING"},{"address":{"street":"Oudenoord","housenumber":"1","postalcode":"3513 EG","city":"Utrecht","geoLocation":{"lat":"52.0970886","lng":"5.1133961"}},"distance":0,"type":"ING"},{"address":{"street":"Bloemenoordplein","housenumber":"50","postalcode":"5143 TC","city":"Waalwijk","geoLocation":{"lat":"51.6823433","lng":"5.0782567"}},"distance":0,"type":"ING"},{"address":{"street":"Dorpsstraat","housenumber":"2","postalcode":"2361 BB","city":"Warmond","geoLocation":{"lat":"52.195528","lng":"4.502244"}},"distance":0,"type":"ING"},{"address":{"street":"Waalderstraat","housenumber":"48","postalcode":"1791 EC","city":"Den Burg","geoLocation":{"lat":"53.056402","lng":"4
<speak> All good except 2 escalations. <break time=“1s”/> We had 5 new deployments and have new release coming this Friday</speak>
@ketankhairnar
ketankhairnar / HortonGrid
Created December 28, 2017 05:10
HortonGrid
package com.example;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class GridQuestion {
package co.in.shoonya.abc.prep.ds.classic.strings;
// Given a string of characters (a, b, c,....z), we want to break the string into a maximum number of substrings
// in which every character comes in only one substring. We have to return length of all substrings.
// Ex 1: Input string = "abcdefgahijklhopqrsot"
// Output = [8, 5, 6, 1]
// Ex 2: Input string = "abcd"
// Output = [1, 1, 1, 1]
import java.util.*;
package co.in.shoonya.abc.kata;
public class CdkShoppingCart {
public static void main(String[] args) {
System.out.println(billAmount(CustomerType.Regular, 15000d));
System.out.println(billAmount(CustomerType.Premium, 20000d));
}
private static double billAmount(CustomerType type, double input) {
package co.in.shoonya.abc.prep.ds.lists;
import co.in.shoonya.abc.prep.ds.lists.ds.ListNode;
public class AggregateAtZeroNode {
public static void main(String[] args) {
ListNode<Integer> l1 = new ListNode<Integer>(1);
l1.setNext(new ListNode<Integer>(4));
l1.getNext().setNext(new ListNode<Integer>(0));