Skip to content

Instantly share code, notes, and snippets.

View Moverr's full-sized avatar
🏖️
😁👍😔😂❤️😍😒👌

Muyinda Rogers Moverr

🏖️
😁👍😔😂❤️😍😒👌
View GitHub Profile
@Moverr
Moverr / jsonwriter.sc
Created December 15, 2023 22:20
Json writer emulating type classes
sealed trait json
final case class jsString(get: String) extends json
final case class jsObject(get: Map[String, json]) extends json
final case class jsNumber(get: Double) extends json
case object jsNull extends json
trait JsonWriter[A] {
def write(value: A): json
}
@Moverr
Moverr / chart.scala
Created May 20, 2023 21:17
Akka Chart Room
package kodeinc
import akka.NotUsed
import akka.actor.typed.{ActorRef, ActorSystem, Behavior, Terminated}
import akka.actor.typed.scaladsl.Behaviors
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
@Moverr
Moverr / evenSpaced.c
Created May 11, 2023 12:54
Is Evenly Saced
#include <stdio.h>
int main(){
//int n[]={100,19,131,140};
//int n[]={200,1,151,160};
int n[]={200,10,151,160};
printf("Blessed \n ");
int value = evenSpaced(n,4);
printf("result : %d \n",value);
@Moverr
Moverr / mera.c
Last active May 10, 2023 22:32
A Simple C functions that returns 1 if an array contains a zero and prime number else 0 is returned
#include <stdio.h>
int main(){
printf("Get the Result");
int record[] = {7,6,10};
//int record[] = {3,7,0,8,0,5};
int result = isMera(record,3);
printf("......%d",result);
return 1;
}
@Moverr
Moverr / calculator.scala
Created May 9, 2023 21:40
Akka Calculator
package kodeinc
import akka.actor.typed.{ActorRef, ActorSystem, Behavior}
import akka.actor.typed.scaladsl.Behaviors
import java.util
object akkaCalc {
sealed trait Response
case class error(errorCode:String,msg:String) extends Response
@Moverr
Moverr / broc.c
Created May 3, 2023 19:14
Write a function named hasStringMode that takes an array argument, and return 1 if the mode Value in its array occurs exactly once otherwise return 0;
#include <stdio.h>
int main(){
int x = 10;
int y =x++;
//int arra[] ={1,-29,8,5,-29,6};s
int arra[] ={1,2,3,4,7};
printf("belong %d",hasStringMode(arra));
return 1;
@Moverr
Moverr / typedActorsCalculator.scala
Created July 8, 2022 23:58
Simple Calculator Using Typed Actors Case Classes and Sealed Trait
package part1Recap
import akka.actor.typed.{ActorSystem, Behavior}
import akka.actor.typed.scaladsl.Behaviors
object ActorCalcApp {
sealed trait calculator
case class calc[T](a:T,b:T,action:String) extends calculator
object CalcExample extends App{
trait calculate[T]{
def calc(a:T,b:T)(c:String):T
}
@Moverr
Moverr / Main.scala
Created February 23, 2021 19:43 — forked from jpallari/Main.scala
Ways to pattern match generic types in Scala
object Main extends App {
AvoidLosingGenericType.run()
AvoidMatchingOnGenericTypeParams.run()
TypeableExample.run()
TypeTagExample.run()
}
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
}
object loops {
def isEven(number: Int) = number % 2 == 0
def main(args: Array[String]): Unit = {
val list = List(1, 2, 3, 4, 5)
list.foreach(x => if(isEven(x)) println(x) )