Skip to content

Instantly share code, notes, and snippets.

View fanf's full-sized avatar

François Armand fanf

View GitHub Profile
@fanf
fanf / ZioYamlTest.scala
Created August 22, 2023 09:37
Bad encoding in ZIO Yaml
package test.yaml
import zio.json._
import zio.json.yaml._
// Default indentation seems broken in YAML.
// If we change zio.json.yaml.JsonOps to add `setIndentWithIndicator(true)` it seems to work
//
// dumperOptions.setLineBreak(options.lineBreak)
// + dumperOptions.setIndentWithIndicator(true)
[01/08/2023 09:39:34 am] Organising filesystem
[01/08/2023 09:39:34 am] ATLauncher Version: 3.4.30.0 [40636a6dca574117f5e428313a6191ff3c5a9840]
[01/08/2023 09:39:34 am] App Arguments: ["--install-method=aur-bin","--no-launcher-update"]
[01/08/2023 09:39:34 am] JVM Arguments: ["-Dawt.useSystemAAFontSettings=on","-Dswing.aatext=true"]
[01/08/2023 09:39:34 am] Java Version: Java 19 (19.0.2)
[01/08/2023 09:39:34 am] Java Path: /usr/lib/jvm/java-20-openjdk
[01/08/2023 09:39:34 am] 64 Bit Java: true
[01/08/2023 09:39:34 am] RAM Available: 30848MB
[01/08/2023 09:39:34 am] Launcher Directory: **USERSDIR**
[01/08/2023 09:39:35 am] GPU: Rembrandt [Radeon 680M] (Advanced Micro Devices, Inc. [AMD/ATI] (0x1002)) unknown 258MB VRAM
name of display: :0.0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_context_flush_control, GLX_ARB_create_context,
GLX_ARB_create_context_no_error, GLX_ARB_create_context_profile,
GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float,
GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample,
@fanf
fanf / threaddump.txt
Created April 14, 2023 06:55
ZIO deadlock on multiple unsafe.run and foreachPar
2023-04-14 08:49:40
Full thread dump OpenJDK 64-Bit Server VM (11.0.18+10 mixed mode):
Threads class SMR info:
_java_thread_list=0x00007fd8b00016d0, length=56, elements={
0x00007fda0802c000, 0x00007fda09237800, 0x00007fda0923c000, 0x00007fda09251800,
0x00007fda09253800, 0x00007fda09255800, 0x00007fda09257800, 0x00007fda0925a000,
0x00007fda09746800, 0x00007fda09bb5800, 0x00007fd9b8001000, 0x00007fda09eb5800,
0x00007fda09fdb000, 0x00007fda09fdc000, 0x00007fda09fdd800, 0x00007fda09fdf000,
0x00007fda09fe1000, 0x00007fda09fe2800, 0x00007fda09fe4800, 0x00007fda09fe6000,
/*
* These codec used to work with zio-json 2.0.0-M3 but are not working anymore with
* zio-json 3.0.0-R7.
* Even more strange, if I remove the encoder part (ie from codec to simple decoder),
* then the decoding works in 3.0.0-R7.
* It looks like a bug
*/
package test
@fanf
fanf / zio-answers-scalac.md
Last active November 17, 2021 06:59
Jan Nasiadka interview questions about ZIO

Jan Nasiadka from scalac contacted me to get some feedback about our usage of ZIO. My answers below, since they can benefit the community more broadly.

Context: we use ZIO in the context of https://rudder.io, a scala application that is 11 years old - far from a greenfield application with ZIO as base architectural choice. We used ZIO as a better framework to cleanly manage errors, porting piece of existing code to it. We are part of ZIO community since 2018 (since ZIO inception, when it was not yet ZIO but a part of scalaz, and when there was only a bifunctor, no context in it). Given our usage, we use ZIO in a specific way: we have tons of entry points and evaluation of ZIO effects, not one main entry point in the "main" method of the app. For correctness, that forced us to call a lot of blocking effects (you never know what a java lib is doing), and so we stressed the thread pool ergonomics, and helped make that part better (and some part

@fanf
fanf / StoreLexer.scala
Last active March 30, 2021 14:45
A value lexer for zio-json that stores said value in a frame buffer
package zio.json.internal
object StoreLexer {
/*
* An utility method that store the next value in a string so that
* something else can parse it.
* Copied fomr zio.json.Lexer#skipValue
*/
import zio.json.JsonDecoder._
[root@server vagrant]# yum install rudder-server-root
CentOS-8 - AppStream 24 kB/s | 4.3 kB 00:00
CentOS-8 - Base 20 kB/s | 3.9 kB 00:00
CentOS-8 - Extras 3.5 kB/s | 1.5 kB 00:00
Rudder 6.2-nightly Repository 635 kB/s | 190 kB 00:00
Package rudder-server-root-1398866025:6.1.7.rc1.git202012030313-1.EL.8.noarch is already installed.
Dependencies resolved.
===============
6.1
<a href="javascript://" onclick="lift.ajax(&quot;F1181437850057OOOOSP=true&quot;, null, null, null); return false;"><span class="treeActiveTechniqueName bsTooltip " data-toggle="tooltip" data-placement="top" data-html="true" title="&#x000a; &lt;h4>Package manager settings (RUG/YaST/ZMD)&lt;/h4>&#x000a; &lt;div class=&quot;tooltip-content&quot;>&#x000a; &lt;p>This technique configures the RUG and YaST package manager using Novell's ZMD.&lt;/p>&#x000a; &lt;p>This Technique is only compatible with &lt;b>Classic&lt;/b> agent.&lt;/p>&#x000a; &#x000a; &lt;/div>"><i class="fa fa-gear tree-icon"></i>Package manager settings (RUG/YaST/ZMD)</span></a>
6.2
<a href="javascript://" onclick="lift.ajax(&quot;F10805191239355LRKGG=true&quot;, null, null, null); return false;"><span class="treeActiveTechniqueName bsTooltip " data-toggle="tooltip" data-placement="top" data-html="true" title="&#x000a; &lt;h4>Pac
@fanf
fanf / TestBatchWithZio.scala
Created March 25, 2020 14:00
Testing batch process with ZIO. Concurrency is hard.
import zio._
import zio.clock._
import zio.duration._
import zio.test.environment._
import java.util.concurrent.TimeUnit
object Batch {