Skip to content

Instantly share code, notes, and snippets.

@mrbuk
mrbuk / cert-type-length.go
Created November 6, 2023 16:25
Prints out signature algorithm, as well as type and the length of the public key for a DER formated certifacted on STDIN
package main
import (
"crypto/ecdsa"
"crypto/rsa"
"crypto/x509"
"fmt"
"io/ioutil"
"log"
"os"
@mrbuk
mrbuk / cloudbuild.yaml
Last active March 11, 2023 17:20
Cloud Build Step calling Cloud Run Service with Identity Token
steps:
- name: gcr.io/cloud-builders/curl
entrypoint: "/bin/sh"
args:
- "-c"
- |-
access_token=$(curl -H 'Metadata-Flavor: Google' \
http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token | \
grep -E -o 'ya29[^"]+')
curl -s -f 'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/$_SERVICE_ACCOUNT:generateIdToken' \
@mrbuk
mrbuk / main.tf
Last active March 24, 2023 14:13
Add a Google Cloud Service Account to a Cloud Identity Group
variable "project" {
type = string
}
variable "group_name" {
type = string
}
variable "customer_id" {
type = string
@mrbuk
mrbuk / cloudbuild.yaml
Created July 16, 2022 09:06
Simple Cloud Build run Terraform init/plan/apply with custom git credentials
# Copyright 2019 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@mrbuk
mrbuk / Dockerfile
Created December 6, 2021 17:42
code-server with mini tools and go, python, rust and node toolstack
FROM debian:bullseye-slim
# minimal dependecies including python
RUN apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates netbase tzdata \
curl wget \
htop git \
bash zsh fish man \
gawk sed grep \
build-essential make \
@mrbuk
mrbuk / vyos-with-bgp.md
Created August 19, 2020 20:56
Deploying a VyOS VM as a router for NSX-T with BGP

Router configuration for VyOS that will

  • learn routes via BGP
  • propagate routes via BGP

This configuration is at the moment used to bridge NSX-T in a homelab environment to the existing homerouter network

Network Design

The simplified network setup looks like the following

@mrbuk
mrbuk / gpio17_high.py
Last active April 23, 2020 15:46
Turn GPIO17 on RasPI on
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, True)
@mrbuk
mrbuk / make-it-sound.sh
Created May 1, 2018 10:53
Set the default sink and source
#!/bin/bash
DEFAULT_CARD=alsa_card.pci-0000_01_00.1
DEFAULT_SOURCE=alsa_input.usb-046d_HD_Pro_Webcam_C920_B6E53ECF-02.analog-stereo
SOUND_FILE=ChID-BLITS-EBU-Narration441-16b.wav
function stop_sound_system() {
echo "Stopping pulseaudion"; killall pulseaudio
echo "Waiting 10s ..."; sleep 10
@mrbuk
mrbuk / DisplayProductID-76e7
Last active October 8, 2017 17:15
LG31MU97 MacOS 50Hz patched EDID
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DisplayPixelDimensions</key>
<data>
AAAQAAAACHA=
</data>
<key>DisplayProductID</key>
<integer>30439</integer>
#!/bin/bash
# if the notebook lid is closed the the display is identified as "DisplayPort-0". If the notebook lid is open it is identified as "DisplayPort-1"
# in case of a closed lid "DisplayPort-1 disconnected" can be found in xrandr output.
# default to notebook lid is open
TARGET_DISPLAY="DisplayPort-1"
xrandr | grep 'DisplayPort-1 disconnected' > /dev/null
if [ "$?" == 0 ]; then