Skip to content

Instantly share code, notes, and snippets.

View lukaszraczylo's full-sized avatar
🎯
Focusing

Lukasz Raczylo lukaszraczylo

🎯
Focusing
View GitHub Profile
@lukaszraczylo
lukaszraczylo / convert.go
Created April 16, 2023 00:51
Convert json value into desired type using Golang generics
// Function:
func ConvertReplyType[T any](desiredType T, reply *[]byte) T {
if reply == nil {
return interface{}(nil).(T)
}
// reflect type of desired type
desiredTypeType := reflect.TypeOf(desiredType)
v := reflect.New(desiredTypeType).Interface()
@lukaszraczylo
lukaszraczylo / archive-old-repositories.sh
Created April 13, 2023 16:34
Archive old github repositories for user/organisation
#!/bin/bash
# This script will archive all repositories on github where
# the last commit was more than 2 years ago.
# It takes one argument, the github username / organisation name.
organisationName=$1
if [ -z "$organisationName" ]; then
echo "Please provide organisation name"
@lukaszraczylo
lukaszraczylo / 0_traefik_mirror_lab.md
Created April 9, 2023 01:40 — forked from neoakris/0_traefik_mirror_lab.md
Reproducible Demo of Traefik 2.0 Traffic Mirroring on EKS

Reproducible Demo of Traefik 2.0 Traffic Mirroring

Overview

What to expect in this doc:

  • Traefik 2.0 has traffic mirroring functionality that should work on generic Kubernetes, but there's no good how-to guides, let this be the first.
  • This is a how-to guide, that's optimized for understanding
apiVersion: jobsmanager.raczylo.com/v1beta1
kind: ManagedJob
metadata:
labels:
name: data-import
spec:
retries: 3
params:
env:
- name: "FOO"
#!/bin/bash
# This script sets the token for all repositories within organisation.
set -e
organisationName=$1
if [ -z "$organisationName" ]; then
echo "Please provide organisation name"
exit 1
name: Test and release
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
branches:
- "main"
name: Sample github action
on:
workflow_call:
inputs:
enable-code-scans:
required: false
type: boolean
secrets:
ghcr-token:
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
ADDITIONAL_ARGS=-var 'traefik_api_key=$(TRAEFIK_API_KEY)' -var "github_user=$(GH_USER)" -var "github_pat=$(GH_TOKEN)"
apply:
cd infrastructure; terraform apply $(ADDITIONAL_ARGS) -auto-approve -var-file ../variables.tfvars
plan:
cd infrastructure; terraform plan $(ADDITIONAL_ARGS) -var-file ../variables.tfvars
destroy:
cd infrastructure; terraform destroy $(ADDITIONAL_ARGS) -var-file ../variables.tfvars
# Variables used for barebone kubernetes setup
network_subnet = "192.168.50"
net_hosts = {
adguard = "240"
adguard_catchall = "249"
traefik = "234"
torrent_rpc = "245"
}