Skip to content

Instantly share code, notes, and snippets.

View lure's full-sized avatar

Alex Shubert lure

  • JetBrains, LLC
View GitHub Profile

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@lure
lure / DockerDesktop.MD
Last active March 9, 2021 03:58
WSL | DockerDesktop

WSL default user and preserve file cetting( ~/.ssh)

To puth into /etc/wsl.conf

If chmod or chown takes no effect on files disk should be mounted with metadata like this.

[automount]
options = "metadata"

Sometimes WSL decide to start the session as a root. Fix it with this snippet

@lure
lure / Main.scala
Created May 24, 2020 03:38 — forked from jpallari/Main.scala
Ways to pattern match generic types in Scala
object Main extends App {
AvoidLosingGenericType.run()
AvoidMatchingOnGenericTypeParams.run()
TypeableExample.run()
TypeTagExample.run()
}
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
}
@lure
lure / compileGwt.groovy
Created September 7, 2019 19:56 — forked from marcokrikke/compileGwt.groovy
compileGwt Gradle task
task compileGwt (dependsOn: classes, type: JavaExec) {
buildDir = "${project.buildDir}/gwt"
extraDir = "${project.buildDir}/extra"
inputs.source sourceSets.main.java.srcDirs
inputs.dir sourceSets.main.output.resourcesDir
outputs.dir buildDir
// Workaround for incremental build (GRADLE-1483)
outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
@lure
lure / fpmax.scala
Created May 17, 2019 17:28 — forked from jdegoes/fpmax.scala
FP to the Max — Code Examples
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
@lure
lure / macros.scala
Created March 22, 2019 21:17
Macro string to symbol
import scala.reflect.macros.whitebox
import scala.language.experimental.macros
def symbolic_impl(c: whitebox.Context)(f: c.Expr[String]): c.Expr[scala.Symbol] = {
import c.universe._
c.Expr(q"""scala.Symbol(${c.eval[String](f)})""")
}
def symbolic(f: String): scala.Symbol = macro symbolic_impl
import cats.implicits._
//https://stackoverflow.com/questions/48744146/stacking-m-either-and-writer
object SafeLogWriter {
type FutureErrorOr[A] = EitherT[Future, Error, A]
type ErrorOr[A] = Either[Error, A]
type MyWriter[A] = WriterT[Future, Vector[String], A]
type MyStack[A] = EitherT[MyWriter, Error, A]
@lure
lure / postgresql_pg_stat_activity_with_tempfiles.sql
Created September 4, 2018 19:47 — forked from ng-pe/postgresql_pg_stat_activity_with_tempfiles.sql
postgresql "pg_stat_activity" with temporary files information
-- View pg_stat_activity with temporary files informations (file list and total file size)
-- version 0.3
SELECT
pg_stat_activity.pid AS pid,
CASE WHEN LENGTH(pg_stat_activity.datname) > 16
THEN SUBSTRING(pg_stat_activity.datname FROM 0 FOR 6)||'...'||SUBSTRING(pg_stat_activity.datname FROM '........$')
ELSE pg_stat_activity.datname
END
AS database,
@lure
lure / google-download.sh
Created April 3, 2018 20:23
Download files from google disk.
#!/bin/bash
SOURCE="$1"
if [ "${SOURCE}" == "" ]; then
echo "Must specify a source url"
exit 1
fi
DEST="$2"
if [ "${DEST}" == "" ]; then