Skip to content

Instantly share code, notes, and snippets.

@frabbit
frabbit / Scope1Spec.scala
Last active July 26, 2022 10:39
This gist shows 2 test cases for creating a kafka consumer in ZIO 2.0 via acquireRelease. While the first example hangs, the second example works as expected. I had to use ZIO.interruptible in the second example to get it working. The question is why ZIO.interruptible is required and if it's a good solution at all.
import zio.*
import zio.test.*
import zio.test.Assertion.{equalTo, assertion}
import com.dimafeng.testcontainers.KafkaContainer
import zio.kafka.consumer.ConsumerSettings
import zio.kafka.producer.ProducerSettings
import zio.kafka.consumer.Consumer
import io.github.scottweaver.zio.testcontainers.kafka.ZKafkaContainer
import zio.kafka.consumer.Consumer.OffsetRetrieval
import zio.kafka.consumer.Consumer.AutoOffsetStrategy
@frabbit
frabbit / index.sh
Last active October 15, 2020 14:42 — forked from zkat/index.js
npx is cool
#!/usr/bin/env bash
echo "hello world"
package;
import scuts.implicit.Wildcard;
import scuts.implicit.Implicit;
import scuts.implicit.Instances;
import Main.BoolInstance.instance;
// for nicer syntax
charCodeAt 1 native 0 : 1x
charCodeAt 1 ucs2 0.0001 : 1.4x
charCodeAt 1 utf32 0.0001 : 1.12x
charCodeAt 1 utf8 0.0002 : 2.27x
charCodeAt 1 utf16 0.0001 : 1.49x
charCodeAt n native 0 : 1x
charCodeAt n ucs2 0.0001 : 1.46x
charCodeAt n utf32 0.0001 : 1.08x
charCodeAt n utf8 0.1279 : 1279.94x
charCodeAt n utf16 0.0918 : 918.07x
@frabbit
frabbit / A.haxe.io.ByteArray.hx
Last active November 14, 2016 17:20
ByteArray haxe
// fast byte access without class overhead and bounds checks like in haxe.io.Bytes
package haxe.io;
@:coreType abstract ByteArray {
public static var getIsChecked:Bool; // flags can be used in bytes to remove unnecessary or multiple bounds checks on different targets
public static var setIsChecked:Bool;
public static var blitCanThrow:Bool; // throws are neko specific flags, can be used in bytes to remove a bounds check
public static var subCanThrow:Bool;
@frabbit
frabbit / Test.hx
Last active August 29, 2015 14:13
Inlining could be done twice
class A implements B {
public function new () {}
public inline function plus (a:Int,b:Int):Int {
return a + b;
}
}
interface B {
| a,((TMono x) as b) ->
(match !x with
| None -> if not (link x b a) then error [cannot_unify t1 t2]
| _ -> error [cannot_unify t1 t2])
| ((TMono x) as a),b ->
(match !x with
| None -> if not (link x a b) then error [cannot_unify t1 t2]
| _ -> error [cannot_unify t1 t2])
Parsing bin/xml/neko.xml
Processing types
...............................................................................................................................................................................
Generating navigation
Generating to bin/pages
...............................................................................................................................................................
Generated 309 types in 20 packages
Copying resources from /media/frabbit/data/work/projects/github/dox-py/themes/default/resources
Done (11.01s)
16742913 function calls (16397456 primitive calls) in 11.586 seconds
Test.hx:240: Generated at: 2014-05-01 17:58:08
Test.hx:242: START
Test.hx:224: ABORTED : IndexError('string index out of range',) in unit.TestXML.testBasic
Test.hx:227: STACK :
Called from unit.py line 11775
Called from unit.py line 11422
Called from unit.py line 3755
Called from unit.py line 30247
Called from unit.py line 2319
@frabbit
frabbit / Test
Last active August 29, 2015 14:00
class Foo {
using MyModule;
import MyObject;
public static function main () {
import MyObject;
using MyModule2;
import MyStatics.myMethod;
myMethod(4);
}