AWS Snippets

Install AWS CLI v2 $ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.0.30.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install AWS Documentation Generate Signed URLs with Linux Tools e.g. for accessing a website behind a CloudFront distribution using a canned policy. Write the policy file policy { "Statement": [ { "Resource": "https://xxxxxxxxxxxx.cloudfront.net/", "Condition": { "DateLessThan": { "AWS:EpochTime": 1648293147 } } } ] } Then apply the following commands[1] - you need to have OpenSSL installed. cat policy | tr -d "\n" | (1) tr -d " \t\n\r" | (2) openssl sha1 -sign private_key.pem | (3) openssl base64 -A | (4) tr -- '+=/' '-_~' (5) ...

March 1, 2018 · 2 min · 371 words · Micha Kops

How to build a quick Lucene Search

Helo – today I wanted to post a small tutorial for a small index and search operation using the Lucene indexer and Maven for the project setup. Setup Create an empty Maven sample project using the Eclipse Maven Plugin or use the following console command: mvn archetype:create -DgroupId=com.hascode.demo.search -DartifactId=lucene-sample Here is my pom.xml there are some dependencies for Lucene defined: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.demo.search</groupId> <artifactId>lucene-sample</artifactId> <version>0.0.1-SNAPSHOT</version> <name>My Lucene Search Sample</name> <description>Lucene Search Sample</description> <dependencies> <dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>lucene</groupId> <artifactId>lucene</artifactId> <version>1.4.3</version> </dependency> </dependencies> </project> ...

March 25, 2010 · 3 min · 540 words · Micha Kops

AMQP and RabbitMQ Snippets

rabbitmqctl Create admin user with full host permissions # create new user named 'theadmin' rabbitmqctl add_user theadmin thepassword # make 'theadmin' admin rabbitmqctl set_user_tags theadmin administrator # give 'theadmin' permissions for all hosts rabbitmqctl set_permissions -p / theadmin ".*" ".*" ".*" AMQP Exchange Types 1. Fanout Exchange Description: A fanout exchange routes messages to all of the queues that are bound to it. It doesn’t take the routing key into consideration. Instead, it simply broadcasts the message to all bound queues. ...

March 1, 2010 · 3 min · 439 words · Micha Kops

GitLab Snippets

Generate AsciiDoc Documentation and Publish it with GitLab Pages We setup a repository and add a directory named docs there .. this is the home of our AsciiDoc files. We’re using asciidoctor/docker-asciidoctor as Docker image for tool provisioning This is the .gitlab-ci.yml, we’re running the stage only when something in the docs directory has changed. stages: - "Build docs" # The name of the job activates the GitLab pages publication pages: image: asciidoctor/docker-asciidoctor stage: "Build docs" tags: - build script: - sh ./gen_docs.sh - mv output public only: refs: - master changes: - /docs/* artifacts: paths: - public expose_as: 'Documentation Archive' ...

March 1, 2010 · 1 min · 186 words · Micha Kops

Helm Snippets

Common operations Add Helm Repository helm repo add NAME URL e.g. for the Bitnami repository: helm repo add bitnami https://charts.bitnami.com/bitnami 1 ↵ "bitnami" has been added to your repositories List Repositories helm repo list 130 ↵ NAME URL bitnami https://charts.bitnami.com/bitnami Searching in a Helm Repository helm search repo wordpress NAME CHART VERSION APP VERSION DESCRIPTION bitnami/wordpress 15.2.30 6.1.1 WordPress is the world's most popular blogging ... bitnami/wordpress-intel 2.1.31 6.1.1 DEPRECATED WordPress for Intel is the most popu... ...

March 1, 2010 · 4 min · 697 words · Micha Kops

IntelliJ Snippets

Live Templates JUnit 5 Test @org.junit.jupiter.api.Test @org.junit.jupiter.api.DisplayName("$NAME$") void $METHOD$() throws Exception { $END$ } Figure 1. IntelliJ Live Template Editor Edit Variables: NAME METHOD: default-value camelCase(NAME) Figure 2. Editing template variables SLF4J Logger Template private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger( $CLASS$.class ); Edit variables: CLASS: expression: className() Favorite Shortcuts Select whole block in Editor Cmd+Tab+Down Select similar blocks in editor Ctrl+G Copy the absolute Path of the current File into Clipboard Cmd+Shift+C ...

March 1, 2010 · 2 min · 341 words · Micha Kops

Java Snippets

Remote Debug a Pod’s Java Process Simple steps for remote debugging a Java process running on a k8 pod: Edit deployment and add the following parameters to the Java start line: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005 Also add the following port mapping at the section container → ports in the deployment: - containerPort: 5005 protocol: TCP Safe, wait for the new pods and then add a port forward for port 5005 for this pod: kubectl port-forward podname 5005 ...

March 1, 2010 · 13 min · 2583 words · Micha Kops

Kafka Snippets

Start an Image with kcat / kafka-cat for Debugging kubectl -n NAMESPACE run "$(whoami)-debug" -it --rm \ --image=confluentinc/cp-kafkacat:6.1.9 \ --restart=Never \ -- bash Dockerfile for Kafka Analysis Container with different Tools With jq, kafka console tools, schema registry tools and kafkacat installed …​. Dockerfile FROM confluentinc/cp-kafka:6.2.1 as cp-kafka FROM confluentinc/cp-schema-registry:6.2.1 as cp-schema-registry FROM debian:10-slim ARG DEBIAN_FRONTEND=noninteractive # Install necessary tools RUN apt-get update && apt-get install -y \ curl \ jq \ yq \ && rm -rf /var/lib/apt/lists/* # Install kafkacat binary RUN apt-get update && apt-get install -y kafkacat && rm -rf /var/lib/apt/lists/* # Copy Kafka binaries COPY --from=cp-kafka /usr/bin/kafka-* /usr/bin/ COPY --from=cp-schema-registry /usr/bin/schema-registry* /usr/bin/ # Copy entrypoint script COPY entrypoint.sh /usr/bin/entrypoint.sh RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT ["/usr/bin/entrypoint.sh"] ...

March 1, 2010 · 7 min · 1333 words · Micha Kops

Linux Snippets

These are not only linux snippets but also bash snippets and snippets using tools that run under Linux, *nix or sometimes even MacOSX, I should reorder this article someday ;) Settings for more reliable bash scripts set -euo pipefail this gives us …​ -e: exit script if a single command fails -u: exit script if an unset variable is used -o pipefail: return value of a pipeline is the status of the last command to exit with a non-zero status, or zero if no command exited with a non-zero status ...

March 1, 2010 · 15 min · 3006 words · Micha Kops

Maven Snippets

Extract Coordinates from the POM Helpful for build and integration environments, pipelines etc. Exctract the Project version from the pom.xml mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout Override a Property via local configuration e.g. to override the property xxx from your project’s pom.xml Create a directory .mvn in your project directory root Create a file named maven.config in this directory Insert -Dxxx=newvalue into the file to override this property Don’t forget to add .mvn to your .gitignore! ...

March 1, 2010 · 2 min · 401 words · Micha Kops