Skip to content

Instantly share code, notes, and snippets.

Batuhan Bayrakci baybatu

View GitHub Profile
@baybatu
baybatu / liquibase-changelog.sh
Created Feb 4, 2019
Generate Liquibase changelog SQLs on CLI
View liquibase-changelog.sh
java -jar liquibase.jar \
--driver=org.postgresql.Driver \
--classpath=postgresql-9.4.1208.jre6.jar \
--changeLogFile=/workspace/product-api/src/main/resources/db/changelog.xml \
--url="jdbc:postgresql://localhost:5432/product" \
--username=root \
--password=123qwe \
updateSQL
@baybatu
baybatu / ReIndexJenkinsfile
Last active Feb 4, 2019
ReIndex Elasticsearch index from one to another on Jenkinsfile. Example transfer happens from `products_v1` to `products_v2` index
View ReIndexJenkinsfile
#!/usr/bin/env groovy
node {
stage('checkout') {
checkout scm
}
stage("Reindex") {
String esHost = params.esHost //example: localhost:9200
String oldIndexVersion = params.oldIndexVersion //example: v1
String newIndexVersion = params.newIndexVersion //example: v2
@baybatu
baybatu / SwitchAliasJenkinsfile
Last active Feb 4, 2019
Switch `products` Elasticsearch alias between index versions on Jenkinsfile. Switching happens from `products_v1` to `products_v2`
View SwitchAliasJenkinsfile
#!/usr/bin/env groovy
node {
stage('checkout') {
checkout scm
}
stage("Switch alias between index versions") {
String esHost = params.esHost //example: localhost:9200
String oldIndexVersion = params.oldIndexVersion //example: v1
String newIndexVersion = params.newIndexVersion //example: v2
@baybatu
baybatu / analytic-functions.md
Last active Feb 3, 2019
SQL'de ROW_NUMBER, RANK ve DENSE_RANK farklarını anlatan güzel bir örnek
@baybatu
baybatu / PaginationThroughHttpHeadersResponseAdvice.java
Last active Jan 22, 2019
Managing pagination through HTTP headers on Spring Boot. `PageResponseAdvice` intercepts responses in `PageResponse` type and puts pagination related fields into HTTP response headers.
View PaginationThroughHttpHeadersResponseAdvice.java
@ControllerAdvice
public class PageResponseAdvice implements ResponseBodyAdvice<Object> {
@Override
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
return PageResponse.class.isAssignableFrom(returnType.getParameterType());
}
@Override
public Object beforeBodyWrite(Object body,
@baybatu
baybatu / rabbitmq-delay-message-consume.md
Last active Jan 18, 2019
RabbitMQ: mesajı geciktirerek tüketmek
View rabbitmq-delay-message-consume.md

RabbitMQ: Mesajı Geciktirerek Tüketmek

  • delay-exchange: Geciktirilecek mesajın bırakıldığı exchange.
  • delay-queue: delay-exchange'e bağlı. Herhangi bir tüketicisi olmamalı.
  • ana-exchange: Geciktirilmeden tüketilmek istenen mesajların bırakılabileceği exchange.
  • ana-queue: ana-exchange'e bağlı kuyruk. Tüketicisi var.

delay-queue şu parametrelerle oluşturulur:

  • x-dead-letter-exchange: -- boş
  • x-message-ttl: 3000 -- mesajın bekletileceği milisaniye
@baybatu
baybatu / es-delete-indices-by-wildcard.sh
Created Dec 28, 2018
Delete indices by wildcard pattern in Elasticsearch #elasticsearch
View es-delete-indices-by-wildcard.sh
for index_name in `curl -XGET "$ES_HOST/products_*" | jq -r 'keys[]'`; do
curl -XDELETE "$ES_HOST/$index_name"
done
@baybatu
baybatu / ThreadPoolTaskExecutorWithMdcPropagation.java
Last active Dec 20, 2018
Propogate MDC context into newly created thread pool
View ThreadPoolTaskExecutorWithMdcPropagation.java
public class ThreadPoolTaskExecutorWithMdcPropagation extends ThreadPoolExecutor {
private static final Logger LOGGER = LoggerFactory.getLogger(ThreadPoolTaskExecutorWithMdcPropagation.class);
private final Map<String, String> parentMdcContextMap;
public ThreadPoolTaskExecutorWithMdcPropagation(int corePoolSize, int maxPoolSize, long keepAliveTime, TimeUnit keepAliveTimeUnit) {
super(corePoolSize, maxPoolSize, keepAliveTime, keepAliveTimeUnit, new LinkedBlockingQueue<>());
parentMdcContextMap = MDC.getCopyOfContextMap();
}
@baybatu
baybatu / json-format-using-vim-with-python.md
Last active Feb 8, 2019
JSON format in Vim using Python json.tool module
View json-format-using-vim-with-python.md
@baybatu
baybatu / datagrip-database-connections.md
Last active Nov 6, 2018
Import & Export database connection properties in DataGrip
View datagrip-database-connections.md

on macOS

default folder in /Users/USERNAME/Library/Preferences/DataGrip2018.1/projects contains database connection properties.

DataGrip2018.1 states your DataGrip version

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.