Skip to content

Instantly share code, notes, and snippets.

View baybatu's full-sized avatar
🏠
Working from home

Batuhan Bayrakci baybatu

🏠
Working from home
View GitHub Profile
@baybatu
baybatu / docker-overwrite-entrypoint.md
Last active January 12, 2026 09:29
Run command in a docker container without running entrypoint
@baybatu
baybatu / kubectl-exec-pipe-commands.md
Last active July 30, 2025 21:20
Piping bash commands in kubectl exec

Bash commands connected using pipe(|) are not executed correctly in kubectl exec.

Example:

kubectl exec -ti <POD> -- pg_dump -h localhost -t my_table | psql -d <TARGET_DB> -h localhost

Here I want to run the pg_dump command first and redirect the output to the psql command as input using pipe(|). But kubectl takes commands only until pipe character, pg_dump in my case and psql has been run on host machine instead of inside the <POD>. The solution is to wrap all commands using double quote(") and run these commands using bash -c.

@baybatu
baybatu / favorite-keygen-music-playlist.md
Last active December 4, 2024 17:51
my favorite keygen music playlist
@baybatu
baybatu / create-rabbitmq-exchange-queue-using-rest-api.sh
Created April 2, 2019 06:35
Create RabbitMQ queue and exchange with binding using REST API
# 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 / tcpdump-osx.sh
Created February 17, 2020 06:29
Getting network traffic of an application by PID on OSX
sudo tcpdump -Q pid=PID -k
@baybatu
baybatu / limit-number.py
Created June 26, 2016 06:27
Limiting input number between minimum and maximum values range in Python
def limit(num, minimum=1, maximum=255):
"""Limits input 'num' between minimum and maximum values.
Default minimum value is 1 and maximum value is 255."""
return max(min(num, maximum), minimum)
@baybatu
baybatu / list-used-nodeports-on-kubernetes.sh
Created April 12, 2023 15:03
List all used node ports on kubernetes cluster. kudos @hasansama
kubectl get svc --all-namespaces -o go-template="{{range .items}}{{range.spec.ports}}{{if .nodePort}}{{.nodePort}}{{printf \"\n\"}}{{end}}{{end}}{{end}}" | sort
@baybatu
baybatu / CompleteableFutureWithExceptionHandling.java
Last active January 11, 2023 06:01 — forked from kencharos/Comp.java
CompletableFuture sample (with simple error handling)
package com.example;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CompleteableFutureWithExceptionHandling {
public static void main(String[] args) {
@baybatu
baybatu / datagrip-database-connections.md
Last active December 2, 2022 17:55
Import & Export database connection properties in DataGrip

on macOS

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

DataGrip2018.1 states your DataGrip version

@baybatu
baybatu / fix-no-class-def-found-error.md
Last active November 3, 2022 11:54
Resolving java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache error in a spring-boot application

The following stacktrace can occur on a spring-boot app. Consider changing the scope of dependencies that use groovy runtime as test.

{"@timestamp":"2022-11-03T12:32:33.865+03:00","@version":"1","message":"Application run failed","logger_name":"org.springframework.boot.SpringApplication","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
    at org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod.<clinit>(NumberNumberMetaMethod.java:33)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)