Skip to content

Instantly share code, notes, and snippets.

@positiveque
positiveque / delete-traefik-acme-certificates.sh
Created November 26, 2024 13:40 — forked from DrJume/delete-traefik-acme-certificates.sh
Select domains from traefik's acme.json to delete
#!/bin/bash
# tested with traefik v2.4.8
ACME_FILE="acme.json"
# get jq from https://stedolan.github.io/jq/
SELECTED_DOMAINS=$(jq -r '.letsencrypt.Certificates[].domain.main' "$ACME_FILE" | fzf -m --height '40%' --reverse --border)
if [[ -z "$SELECTED_DOMAINS" ]]; then
@positiveque
positiveque / cloudflare-zone-settings-overview.sh
Created November 26, 2024 13:40 — forked from DrJume/cloudflare-zone-settings-overview.sh
Cloudflare zone settings overview as table
#!/bin/bash
# parameters
CF_API_EMAIL=
CF_API_KEY=
# specify the id for a zone (domain)
# get it via the Cloudflare Dashboard
# of via flarectl: https://github.com/cloudflare/cloudflare-go/tree/master/cmd/flarectl
CF_ZONE=
@positiveque
positiveque / backup-container-volumes.sh
Created November 26, 2024 13:40 — forked from DrJume/backup-container-volumes.sh
Backup all mounted volumes in a Docker container into a .tar.gz archive
#!/bin/bash
# Author: @DrJume
# This script lets you backup all mounted volumes of a Docker container
# into a .tar.xz archive.
# Throw on nonzero exit in pipelines
set -e
//Do not load plugins' scripts and styles on every page - only where they are in use
add_filter( 'style_loader_tag', 'sz_stop_loading_unused_styles', 10, 2 ); // *doesn't works with 3 arguments
function sz_stop_loading_unused_styles( $tag, $handle) {
if (!is_user_logged_in()){// for FE only
if (is_singular('post')) {// for Posts only
//entire plugin
if (str_contains($tag, 'woocommerce')) $tag = '';
//specific handle
//Gutenberg
if (in_array( $handle, ['wc-blocks-style', 'wp-block-editor', 'wp-editor', 'wp-block-library', 'wp-components'])) $tag = '';
@positiveque
positiveque / stop_loading_blocks_crap_fse.php
Created May 3, 2023 21:34 — forked from sabrina-zeidan/stop_loading_blocks_crap_fse.php
Stop loading block's CSS and JS if the block is not used -- for Full Site Edit themes [WordPress]
// Avoid loading unused assets, both JS and CSS
// Removes both CSS and JS
// For Full Site Editing Theme!
// In a better world block's author makes sure the block's assests are loaded only if block is actually in use (via enqueue_block_assets). For other cases we can do it ourselves
// In this example I load Swiper's block assets only where the block is used
// TODO: Works for content on Singular content only. if block is elsewhere or it's archive use this https://wordpress.stackexchange.com/questions/392493/find-if-widget-block-is-active
add_filter( 'style_loader_tag', 'sz_stop_loading_unused_block_crap', 9999, 3 );
add_filter( 'script_loader_tag', 'sz_stop_loading_unused_block_crap', 10, 3 );
function sz_stop_loading_unused_block_crap( $tag, $handle, $src ) {
@positiveque
positiveque / run-wp-cron.sh
Created May 2, 2023 23:52 — forked from bjornjohansen/run-wp-cron.sh
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
#!/bin/bash
# Copyright © 2015 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
WP_PATH="/path/to/wp"
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
@positiveque
positiveque / redis.md
Created May 2, 2023 23:50 — forked from rahul286/redis.md
Useful redis cli commands

Redis Keys Count by Group (namespace)

redis-cli KEYS "*" | awk -F: '{print $1'} | sort | uniq -c

Count WordPress transient

redis-cli KEYS "*" | grep ":transient:" | wc -l
#!/bin/bash
#
# #############################################################################
# Create new SSH user (Ubuntu)
# I use this script whenever I need to add a new SSH user to an Ubuntu machine.
# Usage:
# 1) Download the "raw" with - wget -O createNewSSHUser.sh https://gist.github.com/raw/4223476
# 2) Make it executable with - chmod a+x createNewSSHUser.sh
# 3) Uncomment the last line and edit the user & pwd values
# 4) Execute it with : sudo ./createNewSSHUser.sh
#!/bin/bash
# Autor: remontti.com.br
#Insert your bot token without the "bot" part in the variable bellow
TOKEN="2ef92jfn2;uf9nf2nFUE(U@sadfwewoijfe#$"
USER=$1
SUBJECT=$2
MESSAGE=$3
NL="
"
#!/bin/bash
#Reads the date parameter. empty then date is today
if [ -z "$1" ]
then
date=$(date +"%Y-%m-%d")
else
date=$1
fi