Skip to content

Instantly share code, notes, and snippets.


Vladimir Sitnikov vlsi

View GitHub Profile
vlsi /
Last active November 3, 2022 08:35
I would definitely recommend Kotlin generics to a Java fellow, here's why

Generics in Java are hard (sad, but true), however, Kotlin makes them way more accessible 🤩.

Suppose you are doing property-based testing. Just like I suggest, I was creating a jqwik test, and I ran into an issue with generic signatures.

Here's a minimal example, and it already has two issues.

Take a second and find both of them 😉

vlsi / ConcurrentHashMapKotlin.kt
Created May 10, 2021 13:10
A translation of OpenJDK's ConcurrentHashMap to Kotlin
View ConcurrentHashMapKotlin.kt
import java.util.concurrent.ThreadLocalRandom
* This is mostly automatic Java to Kotlin conversion followed with cleanups.
* See
object ConcurrentHashMapKotlin {
class TreeNode<K, V> {
// red-black tree links
var parent: TreeNode<K, V>? = null
vlsi / peg-parser.txt
Created April 17, 2021 13:17
View peg-parser.txt
// See
// Sample expressions:
// FindBy${Name}
// FindFirstBy${Name}
// FindBy${Name}And${OperationType}OrderBy${Name}And${OperationType}DescCount
Query "query"
= s:Start t:Transform* f:Finalizer?
{ return {start: s, transforms: t, finalizer: f} }
vlsi / build.gradle.kts
Last active October 7, 2020 12:14
Add Class-Path attribute to a jar manifest in Gradle
View build.gradle.kts
// Add Class-Path to the existing "jar" task
tasks.jar {
val classpath = configurations.runtimeClasspath
// Input declaration is needed for the proper up-to-date checks
manifest {
"Class-Path" to { cp -> cp.joinToString(" ") { it.absolutePath } }
vlsi /
Last active April 28, 2020 18:31
Publishing Gradle-based Java artifacts to a custom Nexus repository

Apache Maven enables developers to augment repository URL via settings.xml. That might sound powerful, however, it requires to use the same repository IDs across all the projects which might not be always possible.

Let's see how Gradle-based project can be published to a custom repository.

For instance, let's try to publish Apache Calcite to our own Nexus instance. Of course we don't want to commit the URL and password of our secretNexus to GitHub, so we need to augment the build without touching the files.

Gradle has Initialization Scripts that enable users to augment all the builds without touching project-specific files.

vlsi /
Created September 9, 2019 12:38

Keybase proof

I hereby claim:

  • I am vlsi on github.
  • I am vlsi ( on keybase.
  • I have a public key ASC2sRZGT4IKWFFWjBEznXZ8DHXjdgWnotEDW-x6_eLlYAo

To claim this, I am signing this object:

vlsi / hs_err_pid57596.log
Created November 4, 2017 08:37
shenandoah/jdk10 crash logs
View hs_err_pid57596.log
# A fatal error has been detected by the Java Runtime Environment:
# Internal Error (/Users/vladimirsitnikov/Documents/work/shenandoah/src/hotspot/share/opto/node.cpp:177), pid=57596, tid=27907
# assert(_refresh_tick < 2*100000) failed: DU iteration must converge quickly
# JRE version: OpenJDK Runtime Environment (10.0) (fastdebug build 10-internal+0-adhoc.vladimirsitnikov.shenandoah)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 10-internal+0-adhoc.vladimirsitnikov.shenandoah, mixed mode, tiered, compressed oops, g1 gc, bsd-amd64)
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
vlsi /
Created February 4, 2017 17:35
JTextArea append benchmark

According to the measurements, replaceRange + append works faster than setText except for the case when text is fully replaced. In 100% replace case setText is on par with replaceRange + append (the results are within error bounds).

For small appends there's a win in terms of response time and memory allocation.

# JMH 1.12 (released 309 days ago, please consider updating!)
# VM version: JDK 1.8.0_102, VM 25.102-b14
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/bin/java
vlsi / 01_init.sql
Last active September 8, 2016 18:50
PostgreSQL index only scan for expression testing
View 01_init.sql
drop table vlsi;
create table vlsi(pk int4, type numeric, vc varchar(500), num numeric);
insert into vlsi(pk, type,vc,num) select s.x, round(x/1000), md5('||x)||md5('||x+1)||md5(''||x+2), mod(x, 1000)
from generate_series(1,1000000) as s(x);
-- Several values exceeed 128 substr, so they require "table access"
insert into vlsi(pk, type,vc,num) select s.x+1000000, round(x/1000), lpad('a', 128, 'a')||'zxc'||s.x||'v', mod(x, 1000)
from generate_series(1,10) as s(x);
vlsi /
Last active March 7, 2018 06:12
JMeter suggestion: add comment that briefly describes test plan as an XML comment

Current JMeter's JMX files are not human-readable, and it is hard to review "diff" between two versions of a script.

I suggest adding a human-readable comment to the start of the file, so the diff between scripts can be easier to understand:

<?xml version="1.0" encoding="UTF-8"?>
Test plan:
   Thread group (146 threads, 1:00:00 duration)
      login (http sampler /login)