Skip to content

Instantly share code, notes, and snippets.

View skp33's full-sized avatar

Kaushal Prajapati skp33

View GitHub Profile
@skp33
skp33 / BasicAuthenticationFilter.java
Created December 8, 2015 12:48 — forked from neolitec/BasicAuthenticationFilter.java
HTTP Basic authentication Java filter
package com.neolitec.examples;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@skp33
skp33 / MovingAvgSpark.scala
Last active August 29, 2015 14:27 — forked from samklr/MovingAvgSpark.scala
Moving Average on stock prices in Spark with custom partitioner
val ts = sc.parallelize(0 to 100, 10)
val window = 3
class StraightPartitioner(p: Int) extends Partitioner {
def numPartitions = p
def getPartition(key: Int) = key * p/0.5
}
val partitioned = ts.mapPartitionsWithIndex((i, p) => {
val overlap = p.take(window - 1).toArray