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 / script.js
Created Dec 2, 2018
Minimal compiler for typescript files
View script.js
const ts = require('typescript');
const tsConfig = require('./tsconfig.json');
const config = tsConfig.compilerOptions;
function compile(fileNames, options) {
if (fileNames.filter(Boolean).length === 0) {
console.log('No files');
return;
}
@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 / Constants.java
Last active Dec 26, 2018
An example of a pre-set scheduler for paralleling reactive work
View Constants.java
public static final Scheduler scheduler = Schedulers.fromExecutorService(new ThreadPoolExecutor(4, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()))
@pgilad
pgilad / test.php
Created Oct 24, 2018
Php instance property mutation
View test.php
<?php
class State {
public $foo = 0;
}
class Mutator {
public function mutateState(State $state) {
$state->foo = 4;
}
@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 - && \
View percentiles.java
@GetMapping("/percentiles-distribution")
public Flux<PercentilesDistribution> getAggregatePercentiles(
@RequestParam @Positive long masterId,
@RequestParam(defaultValue = "0") @Min(-1) long from,
@RequestParam(defaultValue = "0") @Min(-1) long to,
@RequestParam(defaultValue = "ALL") @Size(max = Constants.MAX_LOCATIONS) ArrayList<String> locationId,
@RequestParam(defaultValue = "") @Size(max = Constants.MAX_SCENARIOS) ArrayList<String> scenarioId,
@RequestParam(defaultValue = "") ArrayList<String> labelIds
) {
final int interval = 60;
@pgilad
pgilad / main.go
Created Aug 8, 2018
Generate stable random name from string (used to generate docker tag from git branch)
View main.go
package main
import (
"fmt"
"hash/fnv"
"math/rand"
"os"
"github.com/docker/docker/pkg/namesgenerator"
)
@pgilad
pgilad / build.gradle
Created Jun 20, 2018
Modern build.gradle
View build.gradle
buildscript {
ext {
springBootVersion = '2.0.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
@pgilad
pgilad / Builder.js
Created Mar 20, 2018
A builder for requests
View Builder.js
export class Request {
ajax = $.ajax;
baseURL = API_BASE_URL;
contentType = 'application/json';
data = null;
dataType = 'json';
global = true;
method = 'GET';
params = null;
paramsSerializer = defaultParamsSerializer;
@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 \
You can’t perform that action at this time.