Skip to content

Instantly share code, notes, and snippets.

View samuelorji's full-sized avatar

Samuel Orji samuelorji

View GitHub Profile
samuelorji / producing.scala
Last active July 17, 2018 13:28
A very simple Kafka producer that writes to a given topic without a key
package kafka
import java.util.Properties
import org.apache.kafka.clients.producer.{KafkaProducer, ProducerRecord}
object producing extends App{
samuelorji / consuming.scala
Last active July 20, 2018 00:48
Simple conusmer code for kafka only compatible with kafka 0.10.x
package kafka
import java.util.{Collections, Properties}
import java.util
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.kafka.common.TopicPartition
import org.apache.log4j.Logger
import scala.collection.JavaConverters._
samuelorji / battles.scala
Created July 20, 2018 10:14
A simple script that connects to a cassandra cluster and fetches data from it
package cassandra
import com.datastax.spark.connector.rdd.CassandraTableScanRDD
import org.apache.spark.{SparkConf, SparkContext}
object battles {
case class Battle(
battle_number: Option[Integer],
year: Option[Integer],
samuelorji / build.sbt
Created November 23, 2018 16:32
A sample build.sbt file ffor multiple projects
val Snapshots = "Snapshots" at "url to repo "
val Releases = "Releases" at "url to repo "
lazy val sharedSettings = Seq(
scalaVersion := "2.12.6",
version := "0.1.6",
resolvers ++= Seq(
"Typesafe repository releases" at "",
sealed trait Animal {
def speakLikeAnimal : Unit
//some other method for animals
case class Cat (name : String , sound : String) extends Animal{
override def speakLikeAnimal: Unit = println(s"I am $name and the sound i make is $sound")
trait HumanTendency[A]{
def makeHumanLike(a : A) : String
implicit val humanLike = new HumanTendency[Parrot] {
override def makeHumanLike(a: Parrot): String = s"I am ${}, the sound i make is ${a.sound},and i can talk like a human :) "
implicit class ToParrot( p : Parrot){
def speakLikeHuman(implicit humanlike : HumanTendency[Parrot]) : String = {
//let us create our closed model object type Parrot
val parrot = Parrot("Casey", "prrrrr")
//closed object type Cat
def speakLikeHuman(p :Parrot)(implicit humanTendency: HumanTendency[Parrot]) : String = {
println ( speakLikeHuman(parrot) ) // prints out ---------> I am Casey, the sound i make is prrrrr,and i can talk like a human :)
trait RedisDbT {
val host: String
val port: Int
val timeout: FiniteDuration
implicit val _system : ActorSystem
def getRedisInstance = _system.actorOf(Props(new RedisDbService(host,port,timeout)))