This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.sbt.PlayRunHook | |
import sbt._ | |
import java.net.InetSocketAddress | |
object Angular2 { | |
def apply(log: Logger, base: File, target: File): PlayRunHook = { | |
object Angular2Process extends PlayRunHook { | |
private var watchProcess: Option[Process] = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io._ | |
object Loop1 extends App { | |
//Java way | |
val inputStream: BufferedInputStream = new BufferedInputStream(new FileInputStream("input.csv")) | |
val outputStream = new BufferedOutputStream(new FileOutputStream("output.csv")) | |
val buffer = new Array[Byte](32 * 1024) | |
var bytesRead: Int = inputStream.read(buffer) | |
while (bytesRead > 0) { | |
println("writing.......") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object FoldLeft extends App { | |
def reverse(list: List[Int]): List[Int] = | |
list.foldLeft[List[Int]](Nil)((acc, element) => element :: acc) | |
def dedupe(list: List[Int]): List[Int] = { | |
list.foldLeft[List[Int]](Nil)((acc, element) => if (acc.contains(element)) acc else acc :+ element) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{BufferedReader, File, InputStreamReader} | |
import javax.annotation.concurrent.NotThreadSafe | |
import org.apache.hadoop.io.{LongWritable, Text} | |
import org.apache.hadoop.mapred.{FileSplit, TextInputFormat} | |
import org.apache.spark.broadcast.Broadcast | |
import org.apache.spark.rdd.HadoopRDD | |
import org.apache.spark.{SparkConf, SparkContext} | |
@NotThreadSafe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Producer | |
import java.util.Properties | |
import java.util.concurrent.Future | |
import org.apache.kafka.clients.producer.{ProducerRecord, RecordMetadata} | |
import org.apache.kafka.common.serialization.StringSerializer | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.sql.{DataFrame, SQLContext} | |
import org.apache.spark.{SparkConf, SparkContext} | |
case class Demo(id: Int, name: String, info: Map[String, String], inner: Inner) | |
case class Inner(firstName: String) | |
object ParquetReadWrite extends App { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.inject.Inject | |
import com.google.inject._ | |
import scala.collection.JavaConversions._ | |
object DemoApp extends App { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def withRetry[T](retryCount: Int)(t: => T): T = | |
try | |
t | |
catch { | |
case NonFatal(th) => | |
th.printStackTrace() | |
if (retryCount >= 0) { | |
println("Retrying............... [remaining count: [${retryCount-1}`]") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.libs.json._ | |
object JsonFormatter { | |
implicit val residentReads = Json.reads[Resident] | |
} | |
case class Resident(name: String, age: Int, role: Option[String]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akka { | |
actor { | |
default-dispatcher { | |
fork-join-executor { | |
parallelism-factor = 8 | |
parallelism-min = 16 |