Skip to content

Instantly share code, notes, and snippets.

@vkartk
vkartk / wg0.conf
Created October 21, 2024 15:53
Sample WireGuard configuration
[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 10.0.0.2/24
DNS = 1.1.1.1, 1.0.0.1
[Peer]
PublicKey = YOUR_SERVER_PUBLIC_KEY
AllowedIPs = 0.0.0.0/0
Endpoint = YOUR_SERVER_WAN_IP:51820
@vkartk
vkartk / .htaccess
Created September 6, 2024 12:00
Cloudways WordPress htaccess File
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
@vkartk
vkartk / Caddyfile
Created May 31, 2024 05:35
Caddy Default Config File
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
@vkartk
vkartk / wordpress-reply-to.php
Created April 25, 2024 15:23
Wordpress Custom Reply-To Email
// Sets reply-to if it doesn't exist already.
add_filter( 'wp_mail', 'wp_mail_filter_set_reply_to' );
function wp_mail_filter_set_reply_to( $args ) {
if (!isset($args['headers'])) {
$args['headers'] = array();
}
$headers_ser = serialize($args['headers']);
@vkartk
vkartk / .stignore
Created July 29, 2023 16:14
A comprehensive .stignore file for Syncthing, excluding unnecessary files and directories during synchronization. Organized into categories, platform-specific exclusions included.
# Commonly ignored files and directories
.DS_Store
Thumbs.db
desktop.ini
# Temporary files
*.tmp
*.temp
*.swp
@vkartk
vkartk / update_ufw.bash
Created December 5, 2022 05:12
UFW ssh access from dynamic ip
#!/bin/bash
HOSTNAME=dynamicdns.tld # Your Dynamic DNS Hostname
PORT=22 # SSH Port
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
new_ip=$(host $HOSTNAME | head -n1 | cut -f4 -d ' ')
@vkartk
vkartk / .env.sample
Created October 3, 2022 15:04
This is a sample .env template [ .env.sample ]
# This is a sample .env file for use in local development.
# Duplicate this file as .env in the root of the project
# and update the environment variables to match your
# desired config
#
# See the README for full descriptions of each of the
# available configurations.
@vkartk
vkartk / file-extension.js
Created March 7, 2022 12:15
JavaScript get the file extension
// JavaScript get the file extension
function getExtension(filename){
const ext = filename.split('.').pop();
return ext;
}
@vkartk
vkartk / WooCommerce-Product-Count.php
Created January 17, 2022 07:18
WooCommerce Product Count By Category || Shortcode
// To Only Retrun the Product Count By Category
//[woocommerce_product_category_count category="rings"]
// Special thanks to CHADREX
add_shortcode( 'products-counter', 'products_counter' );
function products_counter( $atts ) {
$atts = shortcode_atts( [
'category' => '',
], $atts );
$taxonomy = 'product_cat';
@vkartk
vkartk / buddy_exclude_users_by_role.php
Created November 6, 2021 19:45
Exclude Users from BuddyPress Members List by WordPress role. ( BuddyPress / BuddyBoss )
function buddy_exclude_users_by_role( $args ) {
// do not exclude in admin.
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return $args;
}
$excluded = isset( $args['exclude'] ) ? $args['exclude'] : array();
if ( ! is_array( $excluded ) ) {
$excluded = explode( ',', $excluded );