Skip to content

Instantly share code, notes, and snippets.

View onwp's full-sized avatar
🚀
saas

Serhat onwp

🚀
saas
View GitHub Profile
@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 / 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 / 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 / find_unused_scss_variables.sh
Created January 9, 2023 13:36
Bash script to find unused SCSS variables
#!/usr/bin/env bash
# HOW TO USE
# Save code to file
# Run as "SCRIPT_FILE_NAME SASS_DIRECTORY"
# e.g "./find_unused_scss_variables.sh ./sass"
VAR_NAME_CHARS='A-Za-z0-9_-'
find "$1" -type f -name "*.scss" -exec grep -o "\$[$VAR_NAME_CHARS]*" {} ';' | sort | uniq -u
@onwp
onwp / list-of-curl-flags.txt
Last active December 30, 2022 13:17 — forked from eneko/list-of-curl-options.txt
List of curl flags
$ curl --help
Usage: curl [options...] <url>
--abstract-unix-socket <path> Connect via abstract Unix domain socket
--alt-svc <file name> Enable alt-svc with this cache file
--anyauth Pick any authentication method
-a, --append Append to target file when uploading
--basic Use HTTP Basic Authentication
--cacert <file> CA certificate to verify peer against
--capath <dir> CA directory to verify peer against
-E, --cert <certificate[:password]> Client certificate file and password
<?php
add_filter('acf/pre_load_reference', 'hwk_bypass_get_field_ref', 10, 3);
function hwk_bypass_get_field_ref($return, $field_name, $post_id){
if(is_int($post_id))
$return = acf_get_field($field_name, $post_id);
return $return;
}
git rev-list --objects --all | grep -f <(git verify-pack -v .git/objects/pack/*.idx| sort -k 3 -n | cut -f 1 -d " " | tail -10)
Regarding why the write operation was of poor throughput it would depend on the amount of data that would be inserted by the operation along with any deadlocks or wait events waiting for a lock it may need to take hold off as well. To that end if possible you could run those write operations to check for any deadlocks(by checking the output of the show engine innodb status) they may be causing , further you can also run profile on them to see what stage of the execution is slowing down the whole query. The explain plan will also provide us with insights on the query execution plan allowing you to make changes to improve efficiency.
https://dev.mysql.com/doc/refman/5.7/en/show-profile.html
https://dev.mysql.com/doc/refman/5.7/en/show-engine.html
https://dev.mysql.com/doc/refman/5.7/en/explain.html
>>Do we have to look at using managed Aurora cluster with read replicas, connection pooling for better throughput?
It is indeed an alternative that you can consider, your workload contains both read and writ
Alternatively, you can install it using any of the following:
docker run -it --rm -p 8888:8888 ghcr.io/validator/validator:latest
npm install vnu-jar
brew install vnu
pip install html5validator
See https://validator.github.io/validator/ for more details.
If you have docker installed, docker option is the easiest.
@onwp
onwp / Exclude groups
Created November 17, 2021 16:36 — forked from lukecav/Exclude groups
Groups to exclude in Redis object caching for LearnDash
comment
counts
plugins
learndash_reports
learndash_admin_profile
wc_session_id