Skip to content

Instantly share code, notes, and snippets.

@lovromazgon
lovromazgon / go.mod
Created July 29, 2024 17:09
Showcase of bug in hamba library
module hamba.test
go 1.22.3
require github.com/hamba/avro/v2 v2.23.0
require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@lovromazgon
lovromazgon / multicmd.sh
Created June 11, 2024 11:56
Execute the same command in multiple folders
#!/bin/bash
# multicmd.sh is a simple utility to execute the same command in multiple folders.
# It's useful for managing multiple git repositories at the same time.
#
# The commands are executed sequentially in each folder. If a command fails, the
# execution will pause and ask if you want to continue the execution or stop entirely.
#
# IMPORTANT: Before running the script, update the paths array to include all
# folders where the command should be executed.
#
package main
import (
"context"
"fmt"
"os"
"sync"
"testing"
"time"
@lovromazgon
lovromazgon / sem-copy-secret.sh
Created January 15, 2021 17:00
Duplicate a SemaphoreCI secret.
#!/bin/bash
# Usage:
# ./sem-copy-secret.sh [source secret name] [target secret name]
set -e
SOURCE_SECRET="$1"
TARGET_SECRET="$2"
echo "Copying secret $SOURCE_SECRET to $TARGET_SECRET"
@lovromazgon
lovromazgon / mute_twist.sh
Last active March 13, 2024 11:02
Mute Twist thread
#!/bin/bash
# Mutes a Twist thread for some time (30 minutes by default).
#
# Usage:
# ./mute_twist.sh <email> <password> <thread ID> [<minutes>]
EMAIL=$1
PASSWORD=$2
THREAD_ID=$3
MINUTES=${4:-30}
@lovromazgon
lovromazgon / README.md
Last active November 4, 2024 22:27
Schedule starting/stopping a CloudSQL instance on GCP

To use this cloud function follow these steps:

  1. Create a pub/sub topic which will be used to trigger the cloud function.
  2. Create the cloud function and copy in the code below.
    1. Make sure to set the correct project ID in line 8.
    2. Set the trigger to Pub/Sub and choose the topic created in step 1.
  3. Create a cloud scheduler job to trigger the cloud function on a regular basis.
    1. Choose the frequency when you want the cloud function to be triggered.
    2. Set the target to Pub/Sub and define the topic created in step 1.
    3. The payload should be set to start [CloudSQL instance name] or stop [CloudSQL instance name] to start or stop the specified instance (e.g. start my_cloudsql_instance will start the CloudSQL instance with the name my_cloudsql_instance)
@lovromazgon
lovromazgon / connect_box_restart.sh
Created June 25, 2019 08:30
This script restarts the ConnectBox from Magenta, an ISP in Austria.
#!/usr/bin/env bash
#
# This script restarts the ConnectBox from Magenta, an ISP in Austria.
#
# Run this script with LOGIN_USER and LOGIN_PASS env variables set to the
# username and password of the router and it will restart it.
#
# LOGIN_USER is 'NULL' by default, that is also the default router setting.
#
# Example usage:
@lovromazgon
lovromazgon / fix-grub.sh
Last active March 13, 2024 09:58
This script fixes GRUB for systems, that were installed according to the Manual Full System Encryption guide (https://help.ubuntu.com/community/ManualFullSystemEncryption). It is inspired by the original script used in the guide and reuses a lot of parts from it. Use an Ubuntu Live CD / USB to get to a terminal and run the script from there.
#!/usr/bin/env bash
####################################################################################################
#
# FIX GRUB FOR ENCRYPTED INSTALLATION
#
# This script is based on the Troubleshooting part of the Manual Full System Encryption for Ubuntu.
# See https://help.ubuntu.com/community/ManualFullSystemEncryption/Troubleshooting
#
# This is NOT AN OFFICIAL Ubuntu script, it can and will break your system. Use at own risk.
@lovromazgon
lovromazgon / github_projects_wip.user.js
Last active February 21, 2019 09:15
Tampermonkey script which changes the background of a column in Github projects if the work in progress limit is exceeded.
// ==UserScript==
// @name Github Projects work in progress limit
// @namespace https://github.com/lovromazgon
// @version 0.4
// @updateURL https://gist.github.com/lovromazgon/1e02018cafa132d0655e8c6850f18e17/raw/github_projects_wip.user.js
// @downloadURL https://gist.github.com/lovromazgon/1e02018cafa132d0655e8c6850f18e17/raw/github_projects_wip.user.js
// @description Changes the background of a column in Github projects if the work in progress limit is exceeded.
// @author Lovro Mažgon
// @match https://github.com/toggl/*/projects/*
// @grant none
@lovromazgon
lovromazgon / toggle-go-version.sh
Created June 13, 2018 07:35
Simple script to toggle between Go versions.
#!/bin/bash
echo "Available go versions:"
result=$(ls -1 /usr/local/ | grep -i "go" | grep -v "^go$")
echo "$result" | nl
echo ""
printf "Which version shall it be: "
read -r num