Skip to content

Instantly share code, notes, and snippets.

@thetekst
thetekst / StringCompressor.java
Last active October 15, 2022 22:11
Write string compressor
public static void main(String[] args) {
final var line = "abaabbbc"; //Expected result: aba2b3c
final var chars = line.toCharArray();
int count = 0;
char prev = ' ';
final var result = new ArrayList<Character>();
for (char current : chars) {
if (current == prev) {
count++;
@thetekst
thetekst / App.java
Last active October 9, 2022 12:21
count popular words in pdf
import com.google.common.base.CharMatcher;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
@thetekst
thetekst / alter.yml
Created March 31, 2022 14:46
native mssql query. alter sequence with stub rollback
databaseChangeLog:
- changeSet:
id: 2022-03-31-14-30
author: tkachenko
changes:
- sql:
dbms: mssql
sql: ALTER SEQUENCE ROCK_SEQ RESTART WITH 1 MINVALUE 1
rollback:
- sql:
@thetekst
thetekst / update.yml
Last active October 4, 2021 17:03
update column with another column value for oracle, postgresql, mssql, etc with where
databaseChangeLog:
- property:
dbms: oracle
name: my_date_type
value: to_date('2021-10-03','YY-MM-DD')
- property:
dbms: postgresql
name: my_date_type
value: date '2021-10-03'
@thetekst
thetekst / test.yml
Last active August 5, 2022 14:57
liquibase. oracle. fix ORA-22858: invalid alteration of datatype; ORA-01439: column to be modified must be empty to change datatype
databaseChangeLog:
- changeSet:
id: 2021100110000
author: test
changes:
- addColumn:
tableName: example_tab
columns:
- column:
name: rock_new
2020-10-18 15:26:10,784 DEBUG reactor.netty.http.client.HttpClient : [id: 0x779c09ee] REGISTERED
2020-10-18 15:26:10,788 DEBUG reactor.netty.http.client.HttpClient : [id: 0x779c09ee] CONNECT: httpbin.org/52.6.34.179:443
2020-10-18 15:26:11,150 DEBUG reactor.netty.http.client.HttpClient : [id: 0x779c09ee, L:/192.168.1.116:39582 - R:httpbin.org/52.6.34.179:443] ACTIVE
2020-10-18 15:26:11,409 DEBUG reactor.netty.http.client.HttpClient : [id: 0x779c09ee, L:/192.168.1.116:39582 - R:httpbin.org/52.6.34.179:443] READ COMPLETE
2020-10-18 15:26:11,482 DEBUG reactor.netty.http.client.HttpClient : [id: 0x779c09ee, L:/192.168.1.116:39582 - R:httpbin.org/52.6.34.179:443] READ COMPLETE
2020-10-18 15:26:11,711 DEBUG reactor.netty.http.client.HttpClient : [id: 0x779c09ee, L:/192.168.1.116:39582 - R:httpbin.org/52.6.34.179:443] USER_EVENT: SslHandshakeCompletionEvent(SUCCESS)
2020-10-18 15:26:11,728 DEBUG reactor.netty.http.client.HttpClientConnect : [id: 0x779c09ee, L:/192.168.1.116:39582 - R:httpbin.org/52.6.34.179:4
@thetekst
thetekst / Application.java
Created April 19, 2020 10:58
Spring Boot Test. Spock. Check for ApplicationContext
package ru.tkachenko.app;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author d.tkachenko
*/
@SpringBootApplication
public class Application {
@thetekst
thetekst / ddos.sh
Last active April 24, 2019 12:51
Do curl request in loop with certificate
#!/bin/bash
BASE_PATH="$HOME/nginx/ssl/certificates"
PATH_CERT="$BASE_PATH/1.crt"
PATH_CERT_KEY="$BASE_PATH/1.key"
URL=https://localhost/v1/api/topic/favourites
#чтобы не писатать полный путь к утилите, например, /usr/bin/seq или /usr/bin/parallel или /usr/bin/curl
#экспортируем директиву в окружение
export MY_ENV="/usr/bin"
export PATH=$MY_ENV:$PATH
@thetekst
thetekst / myprojscript.sh
Last active March 21, 2019 13:43
Gradle clean build and mv jar to other dir
#!/bin/bash
# Важно. Нужно запускать source myprojscript.sh, а не . ./myprojscript.sh, чтобы сохранялся экспорт окружения
# Чтобы запускать этот скрипт было удобно, добавим alias в .bashrc: alias testbuild="cd $HOME/myproj && source myprojscript.sh"
# все манипуляции делаются ради замены пути в JAVA_HOME, чтобы избавиться от ERROR: JAVA_HOME is set to an invalid directory
# смотрим что лежит в JAVA_HOME. По умолчанию там .sdkman/candidates/java/current/jre
# этот путь не корректный. нужно заменить его на .sdkman/candidates/java/current/
# берем последние 3 символа jre и кладем их в переменную PREFIXX
PREFIXX="${JAVA_HOME: -3:3}"
@thetekst
thetekst / Constant.java
Last active March 7, 2019 16:04
Spring Boot 2. Server-Sent Events (SSE) by timeout
package ru.tkachenko.utils;
/**
* @author d.tkachenko
*/
public class Constant {
public static final String V1 = "v1/api";
}