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
@ufuk
ufuk / jcmd.sh
Created December 6, 2022 14:12
Display a Java process' system properties or flags (https://docs.oracle.com/en/java/javase/17/docs/specs/man/jcmd.html)
# list Java processes
jcmd -l
# list running JVM's system properties or flags (select a 'pid' from above command's result list)
jcmd pid VM.system_properties
jcmd pid VM.flags
kubectl rollout restart deployment name-of-my-deployment
@ufuk
ufuk / force-to-delete-pod.sh
Created April 22, 2022 12:55
How to force k8s to delete a pod via kubectl?
kubectl delete pods your-pod-name --grace-period=0 --force -n your-namespace-name
@ufuk
ufuk / logback-spring.xml
Last active January 5, 2021 09:50
Spring Boot & AWS Elastic Beanstalk & AWS Cloudwatch Log Stream friendly logging with newline replacing support to convert root cause's stack trace into single line message. And does these within Spring Boot's default pattern layout.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<appender name="CLOUD_WATCH_FRIENDLY" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m %replace(%rEx{short}){'[\r\n\t]+', '\\n'}%nopex%n</pattern>
</encoder>
@ufuk
ufuk / ExampleConstraint.java
Last active March 20, 2024 13:47
How to initialize an instance of the constraint annotation while writing unit tests for a javax.validation.ConstraintValidator
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
@Documented
@Constraint(validatedBy = ExampleConstraintValidator.class)
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ExampleConstraint {
@keburak
keburak / netscaler-pentest-add-header-sample.txt
Created September 17, 2020 13:59
netscaler Strict-Transport-Security , X-Frame-Options , X-Xss-Protection , CORS policy
------------------------------------------------------------------------------------------------------
#add x-frame-options header
add rewrite action act_insert_XFrame_header insert_http_header X-Frame-Options "\"SAMEORIGIN\""
add rewrite policy pol_enforce_XFrame TRUE act_insert_XFrame_header
------------------------------------------------------------------------------------------------------
#add HSTS header
add rewrite action act_insert_HSTS_header insert_http_header Strict-Transport-Security "\"max-age=157680000; includeSubDomains; preload\""
add rewrite policy pol_enforce_HSTS TRUE act_insert_HSTS_header
------------------------------------------------------------------------------------------------------
#add x-xss-protection header
@JonasGroeger
JonasGroeger / SpringCronExpressionTester.java
Last active October 20, 2022 21:03
Spring Cron Expression Tester (Junit 5)
package de.jonasgroeger;
import org.junit.jupiter.api.Test;
import org.springframework.scheduling.support.CronExpression;
import java.time.LocalDateTime;
import java.time.ZoneId;
class SpringCronExpressionTester {
@ufuk
ufuk / import-csv-file-from-s3-into-aws-redshift.sql
Created January 31, 2019 14:01
Import CSV file from S3 into AWS Redshift
-- Before importing, you need to create table
CREATE TABLE example_table
(
...
);
-- Importing...
COPY example_table
FROM 's3://<BUCKET_NAME>/.../example_table.csv'
CREDENTIALS 'aws_access_key_id=...;aws_secret_access_key=...'
@ufuk
ufuk / bash-echo-time-by-timezone.sh
Created January 31, 2019 13:55
Echo time by timezone in BASH
echo "$(TZ='Europe/Moscow' date +%Y-%m-%d\ %H\:%M)"
# output => 2019-01-31 16:52
@dettmering
dettmering / ping.1m.py
Created January 30, 2019 08:12
BitBar plugin for showing host availability
#!/usr/local/bin/python3
import os
hosts = [
'google.com',
'microsoft.com'
]
header = []