Skip to content

Instantly share code, notes, and snippets.

View erikvanoosten's full-sized avatar

Erik van Oosten erikvanoosten

View GitHub Profile
View ZioKafkaIssue852.scala
package zio.kafka.example
import io.github.embeddedkafka.{ EmbeddedK, EmbeddedKafka, EmbeddedKafkaConfig }
import org.apache.kafka.clients.producer.ProducerRecord
import zio._
import zio.kafka.consumer.Consumer.AutoOffsetStrategy
import zio.kafka.consumer.{ Consumer, ConsumerSettings, OffsetBatch, Subscription }
import zio.kafka.producer.{ Producer, ProducerSettings }
import zio.kafka.serde.Serde
import zio.logging.backend.SLF4J
View MinimalReproducer.scala
package test
import zio._
import zio.internal.ExecutionMetrics
object MinimalReproducer extends ZIOAppDefault {
* A runtime layer that can be used to run everything on the thread of the caller.
erikvanoosten / RuntimeReproducer.scala
Created April 8, 2023 05:47
Reproduces problem where a ZIO taks runs on another thread than expected
View RuntimeReproducer.scala
import zio.internal.ExecutionMetrics
import zio.{Executor, Runtime, RuntimeFlag, RuntimeFlags, Scope, Task, Trace, Unsafe, ZIO, ZIOAppArgs, ZIOAppDefault, ZLayer}
object RuntimeReproducer extends ZIOAppDefault {
override def run: ZIO[Any with ZIOAppArgs with Scope, Any, Any] =
for {
runtime <- ZIO.runtime[Any]
_ <- ZIO.attempt {
println("main thread id" + Thread.currentThread().getId)

Keybase proof

I hereby claim:

  • I am erikvanoosten on github.
  • I am erikvanoosten ( on keybase.
  • I have a public key ASAGx3KiQYeMb9TXRsaSLpS2XNt6-W2zd-d9XV1nT72G2Ao

To claim this, I am signing this object:

erikvanoosten / Parboiled2CsvParser.scala
Created September 23, 2015 11:37 — forked from maciej/Parboiled2CsvParser.scala
Parboiled2 CSV parser
View Parboiled2CsvParser.scala
/* based on comments in */
case class Parboiled2CsvParser(input: ParserInput, delimeter: String) extends Parser {
def DQUOTE = '"'
def DELIMITER_TOKEN = rule(capture(delimeter))
def DQUOTE2 = rule("\"\"" ~ push("\""))
def CRLF = rule(capture("\n\r" | "\n"))
def NON_CAPTURING_CRLF = rule("\n\r" | "\n")
val delims = s"$delimeter\r\n" + DQUOTE
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.*;
import com.yammer.metrics.reporting.GraphiteReporter;
import com.yammer.metrics.reporting.SocketProvider;
import com.yammer.metrics.stats.Snapshot;
import java.util.concurrent.TimeUnit;
# one way (older scala version will be installed)
# sudo apt-get install scala
#2nd way
sudo apt-get remove scala-library scala
sudo dpkg -i scala-2.10.3.deb
sudo apt-get update
View gist:7293883
TIMECAPSULE_IP="" # e.g. ""
TIMECAPSULE_VOLUME="/Time Capsule" # also try "/Data"
export PASSWD='YOURPASSWORDHERE' # No need to escape anything (except "'")
MOUNT_POINT="/mnt/timecapsule" # no need to create the directory
IS_MOUNTED=`mount 2> /dev/null | grep "$MOUNT_POINT" | cut -d' ' -f3`
if [[ "$IS_MOUNTED" ]] ;then
erikvanoosten / gist:3604873
Last active October 10, 2015 00:38
Sentries example usage
View gist:3604873
class DoItAllService extends {
val dbSentry = sentry("mysql:localhost:3366") withMetrics withFailLimit(failLimit = 5, retryDelay = 500 millis)
val twitterApiSentry = sentry("twitter") withMetrics withFailLimit(failLimit = 5, retryDelay = 500 millis) withConcurrencyLimit(3)
def loadTweetFromDb(id: Long): Tweet = dbSentry {
def getFromTwitter(id: Long): Tweet = twitterApiSentry {
erikvanoosten / gist:1059045
Created July 1, 2011 17:40
Example of a specs2 unit test, with mocks and rich context
View gist:1059045
import org.specs2.mutable._
import org.specs2.mock._
import org.specs2.specification.Scope
class ParentElementStrategyTest extends SpecificationWithJUnit with Mockito {
"The ParentElementStrategy" should {
"extract a user ref" in new SimpleContext {
val testColumn = mock[Column]
registry.get("") returns testColumn
userStrategy("user").getShardForEntity(ad, columns) must beTheSameAs(testColumn)