Skip to content

Instantly share code, notes, and snippets.

@markbosky
markbosky / random_rename_files_in_directory.sh
Created September 6, 2020 18:34
Rename files within a directory to random strings (don't forget to chmod 755 to execute)
#!/bin/bash
chars=( {a..z} {A..Z} {0..9} )
function rand_string {
local c=$1 ret=
while((c--)); do
ret+=${chars[$((RANDOM%${#chars[@]}))]}
done
printf '%s\n' "$ret"
@markbosky
markbosky / apache-nginx-https-trailing-slash.txt
Last active December 9, 2021 21:42
Apache NGINX Server Rules: Enforce Trailing Slash, Redirect to HTTPS
#Apache
<IfModule mod_rewrite.c>
RewriteEngine On
# Ensure all URLs have a trailing slash.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|xml|txt|js|php|scss|webp|mp3|avi|wav|mp4|mov|pdf|html|htm|xst)$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1/ [L,R=301]
@markbosky
markbosky / light-dark-favicon-browser-theme.js
Created December 16, 2021 22:04
Light and Dark Favicon Based on User's Browser Theme
jQuery(document).ready(function($) {
'use strict';
function setupIcons() {
const lightSchemeIcon = document.querySelector('link#light-scheme-icon');
const darkSchemeIcon = document.querySelector('link#dark-scheme-icon');
function setLight() {
document.head.append(lightSchemeIcon);
darkSchemeIcon.remove();
@markbosky
markbosky / wp-remove-meta-boxes.php
Created December 17, 2021 19:37
WordPress - Remove Unwanted Meta Boxes from Editor
<?php
// Remove Post Meta Boxes from WP Editor
function remove_my_post_metaboxes() {
remove_meta_box( ‘authordiv’,’post’,’normal’ ); // Author Metabox
remove_meta_box( ‘commentstatusdiv’,’post’,’normal’ ); // Comments Status Metabox
remove_meta_box( ‘commentsdiv’,’post’,’normal’ ); // Comments Metabox
remove_meta_box( ‘postcustom’,’post’,’normal’ ); // Custom Fields Metabox
remove_meta_box( ‘postexcerpt’,’post’,’normal’ ); // Excerpt Metabox
remove_meta_box( ‘revisionsdiv’,’post’,’normal’ ); // Revisions Metabox
@markbosky
markbosky / wp-remove-amp-meta-boxes.php
Created December 17, 2021 19:39
WordPress - Remove AMP for WP – Accelerated Mobile Pages Post Meta Boxes
<?php
// Hide Accelerated Mobile Pages Admin Menus
function plt_hide_accelerated_mobile_pages_menus() {
//Hide "AMP".
remove_menu_page('amp_options');
//Hide "AMP → Setup".
remove_submenu_page('amp_options', 'amp_options&tab=1');
//Hide "AMP → Settings".
remove_submenu_page('amp_options', 'amp_options&tab=2');
@markbosky
markbosky / wp-remove-admin-comments-section.php
Created December 30, 2021 18:48
WordPress - Remove Comments Menu from Admin Area
/**
* Removes comments from the left hand navigation in the admin.
*/
add_action( 'admin_menu', 'wp_remove_menus' );
function wp_remove_menus() {
global $menu;
global $submenu;
remove_menu_page( 'edit-comments.php' );
echo '';
}
@markbosky
markbosky / wp-remove-gutenberg-styles.php
Last active February 21, 2022 19:43
Remove Gutenberg Block Library CSS from loading on the frontend
<?php
//Remove Gutenberg Block Library CSS from loading on the frontend
function smartwp_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-blocks-style' ); // Remove WooCommerce block CSS
wp_dequeue_style( 'storefront-gutenberg-blocks' ); // Storefront theme
}
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css', 100 );
@markbosky
markbosky / Undo_Restore_Windows_Photo_Viewer_CURRENT_USER.reg
Created February 26, 2022 19:14
Undo Windows Photo Viewer Addition Registry Change - Windows 10
Windows Registry Editor Version 5.00
; Created by: Shawn Brink
; Created on: June 27th 2016
; Updated on: May 7th 2019
; Tutorial: https://www.tenforums.com/tutorials/14312-restore-windows-photo-viewer-windows-10-a.html
[HKEY_CURRENT_USER\SOFTWARE\Classes\.bmp]
@markbosky
markbosky / Restore_Windows_Photo_Viewer_CURRENT_USER.reg
Created February 26, 2022 19:15
Restore Windows Photo Viewer Application - Windows 10 Registry Tweak
Windows Registry Editor Version 5.00
; Created by: Shawn Brink
; Created on: June 27th 2016
; Updated on: May 7th 2019
; Tutorial: https://www.tenforums.com/tutorials/14312-restore-windows-photo-viewer-windows-10-a.html
[HKEY_CURRENT_USER\SOFTWARE\Classes\.bmp]
@markbosky
markbosky / tec-remove-susbscribe-dropdown.php
Created April 12, 2022 21:05
WordPress - The Events Calendar - Remove "subscribe to calendar" dropdown from the main calendar page and widget
<?php
// Remove subscribe to calendar dropdown from main calendar page
add_filter( 'tribe_template_html:events/v2/components/subscribe-links/list', '__return_false' );