Skip to content

Instantly share code, notes, and snippets.

View schmichri's full-sized avatar

Christian Schmitt schmichri

View GitHub Profile
@schmichri
schmichri / Entry in Grafana Config
Last active March 14, 2025 09:32
Nginx-Ingress Logs with Fluent-bit and Loki in Grafana | for logging Search Engine Crawlers for https://www.iunera.com and https://www.license-token.com/
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.monitoring.svc.cluster.local
access: proxy
isDefault: false
- name: Loki
@schmichri
schmichri / deadLinkFixer.ts
Last active March 14, 2025 07:17
Reads all Urls from a json and uses puppeteer to check if the links are dead or not. If they are dead it removes them from the JSON File
import {promises as fs} from 'fs';
import * as path from 'path';
import puppeteer, {Browser} from 'puppeteer';
import pLimit from "p-limit";
import {chunkArray} from "../../common/arrayHelper";
import {sleep} from "../../common/sleep";
interface URLResult {
originalUrl: string;
finalUrl: string;
@schmichri
schmichri / Dockerfile 2 Stage Build with node
Last active March 14, 2025 07:37
2 stage Build of Angular site with SSR / Prerendering
# Stage 1 - Building the app
FROM node:lts as builder
ENV CI=true
WORKDIR /site
COPY package*.json ./
RUN npm install
COPY . .
@schmichri
schmichri / docker_image_build_push.yml
Last active March 14, 2025 07:10
Build Angular Site with Docker. Extracts version from package.json and injects it in the Dockerfile https://www.license-token.com/
name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
@schmichri
schmichri / bumpVersion.ts
Created March 14, 2025 07:04
Version Bump for Typescript and package.json
import semver from 'semver';
import fs from "fs";
function bumpVersion(currentVersion: string, release: 'major' | 'minor' | 'patch'): string {
const newVersion = semver.inc(currentVersion, release);
if (!newVersion) {
throw new Error('Failed to bump version');
}
return newVersion;
}
@schmichri
schmichri / arrayHelper.ts
Created March 14, 2025 07:01
Typescript Array Helper
/**
* Shuffles the elements of an array in place using the Fisher-Yates algorithm.
*
* @param {T[]} array - The array to be shuffled.
* @return {T[]} The shuffled array.
*/
export function shuffleArray<T>(array: T[]): T[] {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];