Skip to content

Instantly share code, notes, and snippets.

View iravid's full-sized avatar

Itamar Ravid iravid

View GitHub Profile
package test
import scala.collection.immutable.StringOps
import scala.language.implicitConversions
object Main extends App {
val tags = Set(
Tag("bool", Set[Value[Value.T]](true, "hello", 156)),
Tag("int", 153),
Tag("string", "hello")
// Current OOP-style class
class SearchService(implicit ec: ExecutionContext) {
// these things need to be shutdown
val db = new GraphService
val index = new IndexService
def searchClasses(query: String): Future[List[FqnSymbol]] =
// do things with both db and index
def shutdown: Future[Unit] =
@iravid
iravid / FreeState.scala
Created January 11, 2018 20:42
Experimenting with hand-rolled interpreters for free structures
package freestate
sealed abstract class FreeState[S, A] { self =>
def tag: Int
final def map[B](f: A => B): FreeState[S, B] = self match {
case FreeState.Pure(a) => FreeState.Pure(f(a))
case _ =>
FreeState.FlatMap(self, (a: A) => FreeState.Pure(f(a)))
}
package com.iravid.managedt
import cats.{ Monad, MonadError, StackSafeMonad }
import cats.implicits._
abstract class ManagedT[F[_], R] {
def apply[A](use: R => F[A]): F[A]
}
object ManagedT {
(with-eval-after-load 'org
(progn
(setq org-src-lang-modes
(-cons* '("tut" . scala)
'("tut:silent" . scala)
'("tut:book" . scala)
org-src-lang-modes))
;;(advice-add 'org-md-link :override
(defun org-modified-md-link (link contents info)
(let ((link-org-files-as-md (lambda (raw-path)
def batch[F[_]: Concurrent, T, U](f: T => U, bound: Int)(implicit U: Monoid[U]): Pipe[F, T, U] =
input =>
Stream.eval(Queue.bounded[F, U](1)).flatMap { queue =>
val combiner = input.evalMapAccumulate((U.empty, 0)) {
case ((acc, currBound), t) =>
val u = f(t)
queue.offer1(u).flatMap { stored =>
if (stored) ((U.empty, 0), ()).pure[F]
else {
FROM alpine:3.8 as builder
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >>/etc/apk/repositories
RUN echo "@community http://dl-cdn.alpinelinux.org/alpine/edge/community" >>/etc/apk/repositories
RUN apk add --update --no-cache build-base linux-headers git cmake bash zlib zlib-dev bzip2 bzip2-dev snappy snappy-dev lz4 lz4-dev zstd@community zstd-dev@community jemalloc jemalloc-dev libtbb-dev@testing libtbb@testing
RUN cd /tmp && \
git clone https://github.com/gflags/gflags.git && \
cd gflags && \
mkdir build && \
FROM <ECR repo>/rocksdb-tools:0.0.1 as rocksdb-tools
...
COPY --from=rocksdb-tools /usr/bin/sst_dump /usr/bin/
COPY --from=rocksdb-tools /usr/bin/ldb /usr/bin/
...

Keybase proof

I hereby claim:

  • I am iravid on github.
  • I am iravid (https://keybase.io/iravid) on keybase.
  • I have a public key ASDGRabQXSobOIAmuu_VVb7Tf0vXOPEuKBm-3QLf3BkNIwo

To claim this, I am signing this object:

@iravid
iravid / zio-with-alpakka-kafka.scala
Created March 18, 2019 21:10
ZIO with Alpakka Kafka
import akka.actor.ActorSystem
import akka.kafka.ConsumerMessage.CommittableMessage
import akka.kafka.scaladsl.Consumer
import akka.kafka.{ ConsumerSettings, Subscriptions }
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{ Keep, Sink => AkkaSink }
import org.apache.kafka.common.serialization.StringDeserializer
import scalaz.zio._
import scalaz.zio.stream.Sink
import scalaz.zio.interop.reactiveStreams._