Skip to content

Instantly share code, notes, and snippets.

View ajjain's full-sized avatar

Abhishek Jain ajjain

  • Impetus Technologies Inc.
  • Indore
View GitHub Profile
@ajjain
ajjain / GenericCassandraReader.java
Last active December 16, 2015 13:39
Generic Cassandra composite column reader using Hector client library.
/**
* reads the data from the composite column family.
*
* @param rowKey unique key which identifies a row in cassandra column family.
* @param columnFamilyName represents the column family which contains the data to be looked up.
* @param startValue range query start parameter
* @param endValue range query end parameter
* @param compositeColumnSerializer represents mapping from column name to {@link Serializer}
* @param startComparator holds the comparator value to start the range query
* @param endComparator holds the comparator value to end the range query
@ajjain
ajjain / NodeCassandra.js
Last active December 18, 2015 09:59
This Gist demonstrate on how to integrate NodeJs with Cassandra. I researched both cassandra-node and Helenus to approach the solution, found Helenus very handful could be integrated with ease but lacks composite column support. Cassandra-node was my default choice since I had to handle composites.
var http = require('http');
/*
- Make sure you have downloaded node-cassandra-client and related dependencies and made it available
- at the suitable place.
*/
var cassandraClient = require('./node-cassandra-client.js');
var hosts = ['host1:port1','host2:port2','host3:port3'];
var connection_pool = new cassandraClient.PooledConnection({'hosts': hosts, 'keyspace': 'keyspacename'});
http.createServer(
@ajjain
ajjain / IPenFactory.java
Created October 28, 2013 08:19
Factory implementation in Spring
public interface IPenFactory {
IPen getInstance(String type);
}
@ajjain
ajjain / ScalaSyntax.sc
Last active December 27, 2015 17:49
This my Scala worksheet where I practice Martin's teachings.
package learn.scala
object LearnSyntaxSheet {
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet
var x = 1 //> x : Int = 1
def incr(counter: Int) = counter + 1 //> incr: (counter: Int)Int
incr(100) //> res0: Int = 101
//================================================================================
// 11/07/2013
@ajjain
ajjain / ScalaExample.sc
Created November 19, 2013 00:37
I am following Martin Odersky coursera examples herein
package learn.scala
object Exercise {
println("Welcome to the Exercises") //> Welcome to the Exercises
// EXERCISE 1:
// Write a product function that calculate product of values of a function for the points
// on a given interval
def prod(f: Int=>Int, a: Int, b: Int): Int = {
@ajjain
ajjain / HigherOrderFunction.sc
Created November 19, 2013 03:37
Higher Order Function in Scala Explained. This example is taken from Martin Odersky's teaching at Coursera.
package learn.scala
object Exercise {
// Exercise on implementing Higher order functions in Scala.
// All these examples are taken from Martin Odersky teachings on coursera.
// EXERCISE 1:
// Write a product function that calculate product of values of a function for the points
// on a given interval
@ajjain
ajjain / DataStructureExample.scala
Last active December 28, 2015 20:29
Datastructures in Scala
package learn.scala
/**
* Datastructures in Scala
* The example below shows abstracting Rational numbers and implementing
* rational number arithmetics.
*
* Similar to java scala does provide toString for printing the datastructure representation.
* In the example below we override toString method. Also, we make use of this construct which
* is also available in Scala.
@ajjain
ajjain / ConfigurationService.java
Created November 22, 2013 06:40
Activiti custom serialization of process variables.
public class ConfigurationService {
/**
* The process engine configuration impl.
**/
private ProcessEngineConfigurationImpl processEngineConfigurationImpl;
/**
* The Custom vars.
*/
private List<CustomVariableType> CustomVars;
/**
@ajjain
ajjain / ClassHierarchy.scala
Created December 3, 2013 14:09
Herein we'll discuss class hierarchies in Scala. The first concept in this is about Abstract classes. This is very similar to how it is in Java. Next we discuss about the persistent data structures and creation of binary search tree. This example discusses creating a data structure to model binary search tree of integers.
package learn.scala
/**
* Herein we'll discuss class hierarchies in Scala.
* The first concept in this is about Abstract classes. This is very similar to how it is in Java.
* Next we discuss about the persistent data structures and creation of binary search tree.
*/
object ClassHierarchy {
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet
val node = new NonEmpty(4, new Empty, new Empty)//> node : learn.scala.NonEmpty = {.4.}
@ajjain
ajjain / OperatorOverloading.scala
Created December 3, 2013 14:13
Operator Overloading in Scala
package learn.scala
object OperatorOverloading {
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet
/**
* We wish to use operators for rational number.
* Example: r1 < r2 instead of using r1.less(r2)
* This can be acheived in scala by understanding below two properties
* a) Infix methods Notation