Skip to content

Instantly share code, notes, and snippets.

View pgilad's full-sized avatar
🔭

Gilad Peleg pgilad

🔭
View GitHub Profile
@pgilad
pgilad / kube-resources.sh
Created June 6, 2019 07:22
Get ALL resources in k8s namespace
#!/bin/bash
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found
@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 / popular-git-message.sh
Created February 9, 2019 18:30
Get most popular commit message and strip JIRA prefix tag
@pgilad
pgilad / DataProcessor.java
Created January 8, 2019 15:05
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 -> 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));
@pgilad
pgilad / Dockerfile
Last active January 2, 2019 16:13
Dockerfile to create a zip for AWS Lambda code based on Python 2.7 and Pipenv
FROM amazonlinux:latest
RUN yum -y update && yum install -y gcc python-devel zip which
RUN curl https://bootstrap.pypa.io/get-pip.py | python -
RUN pip install pipenv
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV SOURCE_DIR lambdas
@pgilad
pgilad / Deployment.java
Last active July 30, 2020 21:44
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
pgilad / DataSender.java
Last active December 26, 2018 07:33
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
pgilad / build.gradle
Last active December 26, 2018 07:33
How to create reproducible builds in spring using buildInfo
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
springBoot {
mainClassName = 'com.blazemeter.dagger.DaggerApplication'
buildInfo {
properties {
time = null
@pgilad
pgilad / account.ts
Last active December 26, 2018 07:34
An example of a model wrapping read only state using Typescript
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>;
@pgilad
pgilad / script.js
Created December 2, 2018 13:19
Minimal compiler for typescript files
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;
}