Skip to content

Instantly share code, notes, and snippets.

View Andrei-Pozolotin's full-sized avatar

Andrei Pozolotin Andrei-Pozolotin

View GitHub Profile
@Andrei-Pozolotin
Andrei-Pozolotin / RioArt.java
Last active January 3, 2017 19:43
RioArt.java - expose aeron sink/source https://github.com/akka/akka/issues/22096
package akka.remote.artery.rio;
import akka.Done;
import akka.actor.ActorSystem;
import akka.actor.ExtendedActorSystem;
import akka.remote.RemoteActorRefProvider;
import akka.remote.artery.AeronSink;
import akka.remote.artery.AeronSource;
import akka.remote.artery.AeronSource.ResourceLifecycle;
import akka.remote.artery.ArteryTransport;
@Andrei-Pozolotin
Andrei-Pozolotin / Main.java
Last active January 3, 2017 20:10
BUG: appender -> tailer synchronization contract: https://github.com/OpenHFT/Chronicle-Queue/issues/317
package demo;
import java.text.SimpleDateFormat;
import java.util.Date;
import net.openhft.chronicle.queue.ExcerptAppender;
import net.openhft.chronicle.queue.ExcerptTailer;
import net.openhft.chronicle.queue.RollCycles;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueue;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;

Scoped Implicit Lifetimes

All things considered, our experience in Scala Native has shown that resource management in Scala is way harder than it should be. This gist presents a simple design pattern that makes it resource management absolutely hassle-free: scoped implicit lifetimes.

The main idea behind it is to encode resource lifetimes through a concept of an implicit scope. Scopes are necessary to acquire resources. They are responsible for disposal of the resources once the evaluation exits the

@Andrei-Pozolotin
Andrei-Pozolotin / ExecutionContextExecutorServiceBridge.scala
Created March 15, 2017 17:42 — forked from viktorklang/ExecutionContextExecutorServiceBridge.scala
Turning an ExecutionContext to an ExecutorService (or rather and ExecutorService AND an ExecutionContext) using Scala 2.10+
/*
Copyright 2013 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
https://github.com/scala/bug/issues/10587
the rationale is:
- `ForkJoinPool` and `ExecutionContext.global` behave differently
- `ForkJoinPool` threads terminate upon interrupt
- `ExecutionContext.global` threads stay alive upon interrupt
for `ForkJoinPool` see: main1.Main.scala
for `ExecutionContext.global` see: main2.Main.scala
RUN $ECLIPSE_INSTALL \
-tag "scala-ide-nightly" \
-repository http://download.eclipse.org/releases/oxygen/ \
-repository http://download.eclipse.org/eclipse/updates/4.7 \
-repository http://download.scala-ide.org/plugins/equinox-weaving-launcher/releases/site \
-repository http://download.eclipse.org/tools/orbit/downloads/drops/R20170919201930/repository/ \
-repository http://download.eclipse.org/technology/nebula/snapshot \
-repository http://download.eclipse.org/tools/ajdt/47/dev/update \
-repository http://download.scala-ide.org/nightly \
-installIU org.scala-ide.sdt.feature.feature.group \
@Andrei-Pozolotin
Andrei-Pozolotin / a-scala-js-structured-type.md
Last active November 21, 2017 16:08
scala js structured type method access
@Andrei-Pozolotin
Andrei-Pozolotin / gist:85a1218c2a2353890e4222d6b8eb78db
Created November 21, 2017 23:47 — forked from xeno-by/gist:5967900
Macro-powered structural types
import scala.annotation.StaticAnnotation
import scala.reflect.macros.Macro
import language.experimental.macros
class body(tree: Any) extends StaticAnnotation
trait Macros extends Macro {
import c.universe._
def selFieldImpl = {
@Andrei-Pozolotin
Andrei-Pozolotin / pretty-print.scala
Created January 26, 2018 00:15 — forked from carymrobbins/pretty-print.scala
Pretty print Scala case classes and other data structures.
/**
* Pretty prints a Scala value similar to its source represention.
* Particularly useful for case classes.
* @param a - The value to pretty print.
* @param indentSize - Number of spaces for each indent.
* @param maxElementWidth - Largest element size before wrapping.
* @param depth - Initial depth to pretty print indents.
* @return
*/
private def prettyPrint(a: Any, indentSize: Int = 2, maxElementWidth: Int = 30, depth: Int = 0): String = {
@Andrei-Pozolotin
Andrei-Pozolotin / ! "expected" annotation does not work with new TestAdapter.scala in 0.6.22.md
Last active January 30, 2018 15:13
"expected" annotation does not work with new TestAdapter.scala in 0.6.22
  1. issue:

"expected" annotation does not work with new TestAdapter.scala in 0.6.22

@Test( expected = classOf[ IllegalStateException ] )

  1. despite valid code is present in junit-runtime