Skip to content

Instantly share code, notes, and snippets.

@onwp
onwp / find_unused_css_classes.sh
Last active February 25, 2023 15:26
Find unused CSS classes in html,php,js files for multiple themes. Run this script in "themes" directory of Wordpress
#!/bin/bash
for dir in $(ls -d */ | grep -v cache | grep -v node_modules | cut -f1 -d'/'); do
(
echo "checking $dir :";
pushd "$dir" &>/dev/null || {
printf "error: failed to change to %s\n" "$dir" >&2
continue
}
echo "--------------------------------";
cat $(find app/styles/ -type f) |
@onwp
onwp / jquery-unique-svg-id.js
Created January 16, 2023 09:08
Jquery unique svg id handler
(function ($) {
const all_svg_logos = $('svg');
all_svg_logos.each(function (svg_idx, svg_item) {
if ($(svg_item).children('linearGradient').length) {
$(svg_item).children('linearGradient').each(function (linear_idx, linear_elm) {
$(svg_item).children('g').children('path').each(function (path_idx, path_prop) {
if (path_prop.getAttribute("fill").includes(linear_elm.getAttribute("id"))) {
// Set unique identifier for fill attribute of <path> element based on SVG's occurrence index
path_prop.setAttribute("fill", "url(#" + linear_elm.getAttribute("id") + "_" + svg_idx + ")");
}
@onwp
onwp / mac-clean-up-desktop.scpt
Created February 25, 2023 15:21
Tidy up your desktop icons on mac
tell application "System Events"
tell application "Finder" to activate desktop
tell process "Finder"
click menu item "Clean Up" of menu "View" of menu bar item "View" of front menu bar
end tell
@onwp
onwp / mac-desktop-icons-on-left-side.scpt
Last active January 31, 2025 14:22
MacOS Desktop Icons on Left. It rearranges your desktop icons, keeps it aligned to the left side of screen.
-- https://gist.github.com/mrienstra/8330528
-- Based on http://www.tuaw.com/2012/12/24/applescript-desktop-icon-race/
-- Inspired by http://namesakecomic.com/comic/happy-new-year-from-namesake/#comment-1182035013
-- Rearranges Desktop icons to flow from left to right, top to bottom.
-- To have this run automatically every time files are added or removed from the Desktop, set this script to run as a Desktop "Folder Action". (See https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/reference/ASLR_folder_actions.html )
-- This is currently a rough proof-of-concept. It has only been tested with OS y 10.8.5 (Mountain Lion).
@onwp
onwp / bulk-update-git-author-info.sh
Created February 25, 2023 15:41
Update your old email and name in commits.
git filter-branch --env-filter '
OLD_EMAIL="old@example.com"
NEW_NAME="New Author Name"
NEW_EMAIL="new@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
@onwp
onwp / fresh_npm_install.txt
Created March 19, 2023 18:46
Delete node_modules, clean cache, and npm install
rm -rf node_modules && rm -rf **/node_modules && rm -rf package-lock.json && rm -rf yarn-error.log && rm -rf yarn.lock && npm cache clean --force && npm i
@onwp
onwp / gist:16048aba167d66850ee32550f44b4cec
Created April 21, 2023 18:48
prisma not reading env database_url
npm install -g dotenv-cli
npx prisma generate
dotenv -e .env.local -- npx prisma db push
@onwp
onwp / openvpn-weak-algorithm-fix.txt
Created May 30, 2023 12:27
openvpn weak algorithm fix
Insert the following line in the client's config.ovpn file:
tls-cipher "DEFAULT:@SECLEVEL=0"
@onwp
onwp / wp-cli-clear-cache-commands.txt
Created October 11, 2023 07:07
WP cli clear cache commands
#Flush the object cache using this WP-CLI command.
wp cache flush
#Beaver Builder plugin and Beaver Theme have these WP-CLI commands.
wp beaver clearcache
wp beaver theme clearcache
wp beaver clearcache --all
#Autoptimize plugin has this WP-CLI command.
wp autoptimize clear
@onwp
onwp / nginx.conf
Created December 12, 2023 08:34
alpine-nginx-php8/config/nginx.conf
worker_processes 1;
error_log stderr warn;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;