Skip to content

Instantly share code, notes, and snippets.

@andytough
andytough / 0001_squarespace_right-to-left-text.html
Last active September 1, 2025 11:57
Squarespace - Right to left text
<!-- Added to the advanced section on each Arabic page to make text RTL -->
<script>
document.addEventListener('DOMContentLoaded', function() {
// Set language
document.body.setAttribute('data-lang', 'ar'); // For Arabic pages
// Set text direction
document.body.setAttribute('data-dir', 'rtl'); // For Right-to-Left text direction
});
</script>

This file is the first file in a milti-file GitHub Gist


It can be embeded independently of the other files in the Gist using the url below.


@andytough
andytough / 0001_squarespace_dropdown-menu-target.html
Last active November 14, 2025 18:53
Make top level menus with dropdowns go to the page specified when clicked on
<script>
// Make top level menus with dropdowns go to the page specified when clicked on
document.addEventListener("DOMContentLoaded", function() {
// Function to update links based on text content
function updateLinks(selector, targetText, newHref) {
var links = document.querySelectorAll(selector);
links.forEach(function(link) {
if (link.textContent.trim().toUpperCase() === targetText.toUpperCase()) {
link.href = newHref;
link.addEventListener('click', function(event) {
<!-- To allow a user to creat an account even though the create account buton is hidden, go to:
https://example.com/account/login/create
These urls access account details that are not available when the script is hiding the links to them:
https://example.com/account
https://example.com/account/digital-products
-->
<script>
/*!
* Hide Create Account Link
* Author: Michael Mashay <[email protected]>
<!-- These redirects do not help with SEO, they are just to ensure users end up on the desired page if following an link from an old single page site that used anchors instead of pages for different sections.-->
<script>
/* Redirect home page anchors from old site to relevant page on this site */
const redirects = {
'#about': '/about-me',
'#contact': '/contact',
'#service': '/services'
};
if (window.location.pathname === '/') {
@andytough
andytough / 0001_squarespace_simple-list_regex-to-collect-content.md
Last active September 1, 2025 12:01
Squarespace - Simple list - Regex to collect content

BBEdit Regex Patterns for HTML Data Extraction of Squarespace 7.1 simple list items

1. Extract H2 Text

<h2[^>]*class="list-item-content__title"[^>]*>([^<]+)</h2>

Replacement: \1

2. Extract Image Alt Text

Works if the alt text you want always contains "Logo", use:

@andytough
andytough / 001_squarespace_menus_dual-language_hide-alternative-language-menu-items_01.css
Last active November 14, 2025 18:58
Squarespace - dual language site - menus
<style>
/*Hide alternative language menu items */
/* In this example I am hiding the 5th, 6th, 7th and 8th menu items which are the alernative language pages. Adjust menu item numbers as appropriate*/
/* Target desktop menu items */
#header .header-nav-item:nth-child(5) {display:none}
#header .header-nav-item:nth-child(6) {display:none}
#header .header-nav-item:nth-child(7) {display:none}
@andytough
andytough / netwatch.sh
Created June 4, 2022 14:40 — forked from samwise4/netwatch.sh
Bash script to monitor internet outages
# return 1 if alive, 0 if dead
ping_success() {
! ping -c1 -W1 8.8.8.8 >/dev/null 2>&1
}
# Spinner taken from https://stackoverflow.com/a/12498395
spinnerindex=0
spinner='-\|/'
sleepy_spinner() {
for (( i=0; i<$(($1 * 2)); i++ ))
@andytough
andytough / modx-snippets.php
Created September 21, 2017 13:59 — forked from christianhanvey/modx-snippets.php
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@andytough
andytough / BBEdit-TextWrangler_RegEx_Cheat_Sheet.txt
Created February 14, 2017 12:12 — forked from ccstone/BBEdit-TextWrangler_RegEx_Cheat_Sheet.txt
BBEdit-TextWrangler Regular Expression Cheat-Sheet
————————————————————————————————————————————————————————————————————————————————————————————————————
BBEDIT/TEXTWRANGLER REGULAR EXPRESSION GUIDE MODIFIED 2016/02/29 17:26
————————————————————————————————————————————————————————————————————————————————————————————————————
NOTES:
The PCRE engine (Perl Compatible Regular Expressions) is what BBEdit and TextWrangler use.
Items I'm unsure of are marked '# PCRE?'. The list while fairly comprehensive is not complete.