Skip to content

Instantly share code, notes, and snippets.

🎯
Excited

Gilad Peleg pgilad

Block or report user

Report or block pgilad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pgilad
pgilad / Instructions.md
Last active May 22, 2019
Generate SSL Certificate for use with Webpack Dev Server (OSX)
View Instructions.md

Generate private key

$ openssl genrsa -out private.key 4096

Generate a Certificate Signing Request

openssl req -new -sha256 \
@pgilad
pgilad / Instructions.md
Last active May 20, 2019
Git commit-msg hook to validate for jira issue or the word merge
View Instructions.md

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 / Dockerfile
Last active May 16, 2019
Minimal Spring Boot 2 on Docker Alpine with Java 11 (Using Jigsaw modules)
View Dockerfile
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 / ExampleWebFilter.java
Last active Apr 29, 2019
Try to use WebFilter in Spring Boot Webflux in order to log request body
View ExampleWebFilter.java
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 / popular-git-message.sh
Created Feb 9, 2019
Get most popular commit message and strip JIRA prefix tag
View popular-git-message.sh
@pgilad
pgilad / DemoController.java
Last active Mar 6, 2019
Supporting files for my blog post on remote jmx Spring Boot debugging
View DemoController.java
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 Feb 17, 2019
An example on how to use WebFluxTest to test a Spring Boot WebFlux Controller
View AggregateControllerTest.java
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;
@pgilad
pgilad / build.gradle.kts
Last active Jan 28, 2019
Create a revision for file
View build.gradle.kts
fun digest(file: File, algorithm: String): String {
val contents = file.readBytes()
val messageDigest = MessageDigest.getInstance(algorithm)
val digestBytes = messageDigest.digest(contents)
return String.format("%032x", BigInteger(1, digestBytes)).substring(0..9)
}
project(":jetpack").configure {
apply(plugin = "com.github.johnrengelman.shadow")
@pgilad
pgilad / Deployment.java
Last active Jan 24, 2019
Example of how to patch a deployment image on Kubernetes using Java client
View Deployment.java
package com.blazemeter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.apis.AppsV1beta1Api;
import io.kubernetes.client.models.AppsV1beta1Deployment;
@pgilad
pgilad / DataProcessor.java
Created Jan 8, 2019
Example of Hot/Cold producer when you toggle refCount/autoConnect
View DataProcessor.java
public static void main(String[] args) throws InterruptedException {
final Flux<Long> longFlux = Flux.interval(Duration.ofSeconds(1))
.doOnSubscribe(e -> log.info("SUBSCRIBE"))
.doOnTerminate(() -> log.info("TERMINATE"))
.doOnComplete(() -> log.info("COMPLETE"))
.doOnCancel(() -> log.info("CANCEL"))
.doOnNext(s -> log.info("NEXT {}", s))
.replay()
.refCount(2, Duration.ofSeconds(1));
You can’t perform that action at this time.