Skip to content

Instantly share code, notes, and snippets.

Avatar

François Armand fanf

View GitHub Profile
@fanf
fanf / zio-answers-scalac.md
Last active Nov 17, 2021
Jan Nasiadka interview questions about ZIO
View zio-answers-scalac.md

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 Mar 30, 2021
A value lexer for zio-json that stores said value in a frame buffer
View StoreLexer.scala
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._
View rudder-6.2-migration-error.txt
[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.
===============
View difference-directive.txt
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 Mar 25, 2020
Testing batch process with ZIO. Concurrency is hard.
View TestBatchWithZio.scala
import zio._
import zio.clock._
import zio.duration._
import zio.test.environment._
import java.util.concurrent.TimeUnit
object Batch {
@fanf
fanf / TestDefaultRuntime.scala
Last active Mar 10, 2020
Deadlock in ZIO with `Runtime.default` runtime
View TestDefaultRuntime.scala
/*
Dependencies:
- scala 2.13.1
- zio 1.0.0-RC18-1+44-24f507c2+20200310-2150-SNAPSHOT (local build on master on 2020-03-10)
- with openjdk 11.0.4+11
*/
package some.pkg
import zio.Runtime
@fanf
fanf / TestRuntime.scala
Created Mar 10, 2020
Deadlock with ZIO runtime / init in object
View TestRuntime.scala
object TestRuntime {
object internal {
val platform : _root_.zio.internal.Platform = _root_.zio.internal.Platform.makeDefault()
// a local runtime just to build first zlayer
private val r = Runtime((), platform)
// non memomized env
val env = ZEnv.live
val runtime = Runtime.unsafeFromLayer(env, platform)
@fanf
fanf / key.md
Last active Jan 9, 2020 — forked from shobotch/key.md
Twitter (un)official Consumer Key
View key.md

Twitter Official Consumer Key

Twitter for Android - REVOKED SINCE DECEMBER 2019

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN
Consumer key:    IQKbtAYlXLripLGPWd0HUA
View FlatMapGC.scala
package com.normation
import scala.concurrent.Future
object CheckMemoryReleaseFlatMap {
def getFreeMem = (Runtime.getRuntime().freeMemory() / (1024*1024)).toString + " MB"
def doGC = {
System.gc()
System.runFinalization()
View threadlock2.tdump
2019-11-30 17:28:06
Full thread dump OpenJDK 64-Bit Server VM (11.0.4+11 mixed mode):
Threads class SMR info:
_java_thread_list=0x00007f2104006610, length=92, elements={
0x00007f21bc099800, 0x00007f21bc618000, 0x00007f21bc629000, 0x00007f21bc63b800,
0x00007f21bc63d000, 0x00007f21bc63f000, 0x00007f21bc641000, 0x00007f21bc77e800,
0x00007f21bcc56000, 0x00007f21bcc5a800, 0x00007f21bcc5d800, 0x00007f21bccad800,
0x00007f2160001800, 0x00007f21bccb6800, 0x00007f2144476800, 0x00007f2140066000,