Skip to content

Instantly share code, notes, and snippets.

val pprint2 =
pprint.copy(
additionalHandlers = {
case value: java.nio.file.Path =>
val v = pprint.Util.literalize(value.toString)
pprint.Tree.Apply(
"Paths.get",
Iterator(v).map(pprint.Tree.Literal.apply)
)
case value: scala.meta.inputs.Position.Range =>
import $ivy.`io.get-coursier::coursier:2.0.0-RC6-21`
import coursier._
import java.io.File
import java.io.FileInputStream
import scala.concurrent.ExecutionContext
def extractMainClassName(file: File): Option[String] = {
val jarStream =
new java.util.jar.JarInputStream(new FileInputStream(file))
val mf = jarStream.getManifest
Option(mf.getMainAttributes).flatMap(attrs =>
@d10xa
d10xa / Http4sProxyExample.scala
Created March 28, 2020 11:32
http4s + AsyncHttpClient + proxy
import cats.effect.ContextShift
import cats.effect.IO
import cats.effect.Sync
import org.asynchttpclient.DefaultAsyncHttpClientConfig
import org.asynchttpclient.Realm
import org.asynchttpclient.proxy.ProxyServer
import org.asynchttpclient.proxy.ProxyType
import org.http4s._
import org.http4s.client._
import org.http4s.client.asynchttpclient.AsyncHttpClient
{
"jadd": {
"repositories": [
"central"
],
"dependencies": [
"ru.d10xa::jadd:latest.stable"
]
},
"json-log-viewer": {
@d10xa
d10xa / jsoninjson.py
Created January 25, 2019 11:08
Wraps json from stdin into string field
import json, sys; print(json.dumps({sys.argv[1] if len(sys.argv) > 1 else 'data': json.dumps(json.loads(sys.stdin.read()), ensure_ascii=False)}, ensure_ascii=False))
import cats.data.EitherNel
import cats.data.NonEmptyList
import cats.implicits._
object SeqEitherNel {
def main(args: Array[String]): Unit = {
def data =
(1 to 5).map {
@d10xa
d10xa / eurekasimple.py
Last active December 20, 2017 14:43
Simple client for netflix eureka
import logging
import signal
import sys
import threading
import requests
class Eureka(object):
started = False
@d10xa
d10xa / AkkaHttpProxyCredentialsMain.scala
Created September 10, 2017 12:52
Akka. Support for HTTP(S) proxies with Authorization
import java.net.InetSocketAddress
import akka.actor.ActorSystem
import akka.http.scaladsl.ClientTransport
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.model.headers
import akka.http.scaladsl.settings.ConnectionPoolSettings
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.stream.ActorMaterializer

Keybase proof

I hereby claim:

  • I am d10xa on github.
  • I am d10xa (https://keybase.io/d10xa) on keybase.
  • I have a public key ASA05WWJEOFJ6lXZ1ihPundpRZm_H8pslAhXxM1P0g5bwgo

To claim this, I am signing this object:

package ru.d10xa.hibernate
import org.springframework.data.repository.CrudRepository
import javax.persistence.*
@Entity
class Language {
@Id @GeneratedValue Long id;
String name