Skip to content

Instantly share code, notes, and snippets.

View diyan's full-sized avatar

Oleksii Diian diyan

View GitHub Profile
@diyan
diyan / Dockerfile
Created April 27, 2020 18:20
Dockerfile for Kotlin app using multi-stage build and FatJar
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 / pci_dss.md
Last active February 9, 2024 17:58
PCI DSS. Useful resources
@diyan
diyan / gui_automation_python.md
Last active December 4, 2023 14:48
Desktop GUI automation in Python

Desktop

UI Automation. Desktop. Python

GUI toolkit agnostic

autopy - simple, cross-platform GUI automation toolkit. MIT - https://github.com/msanders/autopy/

  • 432 stars, 102 forks, 2950 monthly downloads at 2015-05-13
  • GUI toolkit agnostic
@diyan
diyan / fabric_monkey_patch.py
Created August 1, 2012 16:12
Fabric monkey patch for replacing SSH transport with WinRM
import sys
import time
import subprocess
import types
from tempfile import TemporaryFile
def remote_sh(target_host, login, password, command_text, stdout=None, stderr=None):
winrs_text = 'winrs -remote:{0} -username:{1} -password:{2} -noprofile {3}'.format(
target_host, login, password, command_text)
#print('winrs text: {0}\n'.format(winrs_text))
@diyan
diyan / gist:2850866
Created June 1, 2012 09:54
Python with PowerShell Remoting (Windows equivalent for Unix ssh sessions)
# Note that target_env.login and target_env.password is global variables
# Maybe I should add this into Fabric project (http://docs.fabfile.org/en/1.4.2/index.html).
# This is complicated task for sure but it would be nice if Fabric could use ssh under Linux and PowerShell Remoting under Windows.
def remote_sh(target_host, command_text, ignore_error=False):
print('run PowerShell script block at {0}: {1}'.format(target_host, command_text))
command_text = command_text.replace('"', '\'')
@diyan
diyan / google_http_client_gson_integration.md
Last active June 28, 2023 20:54
Bridge between Gson/GsonBuilder and Google HTTP Client.

Note that JsonHttpContent class from com.google.http-client/google-http-client-gson does not support the full feature set of Gson library.

Instead it just relies on the JsonParser provided by Gson.

Code snippet below provides a bridge between full featured Gson/GsonBuilder and Google HTTP Client.

See https://stackoverflow.com/questions/34690059/configuring-the-gsonfactory-of-google-http-client

See https://github.com/googleapis/google-http-java-client/tree/main/google-http-client-gson/src/main/java/com/google/api/client/json/gson

@diyan
diyan / apache_http_components_for_google_http_client.md
Last active June 28, 2023 18:46
Configure Apache HttpComponents backend for Google HTTP Client
package com.example.project;

import java.io.IOException;

import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpVersion;
import org.apache.http.client.methods.HttpRequestWrapper;

Apache HttpComponents

ArrayList<NameValuePair> formParams = new ArrayList<>();
formParams.add(new BasicNameValuePair("paramA", "valueA"));
formParams.add(new BasicNameValuePair("paramB", "valueB"));
formParams.add(new BasicNameValuePair("paramC", "valueC"));

BusinessObject businessObject = new BusinessObject();

CloseableHttpClient httpClient = HttpClientBuilder.create().build();
@diyan
diyan / docker_buildx_kotlin_gradle.md
Created December 4, 2020 19:53
Gradle build time on AMD64 vs ARM64 using Docker multi-arch build feature

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.
@diyan
diyan / python_qa_automation.md
Last active February 21, 2023 20:33
Learning Python for QA automation tasks

Hello all,

In this gist you may find resources in Russian/English which could be useful for writing Python script for test automation tasks.

What Python runtime I should use?

While Python 3.x (>=3.3) is reccomended for new project development it much better and easier to go with a bit older but rock-solid Python 2.x (>=2.7) for test automation.

Some Python packages comes with binary modules and it much easier to use 32-bit Python under Windows due to this reason.