Skip to content

Instantly share code, notes, and snippets.

View abelaska's full-sized avatar
👍

Alois Bělaška abelaska

👍
View GitHub Profile
@abelaska
abelaska / ukol.java
Last active January 3, 2023 15:41 — forked from aukrocz/ukol.java
import lombok.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
class Main {
static AtomicLong billIdCounter = new AtomicLong();
@abelaska
abelaska / gist:8d068e86a83f5fc099fe042f59964e46
Last active December 15, 2021 21:31
Delete all the old workflows that aren't on the `main` branch
user=sli-do repo=slido-global-api; gh api repos/$user/$repo/actions/runs \
--paginate -q '.workflow_runs[] | select(.head_branch != "main") | "\(.id)"' | \
xargs -n1 -I % gh api --silent repos/$user/$repo/actions/runs/% -X DELETE
https://stackoverflow.com/a/64473987
Prerequisites:
You will find the latest gh version here.
@abelaska
abelaska / snyk.yaml
Created December 15, 2021 07:15
Github Workflow - Snyk Security Check
# .github/workflows/snyk.yaml
name: Snyk Security Check
on:
push:
schedule:
# At 03:00 on every day-of-week from Sunday through Friday. https://crontab.guru/#0_3_*_*_0-5
- cron: '0 3 * * 0-5'
import { FastifyPluginAsync } from 'fastify';
import fp from 'fastify-plugin';
// https://www.fastify.io/docs/latest/TypeScript/#creating-a-typescript-fastify-plugin
const securityHeadersPlugin: FastifyPluginAsync = async (fastify) => {
fastify.addHook('onRequest', async (_req, res) => {
res.header('Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload');
res.header('X-Content-Type-Options', 'nosniff');
});
async function* walkDirs(dir, opts) {
const files = [];
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) {
const exclude = opts?.excludes?.find((exc) =>
exc.startsWith('/') ? entry.startsWith(exc) : entry.endsWith(exc)
);
if (!exclude) {
yield* await walkDirs(entry, opts);
@abelaska
abelaska / cleanup-firebase-realtime-database.sh
Created December 25, 2020 14:07
Cleanup Firebase real-time database
#!/bin/bash
#
remove() {
firebase --non-interactive -P fpm-prod database:remove -y "$1"
if [ "$?" != "0" ]; then
firebase --non-interactive -P fpm-prod database:get --shallow "$1" | jq 'keys[]' -r | while read l; do
remove "$1/$l"
done
fi
@abelaska
abelaska / pom.xml
Last active October 21, 2021 14:18
Adoptopenjdk 11 openj9
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<from>
<image>adoptopenjdk/openjdk11-openj9:alpine-slim</image>
</from>
<extraDirectories>
@abelaska
abelaska / merge-kubeconfig.sh
Created June 19, 2020 12:20
Merge kubeconfig
# ~/.bashrc
# https://github.com/kubernetes/kubernetes/issues/46381#issuecomment-461404505
function kmerge() {
KUBECONFIG=~/.kube/config:$1 kubectl config view --flatten > ~/.kube/mergedkub && mv ~/.kube/mergedkub ~/.kube/config
}
@abelaska
abelaska / readme.md
Created June 16, 2020 06:02
Deploy to Minikube

Deploy to minikube

Ensure that docker is configured to use localhost:5000 as insecure registry https://docs.docker.com/registry/insecure/

minikube start
eval $(minikube docker-env)
docker run -d -p 5000:5000 --restart=always --name registry registry:2

mvn clean install -DskipChecks -DskipTests -DdockerBuild
@abelaska
abelaska / ObjectPatcher.java
Created June 8, 2020 09:44
Java Jackson Object Patcher
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import cz.monetplus.mep.fs.common.jackson.JacksonMapper;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;