Skip to content

Instantly share code, notes, and snippets.

View VadimKirilchuk's full-sized avatar

Vadim Kirilchuk VadimKirilchuk

View GitHub Profile
@VadimKirilchuk
VadimKirilchuk / ToLoggerPrintStream
Created June 28, 2021 14:38
ToLoggerPrintStream for Rest Assured
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import org.slf4j.Logger;
/**
* A wrapper class which takes a logger as constructor argument and offers a PrintStream whose flush
* method writes the written content to the supplied logger (debug level).
* <p>
* Usage:<br>
@VadimKirilchuk
VadimKirilchuk / clt.py
Created March 18, 2018 12:57
Central limit theorem in action
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import math
# distribution
# In probability theory and statistics, the Laplace distribution is a continuous probability distribution
# named after Pierre-Simon Laplace.
# It is also sometimes called the double exponential distribution,
# because it can be thought of as two exponential distributions
@VadimKirilchuk
VadimKirilchuk / csvToXlsx.groovy
Created February 10, 2018 12:51
Convert CSV to XLSX (Streaming)
#! /usr/bin/env groovy
@Grab("org.apache.poi:poi:3.16")
@Grab("org.apache.poi:poi-ooxml:3.16")
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.*;
/** more java than groovy, will make fancier later **/
def csvToXLSX() {
@VadimKirilchuk
VadimKirilchuk / RequestResponseFilter.java
Created October 10, 2017 08:04
RestAssured RequestResponseFilter
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jayway.restassured.filter.Filter;
import com.jayway.restassured.filter.FilterContext;
import com.jayway.restassured.filter.log.LogDetail;
@VadimKirilchuk
VadimKirilchuk / observable-share-issue.ts
Created February 26, 2017 20:48
Observable.share() issue
@Injectable()
export class AuthService {
private user: BehaviorSubject<User> = new BehaviorSubject<User>(null);
login(username: string, password: string) {
let user = new User("username", "email");
this.user.next(user);
}
/**
@VadimKirilchuk
VadimKirilchuk / ExposePropertyPlaceholderConfigurer.java
Last active August 29, 2015 13:57
Spring property placeholder configurer which exposes properties
/**
* Use instead of {@link PropertyPlaceholderConfigurer}
* to get access to properties loaded by spring.
* <p>
* Note: there is support to define file with list of properties which should stay unexposed.
*
*/
public class ExposePropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean {
private Map<String, String> resolvedProps = new TreeMap<String, String>();
@VadimKirilchuk
VadimKirilchuk / collectStats
Last active December 27, 2015 04:58
Collect some useful performance stats from linux pc
# to be improved later
#deletel old files
rm -rf vmstat.*
rm -rf iostat.*
rm -rf mpstat.*
date > vmstat.log
date > iostat.log
date > mpstat.log
@VadimKirilchuk
VadimKirilchuk / property-diff.groovy
Created July 25, 2013 10:46
Outputs difference between two java property files. Using just diff is not enough because properties can have different order, duplicated or commented,
if (this.args.length < 2) { throw new IllegalArgumentException("Please, give path to baseline properties and path to other properties")}
def excludeList = [/log4j\./]
File baseline = this.args[0] as File
File other = this.args[1] as File
Properties baselineProps = new Properties()
baseline.withInputStream { stream -> baselineProps.load(stream) }
@VadimKirilchuk
VadimKirilchuk / full-screen-carousel.html
Last active December 20, 2015 05:29
Useful snippet for creating utility view which rotates through different locations by using twitter bootstrap carousel.
@VadimKirilchuk
VadimKirilchuk / build.gradle
Last active December 16, 2015 20:49 — forked from Dierk/build.gradle
Snippet to easily generate directory structure for java/groovy/etc multimodule projects.
subprojects {
apply plugin: 'java'
task makeDirs(description:'make all dirs for project setup') << {
def sources = [sourceSets.main, sourceSets.test]
sources*.allSource*.srcDirs.flatten().each { File srcDir ->
println "making $srcDir"
srcDir.mkdirs()
}
}