Skip to content

Instantly share code, notes, and snippets.

View sigismund's full-sized avatar

Žiga Drnovšček sigismund

View GitHub Profile
@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
@sigismund
sigismund / docker-install.sh
Last active June 14, 2022 12:51
Install latest docker and docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
DOCKER_COMPOSE_VERSION="2.6.0"
# Alternatively you can use the official docker install script
wget -qO- https://get.docker.com/ | sh
# Install docker-compose
@sigismund
sigismund / install-docker-ubuntu-sh
Last active March 20, 2019 08:36
Basic docker install on Ubuntu
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $USER