Skip to content

Instantly share code, notes, and snippets.

View sigismund's full-sized avatar

Žiga Drnovšček sigismund

View GitHub Profile
@sigismund
sigismund / cloudflare_account_token_creation.tf
Created May 27, 2025 11:42
Creates Cloudflare Account token with all permissions included
# To use this configuration, you need to set these environment variables:
# export CLOUDFLARE_API_TOKEN="your_api_token"
# OR
# export CLOUDFLARE_EMAIL="your_email"
# export CLOUDFLARE_API_KEY="your_global_api_key"
locals {
account_id = "xxx"
}
data "cloudflare_account" "account" {
@sigismund
sigismund / cronjob-refresh-oidc-token.sh
Created October 29, 2024 12:29
CronJob script used to refresh the OIDC token used by Prometheus Blackbox Exporter
#!/bin/bash
set -e
echo "Starting OIDC token generation process..."
# OIDC Token Request
echo "Requesting OIDC token from ${TOKEN_ENDPOINT//\{tenantId\}/$TENANT_ID}..."
TOKEN_RESPONSE=$(curl -s -X POST "${TOKEN_ENDPOINT//\{tenantId\}/$TENANT_ID}" \
-H "Content-Type: application/x-www-form-urlencoded" \
@sigismund
sigismund / get_good_bots.sh
Created December 8, 2023 09:26
Get IP ranges of "good" crawl bots. Bash version of https://github.com/AnTheMaker/GoodBots
#!/bin/bash
# This is copy of script used in Github Actions of https://github.com/AnTheMaker/GoodBots
# Requirements: curl, whois, jq
WORKING_DIRECTORY=$(pwd)
mkdir -p iplists
# Generate GoogleBot IP-List
curl -s https://developers.google.com/static/search/apis/ipranges/googlebot.json | jq -r '.prefixes[].ipv6Prefix,.prefixes[].ipv4Prefix | select( . != null )' | tr -d "[:blank:]" > $WORKING_DIRECTORY/iplists/googlebot.ips
@sigismund
sigismund / openapi.yaml
Created October 27, 2022 13:51
Create proxy GCP Service endpoint
swagger: "2.0"
info:
title: Simple service endpoint for GCP
version: 1.0.0
host: $DOMAIN_NAME
x-google-endpoints:
- name: $DOMAIN_NAME
target: $IP_ADDR
x-google-allow: all
basePath: /
#!/bin/sh
for bin in ~/.local/share/flatpak/exports/bin/*; do
appid="$(basename $bin)"
cmd="$(flatpak info -m $appid | awk -F= '/^command=/ {print $2}')"
echo "alias ${cmd}=$bin"
done
@sigismund
sigismund / jira-unwatch.js
Last active February 6, 2022 16:37
Jira - remove watched but completed issues
AJS.$.ajax({
url: '/rest/api/latest/search',
data: {jql:'watcher = currentUser() AND status in (Done, Deployed, Closed)'},
success: function (response) {
AJS.$.each(response.issues, function(i,issue) {
var completed = ['Done', 'Deployed', 'Closed']
if (completed.includes(issue.fields.status.name)) {
AJS.$.ajax({
url: '/rest/api/1.0/issues/' + issue.id + '/watchers',
@sigismund
sigismund / install-google-chrome.sh
Created April 1, 2021 12:20
Chromium install on CentOS/Amazon Linux
#! /bin/bash
# Copyright 2017-present: Intoli, LLC
# Source: https://intoli.com/blog/installing-google-chrome-on-centos/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
@sigismund
sigismund / install_chrome.sh
Created June 10, 2020 06:37
Install Chrome on CentOS/AWS
#! /bin/bash
# Copyright 2017-present: Intoli, LLC
# Source: https://intoli.com/blog/installing-google-chrome-on-centos/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
@sigismund
sigismund / wp-cli-scheduler.sh
Last active August 3, 2020 08:22
Check if wp action-scheduler ("cron") tasks are already running
#!/bin/bash
SERVICE="wp-cli action-scheduler"
MAX_RUNNING_SCHEDULERS=3
WP_CLI_PATH="/usr/local/bin/wp"
if (( $(ps aux | grep '/bin/wp action-scheduler' | grep -v 'grep' | wc -l) >= MAX_RUNNING_SCHEDULERS ))
then
echo "$SERVICE tasks are running at it's limit ($MAX_RUNNING_SCHEDULERS)."
else
echo "$SERVICE tasks are NOT running at it's limit ($MAX_RUNNING_SCHEDULERS)."
@sigismund
sigismund / git_origin_cleanup.sh
Created November 18, 2019 14:50
Cleanup of already merged branches. Excludes develop & master branch
git branch -r --merged | grep -v '\\*\\|master\\|develop' | sed 's/origin\///' | xargs -n 1 git push --delete origin