Skip to content

Instantly share code, notes, and snippets.

View remeniuk's full-sized avatar

Vasil Remeniuk remeniuk

View GitHub Profile
val bonusForm = Form(
mapping(
"alias" -> optional(text),
"selectedBonus" -> optional(mapping(
"itemId" -> nonEmptyText,
"bonus" -> number
)(Bonus.apply)(Bonus.unapply)),
"bonuses" -> list(
mapping(
"itemId" -> nonEmptyText,
val selectedBonusIdValidator = (form: Form[BonusForm]) =>
(for {
value <- form.value
bonusId <- value.selectedBonusId
} yield form
) getOrElse form.withError("selectedBonusId", "You should select an item!")
val selectedBonusValueValidator = (form: Form[BonusForm]) =>
(for {
value <- form.value
@segmentCriteria(filter: MongoFilter) = {
@{
filter match {
case eql(column, childFilter) =>
segmentCriterion(column.name, "=" , childFilter)
case gt(column, childFilter) =>
segmentCriterion(column.name, ">" , childFilter)
case lt(column, childFilter) =>
segmentCriterion(column.name, "<" , childFilter)
case childFilter: and =>
./run_etl_qa.sh t_user_session_load/initial_load
INFO 11-02 08:23:45,172 - Kitchen - Logging is at level : Detailed logging
INFO 11-02 08:23:45,174 - Kitchen - Start of run.
INFO 11-02 08:23:45,199 - RepositoriesMeta - Reading repositories XML file: /home/crm-user/.kettle/repositories.xml
INFO 11-02 08:23:45,407 - t_user_session_load/initial_load - Start of job execution
INFO 11-02 08:23:45,412 - t_user_session_load/initial_load - exec(0, 0, START.0)
INFO 11-02 08:23:45,414 - START - Starting job entry
INFO 11-02 08:23:45,415 - t_user_session_load/initial_load - Starting entry [Create empty table]
INFO 11-02 08:23:45,415 - t_user_session_load/initial_load - exec(1, 0, Create empty table.0)
INFO 11-02 08:23:45,416 - Create empty table - Starting job entry
@remeniuk
remeniuk / gist:3834258
Created October 4, 2012 15:11
modified HTablePool
public class HTablePool {
private static final int RESIZE_TABLE_POOL_INTERVAL_SEC = (int) TimeUnit.MINUTES.toSeconds(30);
private static final int REPORT_CACHED_CONNECTIONS_COUNT_INTERVAL_SEC = (int) TimeUnit.MINUTES.toSeconds(2);
private static final Log log = LogFactory.getLog(HTablePool.class);
protected final ConcurrentMap<String, LinkedList<HTableInterface>> tables = new ConcurrentHashMap<String, LinkedList<HTableInterface>>();
private final Configuration config;
private final HTableInterfaceFactory tableFactory;
@remeniuk
remeniuk / gist:3466876
Created August 25, 2012 15:10
JMX dumper
import scala.collection.JavaConversions._
import java.lang.management.{ManagementFactory, MemoryMXBean}
import java.net.URI
import javax.management.JMX
import javax.management.remote.{JMXConnectorFactory, JMXServiceURL}
import scala.collection.JavaConversions._
object JmxDump {
def main(args: Array[String]) =
VL-0{n=5 c=[1003:3.400, 1006:3.400, 1008:3.200, 1009:3.200, 1012:3.200] r=[1003:1.744, 1006:1.744, 1008:1.600, 1009:1.600, 1012:1.600]}
Top Terms:
1006 => 3.4
1003 => 3.4
1012 => 3.2
1009 => 3.2
1008 => 3.2
VL-15{n=1 c=[1016:4.000, 1019:3.000, 1020:3.000, 1021:3.000, 1022:3.000, 1023:3.000, 1024:3.000, 1025:3.000] r=[]}
// clusterization results
val outputClustersPath = new Path("job/output-clusters")
// textual dump of clusterization results
val dumpPath = "job/dump"
println("Running K-means...")
// runs K-means algorithm with up to 20 iterations, to find clusters of colluding players (assumption of collusion is
// made on the basis of number hand player together with other player[s])
KMeansDriver.run(conf, vectorsPath, inputClustersPath, outputClustersPath,
new CosineDistanceMeasure(), 0.01, 20, true, 0, false)
// randomly selected cluster the will be passed as an input to K-means
val inputClustersPath = new Path("job/input-clusters")
val distanceMeasure = new EuclideanDistanceMeasure
println("Making random seeds...")
// build 30 initial random clusters/centroids
RandomSeedGenerator.buildRandom(conf, vectorsPath, inputClustersPath, 30, distanceMeasure)
val conf = new Configuration
conf.set("io.serializations", "org.apache.hadoop.io.serializer.JavaSerialization,"
+ "org.apache.hadoop.io.serializer.WritableSerialization")
// the path, where the vectors will be stored to
val vectorsPath = new Path("job/vectors")
// enumeration of all users involved in a selected subset of hand history records
val dictionaryPath = new Path("job/dictionary")
// text file with the dictionary size
val dictionarySizePath = new Path("job/dictionary-size")