Skip to content

Instantly share code, notes, and snippets.

@groundcat
groundcat / auto-delete-cf-dns.js
Created April 7, 2024 09:19 — forked from azliabdullah/auto-delete-cf-dns.js
bulk delete all DNS records in cloudflare
/**
* 1. open cloudflare dashboard, choose domain, go to DNS section
* 2. open browser's dev tool (via F12 or inspect or however)
* 3. in devtool, go to console tab
* 4. clear all existing messages
* 5. paste all script below
* 6. hit enter and watch
* 7. script only delete records displayed in the screen
* 8. if want to delete more, refresh browser and run script again
*
@groundcat
groundcat / virtualizor-auto-restart-vps.sh
Last active February 26, 2024 22:09
Auto restart the VPS through the Virtualizor end-user API when the VPS is down
#!/bin/bash
# Define variables
VPS_IP=""
API_KEY=""
API_PASSWORD=""
PANEL_URL="https://panel.example.com:4083"
# Stop the VPS
stop_vps() {

A one-line command that creates the script in the /opt directory and sets up the cronjob to run at 2:10 AM:

sudo bash -c 'echo -e "#!/bin/bash\nsudo apt-get update\nsudo apt-get install --only-upgrade tailscale -y" > /opt/update_tailscale.sh && chmod +x /opt/update_tailscale.sh && (crontab -l 2>/dev/null; echo "10 2 * * * /opt/update_tailscale.sh") | crontab -'
@groundcat
groundcat / enable-clipboard.sh
Created September 7, 2023 06:20
Fix clipboard sharing for Virtualbox Ubuntu VMs
# optionally: sudo apt-get remove virtualbox-guest-x11
sudo apt-get install virtualbox-guest-x11
sudo /usr/bin/VBoxClient --clipboard
||sogou.com^
||ocsp.apple.com^
||file.apicvn.com^
||dldir1.qq.com^
||360.com^
||360.cn^
||izatcloud.net^
||fengkongcloud.com^
||tebiefuza.cn^
||fengkongcloud.com^
@groundcat
groundcat / backup-proxmox-to-s3.md
Created August 2, 2023 05:25
Backup proxmox files to S3

Here is a step-by-step guide on how to use AWS CLI with a non-AWS custom endpoint, access id, and key to move (upload then delete) files to object storage.

  1. Install AWS CLI

This can be done by running the following command in your terminal:

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
@groundcat
groundcat / check.sh
Last active July 16, 2023 21:06
CDN and Load Balancer Tester
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: ./check.sh [domain]"
exit 1
fi
DOMAIN=$1
ALL_RECORDS=$(dig @8.8.8.8 +short $DOMAIN)
@groundcat
groundcat / readme.md
Created July 8, 2023 21:22
Checks connection and auto connect to Cloudflare Warp

Cloudflare Warp Status Check Script

This bash script checks the status of Cloudflare Warp for a given endpoint (https://cloudflare.com/cdn-cgi/trace). It uses curl to make a HTTP request to the specified URL, checks if the response contains "warp=on" or "warp=plus", and acts accordingly.

Prerequisites

Before running the script, make sure you have the following tools installed on your system:

  • curl: A command-line tool for making HTTP requests. You can install it with a package manager like apt, brew, or yum.
  • warp-cli: A command-line interface for managing Cloudflare Warp. Follow Cloudflare's instructions to install it.
@groundcat
groundcat / batch-flatten-pdf.md
Last active March 17, 2023 02:15
Flatten all PDF files in a folder on Linux

To flatten all PDF files in a folder, you can use the command-line tool called pdftk. It is a powerful toolkit for working with PDF files, and it is available on most Linux distributions.

First, install pdftk on your system if you haven't already. For Ubuntu or Debian-based systems, you can use:

sudo apt update
sudo apt install pdftk

For Fedora-based systems, you can use:

@groundcat
groundcat / woocommerce-auto-complete-downloadable-orders.php
Created March 16, 2023 22:24
Automatically mark WooCommerce orders complete, only if all the products in the order is downloadable.
/**
* Auto Complete all WooCommerce orders with only downloadable products.
* If all the products are downloadable, the order status will be updated to 'completed'.
* Use this plugin to implement the function:
* https://github.com/woocommerce/theme-customisations
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;