Skip to content

Instantly share code, notes, and snippets.

View sburlot's full-sized avatar

Stephan Burlot sburlot

View GitHub Profile
# I use this as a template to enable or disable features on websites.
# Not all are activated at the same time, check what you need
#
# Stephan Burlot coriolis.ch Apr 2024
#
## Prevent user enumeration for WordPress
RewriteCond %{REQUEST_URI} !^/wp-admin [NC]
RewriteCond %{QUERY_STRING} author=\d
RewriteRule ^ - [L,R=403]
@sburlot
sburlot / check_load_json.php
Created April 23, 2024 08:20
Check if your hosting server has too much activity
<?php
// Check if your hosting server has too much activity.
// I use it to check when my site is slow
// Drop it in your main directory and call it with curl
// curl "https://example.com/check_load_json.php"
//
// Returns the load avg as a json, so you can process it easily
//
// Stephan Burlot coriolis.ch Apr 2024
//
@sburlot
sburlot / WooCommerce Yesterday Sales
Last active April 23, 2024 09:02
Get number of yesterday sales from WooCommerce
# you'll need jq installed
# and keys for WooCommerce API access
#
# Stephan Burlot coriolis.ch Apr 2024
#
# this works on MacOSX
curl -s "https://example.ch/wp-json/wc/v3/orders?\
consumer_key=ck_CONSUMER_KEY&\
consumer_secret=cs_SECRET_KEY&\
after=$(date -v-1d '+%Y-%m-%dT00:00:00')" | \
@sburlot
sburlot / WooCommerce Today Sales
Created April 23, 2024 08:13
Get number of today sales from WooCommerce
# you'll need jq installed
# and keys for WooCommerce API access
#
# Stephan Burlot coriolis.ch Apr 2024
#
curl -s "https://example.ch/wp-json/wc/v3/orders?\
consumer_key=ck_CONSUMER_KEY&\
consumer_secret=cs_SECRET_KEY&\
after=$(date '+%Y-%m-%dT00:00:00')" | \
jq '. | length'
@sburlot
sburlot / get_sites_mainwp.php
Created April 23, 2024 08:07
Outputs list of all sites managed with MainWP in a CSV file
#!/usr/bin/env php
<?php
/*
Little helper tool to help me manage all my WordPress sites
Needs MainWP https://mainwp.com/ installed and configured
Creates a CSV file with all sites managed by MainWP
CSV File with site name, url, WP version, PHP version and name of theme
Tested with PHP 8.1.27
@sburlot
sburlot / fastmail_snooze.py
Created April 23, 2024 07:56
Mark snoozed emails from FastMail as UNREAD
#!/usr/bin/python3
# When snoozing a Fastmail ( fastmail.com ) message, mark it as unread so when it appears
# again in the INBOX it's unread and I can see it, instead of being another
# email lost in all my messages
# run it as an hourly cron
# tested with Python 3.10.12
#
# Stephan Burlot [email protected] Apr 2024
#
@sburlot
sburlot / backblaze_b2_bucket_size.pl
Last active April 23, 2024 07:57
Report size of all Backblaze B3 folders in bucket with S3CMD
#!/usr/bin/perl
# I use updraft to backup WordPress sites, I need to monitor BackBlaze/b2 bucket size because money
# This script will report the size used by all buckets, used to monitor the
# size of all buckets.
# It uses s3cmd https://s3tools.org/s3cmd
# Outputs and send via email the size of all buckets, sorted by size, with
# total size of all buckets
#
# Stephan Burlot [email protected] Apr 2024
#
@sburlot
sburlot / s3_bucket_size.pl
Last active April 23, 2024 07:47
Report size of all Amazon S3 buckets with S3CMD
#!/usr/bin/perl
# I use updraft to backup WordPress sites, I need to monitor S3 bucket size because money
# This script will report the size used by all buckets, used to monitor the
# size of all buckets.
# It uses s3cmd https://s3tools.org/s3cmd
# Outputs and send via email the size of all buckets, sorted by size, with
# total size of all buckets
#
# Stephan Burlot [email protected] Apr 2024
#
#!/usr/bin/perl
# vi:set ts=4 nu:
use strict;
use POSIX 'strftime';
use Net::SSL::ExpireDate;
use Date::Parse;
use Data::Dumper;
use MIME::Lite;
@sburlot
sburlot / unban.pl
Created March 7, 2018 00:53
remove an iptable rule, passing an IP address to look for
#!/usr/bin/perl
## unban an IP using iptables
## script will display the iptable command to run, it will not delete the rule (if found)
## Usage: ./unban.pl -ip=123.123.123.123
use Getopt::Long;
@LINES = `iptables -L -n`;