Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Batuhan Bayrakci baybatu

🏠
Working from home
View GitHub Profile
@baybatu
baybatu / delete-redis-keys-by-pattern.md
Last active Sep 17, 2021
Delete Redis keys by pattern
View delete-redis-keys-by-pattern.md
@baybatu
baybatu / delete-index-by-pattern-in-es.py
Created Jun 10, 2021
delete index by pattern in Elasticsearch with Python
View delete-index-by-pattern-in-es.py
# usage
# python delete-index-by-pattern-in-es.py http://ES_HOST:9200 my-es-index-*
# indexes matched with pattern you entered will be deleted
from elasticsearch import Elasticsearch
import sys
es_host = sys.argv[1]
index_pattern = sys.argv[2]
print(f"es_host:{es_host} ; index_pattern:{index_pattern}")
@baybatu
baybatu / create-rabbitmq-exchange-queue-using-rest-api.sh
Created Apr 2, 2019
Create RabbitMQ queue and exchange with binding using REST API
View create-rabbitmq-exchange-queue-using-rest-api.sh
# create exchange
curl -i -u guest:guest -H "content-type:application/json" \
-XPUT -d'{"type":"fanout","durable":true}' \
http://localhost:15672/api/exchanges/%2f/my.exchange.name
# create queue
curl -i -u guest:guest -H "content-type:application/json" \
-XPUT -d'{"durable":true,"arguments":{"x-dead-letter-exchange":"", "x-dead-letter-routing-key": "my.queue.dead-letter"}}' \
http://localhost:15672/api/queues/%2f/my.queue
@baybatu
baybatu / PaginationThroughHttpHeadersResponseAdvice.java
Last active Aug 5, 2021
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 / attach-listener-to-push-method.js
Last active Jul 19, 2021
Attach event listener to Array push method call
View attach-listener-to-push-method.js
var eventify = function(arr, callback) {
arr.push = function(e) {
Array.prototype.push.call(arr, e);
callback(arr);
};
};
var array = [1,2,3];
eventify(array, function(newArray) {
@baybatu
baybatu / use-git-profile-by-directory.md
Created Jun 30, 2021
Using git profiles by current directory
View use-git-profile-by-directory.md

~/.gitconfig:

[includeIf "gitdir:~/workspace/project1/**"]
    path = .gitconfig.project1
[includeIf "gitdir:~/workspace/project2/**"]
    path = .gitconfig.project2

~/.gitconfig.project1:

@baybatu
baybatu / yaml-cift-tirnak.md
Last active May 3, 2021
Iyi pratik ornegi olarak Yaml dosyalarinda cift tirnak kullanimi
View yaml-cift-tirnak.md

Yaml dosyalarda yes, on, true gibi degerlerin hepsi boolean true degerine eslestiriliyor. Bu da gozden kactiginda tespiti zor buglara neden oluyor.

Bu tarz sorunlardan bastan kacinmak icin string alanlari cift tirnak ile cevrelemek iyi bir pratik.

🚫 Kotu ornek:

watermark:
  - no
  - yes
@baybatu
baybatu / disable-vino-encryption.sh
Created Aug 13, 2018
Disable vino encryption on Ubuntu
View disable-vino-encryption.sh
gsettings set org.gnome.Vino require-encryption false
@baybatu
baybatu / use-local-pod-on-demo-project.md
Last active Apr 26, 2021
use local ios pod on a demo project
View use-local-pod-on-demo-project.md

harray-ios-sdk projesini local'deki demo bir ios projesinde kullanabilmek icin adimlar:

  • localde bi ios projesi olustur (orn: batuiostest)
  • Kullanacagin modulun (harray-ios-sdk) kaynak kodlarini bu projenin icine kopyala
  • Ana dizinde Podfile olustur (ruby kodu icerecek) ve sunu koy:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'batuiostest' do