Skip to content

Instantly share code, notes, and snippets.

View stefanmm's full-sized avatar
🏠
Working from home

Stefan stefanmm

🏠
Working from home
View GitHub Profile
@stefanmm
stefanmm / wp-auto-open-accordion.js
Created August 8, 2023 23:12
WP 6.3 - Open "Details" block automatically on page load based on URL hash
// First, set a class name inside the "Details" accordion block (because we do not have ability to set the ID)
// If multiple elements with the same class name are detected, the first one will be triggered
// Append that class name after the page URL, like so: site.domain/page/#classname
if(window.location.hash) {
var hash = window.location.hash;
var el = document.getElementsByClassName(hash.slice(1))[0];
if(!el.hasAttribute('open')){
el.setAttribute('open', '');
@stefanmm
stefanmm / functions.php
Created December 10, 2023 00:05
Fix "Does not use passive listeners to improve scrolling performance" for WP comment-reply.min.js
function sm_fix_comment_reply_passive_listeners(){
// deregister inside wp_footer (and not inside init) in case other plugins try to register comment-reply after init
wp_deregister_script( 'comment-reply' );
// Do not load JS if not needed
if ( is_single() && comments_open() ) {
?>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Function checks if a given script is already loaded
@stefanmm
stefanmm / usb_reset.sh
Last active June 28, 2024 13:33 — forked from erwin/turn-off-device.sh
Fix: USB keyboard not working in Linux after sleep/suspend
#!/bin/bash
# Thanks to:
# https://gist.github.com/erwin/a66a4c3f8a5d940ab6c434b48568ff39
# https://bbs.archlinux.org/viewtopic.php?pid=1956897#p1956897
# HOW TO:
# 1) Copy this file to /usr/local/bin/usb_reset.sh
# 2) make it executable: sudo chmod +x /usr/local/bin/usb_reset.sh
# 3) Create new service: sudo nano /etc/systemd/system/usb_reset.service