Skip to content

Instantly share code, notes, and snippets.

@hu0p
hu0p / functions.php
Created January 26, 2018 17:16
Adding search to Wordpress Navigation
add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );
function add_search_box( $items, $args ) {
$items .= '<li class="primary-nav_searchbar">' . get_search_form( false ) . '</li>';
return $items;
}
@hu0p
hu0p / snippet.js
Created August 14, 2019 13:13
Disable navigation for all clicks on a page. This is useful for testing analytics tracking. Copy/paste in JS console
Array.from(document.querySelectorAll('a')).map( el => el.addEventListener("click", e => e.preventDefault()))
@hu0p
hu0p / ttfb.sh
Created February 14, 2020 00:13
Check Time to First Byte for a list of sites
#!/bin/bash
# file: ttfb.sh
# check the TTFB for a list of sites
# add list of sites here
declare -a sites=()
# test results will be output here
rm -rf $HOME/Desktop/TTFB-`date +"%m-%d-%Y"`.csv
echo "TTFB Test on: `date +"%m-%d-%Y %H:%M"`\n URL, Connect, TTFB, Total Time" | cat >> $HOME/Desktop/TTFB-`date +"%m-%d-%Y"`.csv
@hu0p
hu0p / downloadImages.js
Created March 11, 2021 17:28
A utility function to bulk download images on a page
function downloadImages(selector) {
function saveImg(blob, fileName) {
var a = document.createElement("a")
document.body.appendChild(a)
a.style = "display: none"
var url = window.URL.createObjectURL(blob)
a.href = url
a.download = fileName
a.click()