Skip to content

Instantly share code, notes, and snippets.

@polster
polster / makefile
Created January 3, 2022 22:17
Kafka topics creation per make
#!make
KAFKA_BOOTSTRAP_SERVER=localhost:9092
KAFKA_TOPICS_FILE=./config/kafka/topics.txt
kafka-topics-create:
awk -F':' '{ system("kafka-topics.sh --create --bootstrap-server ${KAFKA_BOOTSTRAP_SERVER} --topic="$$1" --partitions="$$2" --replication-factor="$$3" --config="$$4) }' \
${KAFKA_TOPICS_FILE}
.PHONY: kafka-topics-create
@polster
polster / BiConsumerConfig.java
Last active January 3, 2022 21:59
Spring Cloud Stream: BiConsumer
@Bean
public BiConsumer<KTable<String, PersonChangedEvent>, KTable<String, AddressChangedEvent>> processPersonEvents(
ProjectorService projectorService,
MappingContext mappingContext) {
return (personChangedEvents, addressChangedEvents) -> {
personChangedEvents
.mapValues(personChangedEvent -> PersonAggregateRoot.empty().apply(personChangedEvent, mappingContext))
.join(addressChangedEvents, ((root, addressChangedEvent) -> root.apply(addressChangedEvent, mappingContext)))
@polster
polster / install_theme.md
Last active February 11, 2020 21:27
oh-my-zsh Theme
  • Create the following file:
    vi ~/.oh-my-zsh/custom/themes/devtheme.zsh-theme
  • Add the following content and save
    local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
    PROMPT='${ret_status} %{$fg_bold[magenta]%}%n%{$reset_color%}%{$FG[146]%}@%{$reset_color%}%{$fg_bold[blue]%}%m%{$reset_color%}  %{$fg_bold[cyan]%}%~%{$reset_color%} $(git_prompt_info)'
    

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"

@polster
polster / run-postman.sh
Created November 29, 2019 11:41
Postman collection execution script for ci-pipelines
#!/bin/bash
set -o pipefail
# #############################################################################
#
# Helper script used to execute Postman collections.
#
# #############################################################################
function usage(){
@polster
polster / wait_till_pod_ready.sh
Last active November 29, 2019 11:42
Kubernetes pod deployment status polling script for ci-pipelines
#!/bin/bash
# #############################################################################
#
# Helper script used to poll one or more pods for their running status.
#
# #############################################################################
DEFAULT_POLL_MAX_COUNT=20
DEFAULT_POLL_SLEEP_IN_SECONDS=5
@polster
polster / kaniko_build.sh
Created November 25, 2019 12:58
Build and push docker image with Kaniko, assuming local Dockerfile within the workspace
docker run \
-v $(pwd):/workspace:ro \
-v ~/.kaniko/config.json:/kaniko/.docker/config.json:ro \
-v ~/.kaniko/credentials:/root/.aws/credentials:ro \
gcr.io/kaniko-project/executor:latest \
--context=/workspace \
--destination=ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/NAME_SPACE/IMAGE_NAME:latest --force
@polster
polster / gitlab-ci.yml
Created November 18, 2019 07:43
gitlab-ci template script
image: alpine:3.7
.script-snip-one: &script-snip-one |
echo "Running snippet one"
ls -la
.script-snip-two: &script-snip-two |
echo "Running snippet two"
ls -la
@polster
polster / AuthToken.java
Last active March 7, 2021 07:54
Spring Boot Retry Policy Example
package com.myexamples.oauth;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import static java.util.Objects.requireNonNull;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AuthToken {
@polster
polster / gitlab_sync.sh
Created November 27, 2017 05:21
Gitlab project sync script
#!/bin/bash -x
GITLAB_USER_ID="yourUserId"
GITLAB_PRIVATE_TOKEN="yourPrivateToken"
GITLAB_API_BASE="https://gitlab.com/api/v3"
GITLAB_LOCAL_DIR_BASE="${HOME}/Dev/Git"
repo_urls=$(curl -s "${GITLAB_API_BASE}/users/${GITLAB_USER_ID}/projects?private_token=${GITLAB_PRIVATE_TOKEN}&per_page=999" \
| jq -r '.[] | .ssh_url_to_repo')
@polster
polster / ubuntu-kernel-cleanup.sh
Created August 7, 2017 06:42
Ubuntu: Cleanup old kernel headers and images
sudo apt-get purge $(for tag in "linux-image" "linux-headers"; do dpkg-query -W -f'${Package}\n' "$tag-[0-9]*.[0-9]*.[0-9]*" | sort -V | awk 'index($0,c){exit} //' c=$(uname -r | cut -d- -f1,2); done)