Skip to content

Instantly share code, notes, and snippets.

@lovromazgon
lovromazgon / README.md
Last active Sep 4, 2020
Schedule starting/stopping a CloudSQL instance on GCP
View README.md

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 Jun 25, 2019
This script restarts the ConnectBox from Magenta, an ISP in Austria.
View connect_box_restart.sh
#!/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 Aug 6, 2020
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.
View fix-grub.sh
#!/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 Feb 21, 2019
Tampermonkey script which changes the background of a column in Github projects if the work in progress limit is exceeded.
View github_projects_wip.user.js
// ==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 Jun 13, 2018
Simple script to toggle between Go versions.
View toggle-go-version.sh
#!/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
@lovromazgon
lovromazgon / switch_audio_sink.sh
Last active May 6, 2019
Script for switching between 2 audio sinks
View switch_audio_sink.sh
#!/bin/bash
set -euo pipefail # strict mode
currentSink() { pacmd list-sinks | awk '{if($1=="*"){print $3;}}'; }
inactiveSink() { pacmd list-sinks | awk '{if($1=="index:"){print $2;}}'; }
sinkInputs() { pacmd list-sink-inputs | awk '{if($1=="index:")print $2}'; }
current_sink="$(eval currentSink)"
inactive_sink="$(eval inactiveSink)"
sink_inputs="$(eval sinkInputs)"
@lovromazgon
lovromazgon / .bashrc
Created Jan 19, 2018
Support for multiple GOPATHs - set GOPATH on change of directory
View .bashrc
# with these functions you can have multiple gopath directories residing in /opt, where each gopath folder starts with "go-"
# when cd-ing to one of these directories (or any directory in them, on any level) the GOPATH gets changed automagically
function cd {
# call builtin cd. change to the new directory
builtin cd $@
# call a hook function that can use the new working directory
# to decide what to do
set_gopath
}
@lovromazgon
lovromazgon / tm_tempo_hours_diff.js
Last active Nov 9, 2017
Tampermonkey script which adds the information about required vs worked hours in Tempo.io
View tm_tempo_hours_diff.js
// ==UserScript==
// @name JIRA Hours Diff
// @namespace https://github.com/lovromazgon
// @version 0.2.3
// @updateURL https://gist.github.com/lovromazgon/7f2589530a36a8f355b05c087a82ee37/raw
// @description Adds the information about required vs worked hours in Tempo.io
// @author Lovro Mažgon
// @match https://app.tempo.io/timesheets/jira/reports/*
// @grant none
// ==/UserScript==
@lovromazgon
lovromazgon / multiinput_test.go
Created May 25, 2017
Test for stop of goflow component with multiple inputs
View multiinput_test.go
package test
import (
"github.com/trustmaster/goflow"
"fmt"
"testing"
"time"
)
// component 1
View .vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=500
" Enable filetype plugins
filetype plugin on
filetype indent on
You can’t perform that action at this time.