Skip to content

Instantly share code, notes, and snippets.

View misTrasteos's full-sized avatar

Álvar Torres misTrasteos

  • Madrid, Spain
View GitHub Profile
@misTrasteos
misTrasteos / Kubernetes hostPath volumes in Kind.md
Last active January 24, 2021 16:20
Kubernetes hostPath volumes in Kind

create the cluster

We need to provide some extra options when creating the kind cluster.

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraMounts:
 - hostPath: /kubernetes/volumes
@misTrasteos
misTrasteos / README.md
Last active February 2, 2021 21:41
generate a Docker image from a python script

Files

requirements.txt

prometheus-client==0.9.0

client.py

from prometheus_client import start_http_server, Counter
import time
@misTrasteos
misTrasteos / generateMinutesFromLastWeek.py
Created February 10, 2021 21:47
Generate a week of minutes for fake log purposes
import datetime
now = datetime.datetime.now().replace(second=0, microsecond=0)
# I use replace method to round to second and microsecond, as datetime is inmutable
minutesInAWeek = 7 * 24 * 60 # 7 days in a week, 24 hours a day, 60 minutes an hour
for i in reversed(range(minutesInAWeek)):
minuteInThePast = now - datetime.timedelta(minutes = i)
@misTrasteos
misTrasteos / generateRandomWalk.py
Last active February 11, 2021 22:33
generate a random walk time series
import matplotlib.pyplot as plt
import numpy as np
numberOfDays = 7
minutesPerDay = 24 * 60
def addNoise(array, noise=5):
# some random noise
return array + np.random.rand( len(array) ) * noise
@misTrasteos
misTrasteos / README.md
Created February 12, 2021 18:29
Download all maven dependencies into a folder using maven docker image

how to run

run this container from the root of your maven project.

docker run -it --rm -v "$(pwd)/dependencies":/root/.m2 -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven mvn dependency:go-offline

All dependencies will be downloaded in this directory

@misTrasteos
misTrasteos / Dockefile
Last active February 18, 2021 21:22
Trying to build my own github actions agent
# DISCLAIMER, this is not the best way to build a Docker Image. It is still WIP, so I find this way easier to modify.
FROM ubuntu:20.04
ARG JAVA_VERSION=adoptopenjdk-8-hotspot
ARG MAVEN_VERSION=3.6.3
# general stuff
RUN apt-get update
RUN apt-get install wget -y
RUN apt-get install apt-transport-https -y
@misTrasteos
misTrasteos / README.md
Last active November 22, 2021 12:23
Promethus & Grafana on Kubernetes
@misTrasteos
misTrasteos / QuarkusRest.java
Created November 22, 2021 14:00
Quarkus Rest Micrometer Jbang minimal example
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-resteasy:2.4.1.Final
//DEPS io.quarkus:quarkus-micrometer-registry-prometheus:2.4.1.Final
//JAVAC_OPTIONS -parameters
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
import io.quarkus.runtime.Quarkus;
import javax.enterprise.context.ApplicationScoped;
@misTrasteos
misTrasteos / k6.js
Created November 22, 2021 15:19
K6 basic example
import http from 'k6/http';
import { randomString } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
export const options = {
stages: [
{ duration: '30s', target: 500 },
{ duration: '2m', target: 1000 },
{ duration: '30s', target: 0 }
]
@misTrasteos
misTrasteos / WeakHashMapPoc.java
Last active December 8, 2021 00:12
WeakHashMap JVM Java Example
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA_OPTIONS -Xms32m -Xmx32m -Xlog:gc* -XX:+UseSerialGC
/// -XX:+HeapDumpBeforeFullGC
/// jbang run -D=WEAK WeakHashMapPoc.java for infinite execution as weak references are collected before an OOO
/// jbang run -D=STRONG -D=WEAK WeakHashMapPoc.java OOO even using a WeakHashMap, as keys are strongly referenced
/// jbang run WeakHashMapPoc.java for an OOO as simple Map keys are strongly referenced