Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexey Diyan diyan

View GitHub Profile
View time_parser_test.go
package loose
import (
"encoding/json"
"testing"
"time"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
View Balancer.kt
package com.example.akka.stream
import akka.NotUsed
import akka.stream.FlowShape
import akka.stream.javadsl.Balance
import akka.stream.javadsl.Flow
import akka.stream.javadsl.GraphDSL
import akka.stream.javadsl.Merge
// Most likely those classes are useless
@diyan
diyan / docker_buildx_kotlin_gradle.md
Created Dec 4, 2020
Gradle build time on AMD64 vs ARM64 using Docker multi-arch build feature
View docker_buildx_kotlin_gradle.md

Gradle build time on AMD64 vs ARM64 using Docker multi-arch build feature

AMD64. docker buildx build --platform=linux/amd64 --tag=sample-app:amd64 .
ARM64. docker buildx build --platform=linux/arm64 --tag=sample-app:arm64 .

AMD64. An attempt to start the daemon took 1.883 secs.
ARM64. An attempt to start the daemon took 51.799 secs.

AMD64. :compileKotlin (Thread[Execution worker for ':' Thread 5,5,main]) completed. Took 25.839 secs.
View sharded_redis_cluster_behavior.md

Sharded Redis Cluster Behavior

Provision Sharded Redis Cluster using Docker Compose

$ curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-redis-cluster/master/docker-compose.yml > docker-compose.yml
$ docker-compose up

Write sample dataset

@diyan
diyan / terraform_iam.md
Last active Apr 28, 2020
Examples of Terraform and AWS IAM resources
View terraform_iam.md

AWS IAM using Terraform

Example 1

// Data Resource for IAM Policy Document
// String interpolation
// Separate IAM Policy attached to IAM Role
data "aws_iam_policy_document" "cloudwatch_logs_write_policy" {
  statement {
    actions = [
@diyan
diyan / Dockerfile
Created Apr 27, 2020
Dockerfile for Kotlin app using multi-stage build and FatJar
View Dockerfile
FROM openjdk:8-alpine as builder
# johnrengelman/shadow v5.2.0 requires Gradle v5
# but openjdk:8-alpine packaged with Alpine v3.9
# which packaged with Gradle v4.10.3
RUN set -x \
&& apk add --update --no-cache --repository=http://nl.alpinelinux.org/alpine/v3.10/community gradle
# Install deps before copying code, use docker cache for external packages
WORKDIR app
@diyan
diyan / LooseMapDeserializerTest.kt
Last active Apr 14, 2020
Kotlin, Jackson, JUnit5, AssertJ
View LooseMapDeserializerTest.kt
package com.project.json
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.readValue
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
@diyan
diyan / aws_sdk_v2_ecs_config.kt
Last active Dec 18, 2019
ECS. AutoScaling config, Service placement, container limits in Kotlin
View aws_sdk_v2_ecs_config.kt
import com.fasterxml.jackson.annotation.JsonPropertyOrder
import com.fasterxml.jackson.dataformat.csv.CsvMapper
import software.amazon.awssdk.services.ecs.EcsClient
import software.amazon.awssdk.services.ecs.model.DescribeClustersRequest
import software.amazon.awssdk.services.ecs.model.DescribeServicesRequest
import software.amazon.awssdk.services.ecs.model.DescribeTaskDefinitionRequest
import software.amazon.awssdk.services.ecs.model.ListServicesRequest
import java.util.concurrent.ForkJoinPool
import java.util.concurrent.TimeUnit
import kotlin.streams.asSequence
@diyan
diyan / wine416_staging__dotnet416_devpack.md
Last active Jan 20, 2021
WORKS. Setup Wine 4.16 Staging, winetricks, .NET 4.6.1 Developer Pack, NuGet. Compile ASP.NET Web Forms Web Site using Wine/MSBuild
View wine416_staging__dotnet416_devpack.md
FROM debian:9.11
# Wine on Debian 9, see https://wiki.winehq.org/Debian
# Winetricks, see https://wiki.winehq.org/Winetricks#Installing_winetricks
# WINEDEBUG=-all to suppress Wine debug output
# .NET Runtime via Winetricks, install sequence:
#   v4.0 on WinXP, v4.5 on Win7, v4.6 on Win2003, v4.6.1 on Win7.
RUN set -x \
    && tempDeps='software-properties-common apt-transport-https gnupg wget curl cabextract' \
    && apt-get update \
@diyan
diyan / wine402_aspnet461.md
Last active Sep 30, 2019
FAILED experiment. Setup Wine, winetricks, dotnet461, NuGet. Compile ASP.NET Web Forms Web Site using Wine/MSBuild
View wine402_aspnet461.md
FROM debian:9.11
# Wine on Debian 9, see https://wiki.winehq.org/Debian
# Winetricks, see https://wiki.winehq.org/Winetricks#Installing_winetricks
RUN set -x \
    && tempDeps='software-properties-common apt-transport-https gnupg wget curl cabextract' \
    && apt-get update \
    && apt-get install -y --no-install-recommends $tempDeps \
    && dpkg --add-architecture i386 \
    && wget -qO - https://dl.winehq.org/wine-builds/winehq.key | apt-key add - \