Skip to content

Instantly share code, notes, and snippets.

View stykalin's full-sized avatar

Aleksandr Stykalin stykalin

  • Russia
View GitHub Profile
@stykalin
stykalin / PoiController.kt
Last active November 15, 2023 07:29
Get Apache Poi Palette
import org.apache.poi.ss.usermodel.FillPatternType
import org.apache.poi.ss.usermodel.IndexedColors
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import java.io.ByteArrayOutputStream
@stykalin
stykalin / GetTagsFromBitBucketCommitMessage.py
Created June 19, 2022 11:09
Get tags from BitBucket commit message
import re
import requests
from requests.auth import HTTPBasicAuth
repo_url = '%repository_url%'
branch = '%teamcity.build.branch%'
r = repo_url.split("/")
prUrl = f"https://bitbucket.url/rest/api/1.0/projects/{r[3]}/repos/{r[4].replace('.git', '')}/{branch}"
print(prUrl)
@stykalin
stykalin / TwoBranchesAuto-mergeScript.sh
Created June 17, 2022 05:39
Script for auto-merging on CI from one branch (e.g. env1) to another branch (e.g. env2)
# Script for auto-merging on CI from one branch (e.g. env1) to another branch (e.g. env2).
# Usefull when you run the code from different branches on different environments.
# Assume that main developing environment is env1
# and for env2 the code should moustly the same, ecxept some minor parts, specific for env2.
# CI checkout the default branch (e.g. env1)
git checkout -B env2
git pull --no-edit
git merge env1
git push -u origin env2
@stykalin
stykalin / ScriptAsBookmark.md
Last active August 6, 2020 13:14
Run JS script as browser bookmark

To run some JS code as bookmark you need wrap your code in bookmark url as: javascript:(<here you code>)();

For example I generate GUUID this way:

javascript:(window.alert(([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15 >> c/4).toString(16))))();

For several rows code use: javascript:(function(){<here you code>})();

javascript:(function(){document.querySelector("input[name='login']").value=my_login;document.querySelector("input[name='password']").value=my_pass;})();
import com.fasterxml.jackson.databind.ObjectMapper
fun main() {
val info = mapOf("name" to "Alex", "age" to 35, "address" to mapOf("city" to "Ryazan", "street" to "My Street", "building" to 1))
val mapper = ObjectMapper()
mapper.writerWithDefaultPrettyPrinter().writeValue(File("info.json"), info)
}
1. Add dependecy:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
2.Create config file for log4j (https://logging.apache.org/log4j/2.x/manual/configuration.html).
I prefer log4j2-test.properties because according documentation this format will look second, after configFile:
'If no system property is set the properties ConfigurationFactory will look for log4j2-test.properties in the classpath.'
---------------------------------------------------------------
public class AllureTestNgListener implements
ISuiteListener,
ITestListener,
IInvokedMethodListener,
IDataProviderListener {
...
@Override
public void beforeDataProviderExecution(IDataProviderMethod iDataProviderMethod, ITestNGMethod iTestNgMethod, ITestContext iTestContext) {
final String parentUuid = classContainerUuidStorage.get(iTestNgMethod.getTestClass());