Skip to content

Instantly share code, notes, and snippets.

import scala.deriving.Mirror
import scala.quoted.*
import scala.compiletime.constValue
trait EnumWithValue:
def value: String
object EnumWithValue:
inline def enumMapValues[E <: EnumWithValue](using
m: Mirror.SumOf[E]
@narma
narma / wsl-subl.go
Created August 8, 2023 15:10
Execute SublimeText from wsl
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
#!/usr/bin/env -S scala-cli shebang
//> using scala "3.2.2"
import scala.collection.mutable
enum Color:
case Yellow
case Blue
@narma
narma / redpanda_compatibility_tests_output_1.log
Created April 24, 2021 00:07
redpanda compatibility tests first results
[info] RedpandaSpec:
[info] Creating container for image: vectorized/redpanda:v21.4.14
[info] Starting container with ID: 87a58766b73e33e0ff0a8fd21deaa2cb58f7c8aa07897bb2ec7dd88a5fdcb474
[info] Container vectorized/redpanda:v21.4.14 is starting: 87a58766b73e33e0ff0a8fd21deaa2cb58f7c8aa07897bb2ec7dd88a5fdcb474
[info] Container vectorized/redpanda:v21.4.14 started in PT4.338022S
[info] - should #1 produce messages when all topic was created
[info] Creating container for image: vectorized/redpanda:v21.4.14
[info] Starting container with ID: f4b4486026d74d2e15de2690fbdd0e3910074c4e8ccc24a0266b61c808044857
[info] Container vectorized/redpanda:v21.4.14 is starting: f4b4486026d74d2e15de2690fbdd0e3910074c4e8ccc24a0266b61c808044857
[info] Container vectorized/redpanda:v21.4.14 started in PT4.133538S
@narma
narma / diag.scala
Last active March 23, 2021 11:27 — forked from jsfwa/diag.scala
//Any - because everything in zio is private even diagnostic trait
class StreamDiagnostics(val queue: Queue[Any]) extends LogSupport {
val map = TrieMap.empty[String, Promise[Throwable, Unit]]
def runWithMonitor[R](tp: TopicPartition, stream: ZStream[R, Throwable, _]): ZIO[R, Throwable, Unit] =
for {
p <- Promise.make[Throwable, Unit]
_ <- queue.offer(StreamControl(tp, p))
fb <- stream
testM("should close old stream during rebalancing under load") {
val nrMessages = 40000
val nrPartitions = 3
import zio.stream.Stream
def run(instance: Int, topic: String, allAssigments: Ref[Map[Int, Set[Int]]]) = {
val subscription = Subscription.topics(topic)
Consumer
.subscribeAnd(subscription)
@narma
narma / Gemfile
Created June 24, 2020 22:52 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@narma
narma / zio_binary_crash.txt
Created February 16, 2020 00:40
ZIO application compiled to binary with GraalVM fail to run due to scala-reflect
Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.Invokers$Holder.invokeExact_MT(Object, Object)
at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:101)
at scala.reflect.internal.util.StatisticsStatics.areSomeColdStatsEnabled(StatisticsStatics.java:43)
at scala.reflect.internal.Symbols$TypeSymbol.<init>(Symbols.scala:3232)
at scala.reflect.internal.Symbols$ClassSymbol.<init>(Symbols.scala:3288)
at scala.reflect.internal.Symbols$ModuleClassSymbol.<init>(Symbols.scala:3461)
at scala.reflect.internal.Symbols$PackageClassSymbol.<init>(Symbols.scala:3510)
at scala.reflect.internal.Mirrors$Roots$RootClass.<init>(Mirrors.scala:306)
at scala.reflect
#!/bin/sh
ngrep -d lo -W byline port $1
@narma
narma / centos_htop.sh
Created January 31, 2019 14:30
Install HTOP on centos/
wget dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm && rpm -ihv epel-release-7-11.noarch.rpm