Skip to content

Instantly share code, notes, and snippets.


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 /
Last active Mar 6, 2019
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;
public class DemoController {
pgilad /
Created Feb 17, 2019
An example on how to use WebFluxTest to test a Spring Boot WebFlux Controller
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 /
Created Feb 9, 2019
Get most popular commit message and strip JIRA prefix tag
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 /
Created Jan 8, 2019
Example of Hot/Cold producer when you toggle refCount/autoConnect
public static void main(String[] args) throws InterruptedException {
final Flux<Long> longFlux = Flux.interval(Duration.ofSeconds(1))
.doOnSubscribe(e ->"SUBSCRIBE"))
.doOnTerminate(() ->"TERMINATE"))
.doOnComplete(() ->"COMPLETE"))
.doOnCancel(() ->"CANCEL"))
.doOnNext(s ->"NEXT {}", s))
.refCount(2, Duration.ofSeconds(1));
pgilad / Dockerfile
Last active Jan 2, 2019
Dockerfile to create a zip for AWS Lambda code based on Python 2.7 and Pipenv
View Dockerfile
FROM amazonlinux:latest
RUN yum -y update && yum install -y gcc python-devel zip which
RUN curl | python -
RUN pip install pipenv
pgilad /
Last active Jan 24, 2019
Example of how to patch a deployment image on Kubernetes using Java client
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 /
Last active Dec 26, 2018
DataSender using Netty Reactive Client
package data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.ByteBufFlux;
import reactor.netty.http.client.HttpClient;
import reactor.retry.Retry;
import settings.Settings;
pgilad / build.gradle
Last active Dec 26, 2018
How to create reproducible builds in spring using buildInfo
View build.gradle
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
springBoot {
mainClassName = 'com.blazemeter.dagger.DaggerApplication'
buildInfo {
properties {
time = null
pgilad / account.ts
Last active Dec 26, 2018
An example of a model wrapping read only state using Typescript
View account.ts
import _ from 'lodash';
import produce from 'immer';
import { IAccount } from '../../types/account';
import { IData, IModifiable, ProduceRecipe } from '../metadata';
* An account model
export class Account implements IModifiable<IAccount>, IData<IAccount> {
readonly data: Readonly<IAccount>;
You can’t perform that action at this time.