Skip to content

Instantly share code, notes, and snippets.

View pgilad's full-sized avatar
🔭

Gilad Peleg pgilad

🔭
View GitHub Profile
@pgilad
pgilad / Instructions.md
Last active March 31, 2024 22:30
Git commit-msg hook to validate for jira issue or the word merge

Instructions

  • copy the file commit-msg to .git/hooks/commit-msg
  • make sure your delete the sample file .git/hooks/commit-msg.sample
  • Make commit msg executable. chmod +x .git/hooks/commit-msg
  • Edit commit-msg to better fit your development branch, commit regex and error message
  • Profit $$

Shell example

@pgilad
pgilad / Instructions.md
Last active March 27, 2024 12:59
Generate SSL Certificate for use with Webpack Dev Server (OSX)

Generate private key

$ openssl genrsa -out private.key 4096

Generate a Certificate Signing Request

openssl req -new -sha256 \
@pgilad
pgilad / Dockerfile
Last active March 18, 2024 04:37
Minimal Spring Boot 2 on Docker Alpine with Java 11 (Using Jigsaw modules)
FROM alpine:3.8 AS builder
WORKDIR /opt
ARG JDK_TAR=openjdk-11+28_linux-x64-musl_bin.tar.gz
ARG JDK_DOWNLOAD_PREFIX=https://download.java.net/java/early_access/alpine/28/binaries
RUN wget -q "$JDK_DOWNLOAD_PREFIX/$JDK_TAR" && \
wget -q "$JDK_DOWNLOAD_PREFIX/$JDK_TAR.sha256"
RUN cat $JDK_TAR.sha256 | xargs -I{} echo "{} $JDK_TAR" | sha256sum -c - && \
@pgilad
pgilad / json-to-toml.py
Created May 16, 2016 12:56
Convert a json file to toml
#!/usr/bin/env python2
# don't forget to `pip install toml`
import json
import sys
import toml
if len(sys.argv) < 3: raise Exception('Usage is `json_to_toml.py input.json output.toml`')
json_file = sys.argv[1]
@pgilad
pgilad / apachetop.sh
Created February 10, 2016 13:01
Run apachetop on multiple files from find
# Run apachetop on multiple files as a result of find
sudo apachetop $(find /var/log/blazemeter/ -name "*access.log" -print | sed 's/^/-f '/)
@pgilad
pgilad / percentiles.R
Created April 2, 2017 06:19
Percentiles plot using R
library("ggplot2")
sample.jtl <- read.csv("~/repos/work/csv-percentiles/sample.csv")
sample.jtl$ts <- as.POSIXct(sample.jtl$ts / 1000, origin="1970-01-01")
interval_size <- '5 sec'
wanted_percentiles <- c(0.5, 0.9, 0.95, 0.99)
get_quantiles <- function(items) {
yy <- quantile(items, wanted_percentiles)
@pgilad
pgilad / docker-volume-prune.sh
Created May 4, 2020 19:03
Docker volume prune with until workaround (filter for --until isn't supported)
#!/usr/bin/env bash
set -euo pipefail
volumes=$(docker volume ls --filter dangling=true --quiet)
if [[ -z "$volumes" ]]; then
echo "No dangling volumes found"
exit 0
fi
@pgilad
pgilad / ExampleWebFilter.java
Last active June 17, 2021 08:02
Try to use WebFilter in Spring Boot Webflux in order to log request body
package com.blazemeter.dagger.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
@pgilad
pgilad / DemoController.java
Last active December 17, 2020 08:29
Supporting files for my blog post on remote jmx Spring Boot debugging
package com.example.demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@RestController
public class DemoController {
@GetMapping("/ping")
@pgilad
pgilad / AggregateControllerTest.java
Created February 17, 2019 19:12
An example on how to use WebFluxTest to test a Spring Boot WebFlux Controller
package com.blazemeter.dagger.domains.aggregate;
import com.blazemeter.dagger.domains.aggregate.port.AggregateRepository;
import com.blazemeter.dagger.domains.common.CollectionService;
import org.apache.commons.lang3.RandomUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;