Skip to content

Instantly share code, notes, and snippets.

View batakpout's full-sized avatar
🎯
Focusing

aamir batakpout

🎯
Focusing
View GitHub Profile
import java.nio.file.{Files, Paths}
import cats.effect.{ExitCode, IO, IOApp, Resource}
import cats.implicits._
import scala.collection.mutable
import scala.io.Source
case class SensorData(sensorId: String, humidity: Double)
object Main extends IOApp {
@batakpout
batakpout / latency.txt
Created September 23, 2021 17:40 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
/**
* D Holbrook
*
* Code Club: PO1
*
* (*) Define a binary tree data structure and related fundamental operations.
*
* Use whichever language features are the best fit (this will depend on the language you have selected). The following operations should be supported:
*
* Constructors
import akka.actor._
import akka.event.{LookupClassification, EventBus}
import akka.event.ActorEventBus
case class Book(title: String, authors: List[String])
class AuthorBookBus(author: String) extends EventBus
with LookupClassification
with ActorEventBus {
import akka.actor._
case class Book(title: String, authors: List[String])
class BookPublisher extends Actor {
def receive = {
case book: Book => {
println(s"Yeah! Publishing a new book: $book")
context.system.eventStream.publish(book)
@batakpout
batakpout / GenericsStart
Created March 21, 2017 08:27
Simple Generic Start In Scala
package generics
object TestProb1 extends App {
//type constraints
class D[T <: B] // T must be a B. i.e. for any T, it is a B or a subclass of B.
new D[B]()
new D[C]()
//new D[A]() CTE (type arguments [generics.A] do not conform to class D's type parameter bounds [T <: generics.B]
val pattern = java.util.regex.Pattern.compile ("""(?xs) ("(.*?)"|) ; ("(.*?)"|) (?: \r?\n | \z ) """)
val matcher = pattern.matcher (input)
while (matcher.find) {
val col1 = matcher.group (2)
val col2 = matcher.group (4)
// ...
}