Skip to content

Instantly share code, notes, and snippets.

View andymagill's full-sized avatar
👀
Looking for Opportunities

Andrew Magill andymagill

👀
Looking for Opportunities
View GitHub Profile
@andymagill
andymagill / jotform-extract.js
Created February 20, 2025 17:53
Extract Product data from Jotform
function extractProductData() {
const products = [];
const productItems = document.querySelectorAll('.form-product-item');
productItems.forEach(item => {
const productId = item.getAttribute('pid');
const name = item.querySelector('.form-product-name')?.textContent?.trim() || ''; // Adjust selector. Use ? to avoid errors if element is missing.
const description = item.querySelector('.form-product-description')?.textContent?.trim() || ''; // Adjust selector.
const price = item.querySelector('.form-product-detail span span')?.textContent?.trim() || ''; // Adjust selector.
const image = item.querySelector('.image_area img')?.src || ''; // Adjust selector. Assumes image is in an <img> tag.
@andymagill
andymagill / marketo-form-overrides.scss
Last active December 23, 2024 08:58
Marketo Form Overrides
// marketo form overrides
// from https://jennamolby.com/how-to-create-responsive-marketo-forms/
.mktoForm {
&,
.mktoLabel ,
.mktoHtmlText ,
.mktoFormRow,
@andymagill
andymagill / setup.cjs
Created August 27, 2024 01:37
Create Project Skeleton in NODE.js
const fs = require('fs');
const path = require('path');
const directories = [
'src/lib/components',
'src/lib/stores',
'src/lib/utils',
'src/routes/history',
'src/routes/reports',
'static'
@andymagill
andymagill / middleware.ts
Created June 14, 2024 13:04
Next.JS TypeScript CSP middleware - broken
import { NextRequest, NextResponse } from 'next/server';
export function middleware(request: NextRequest) {
const nonce = Buffer.from(crypto.randomUUID()).toString('base64');
const cspHeader = `
default-src 'self';
script-src 'self' 'nonce-${nonce}' 'strict-dynamic';
style-src 'self' 'nonce-${nonce}';
img-src 'self' blob: data:;
font-src 'self';
@andymagill
andymagill / Taleo Injector
Created February 8, 2024 14:08
For a consistent navigation and branding, this script loads content, styles and dependencies from one website and injects them into a 3rd party service platform.
// Taleo brandfile external JS
class Injector {
site_url;
style_paths;
script_paths;
script_paths_loaded;
scripts_inited;
@andymagill
andymagill / Example JS class
Last active May 24, 2023 20:23
Simple JS class for copiepasta
// Example Class
class Example {
// properties
// methods
constructor() {
@andymagill
andymagill / .htaccess
Last active December 11, 2022 08:46
HTACCESS rewrite rule not working on SiteGround
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# don't rewrite anything in docs folder to wordpress
RewriteCond %{REQUEST_URI} !^/(docs/*) [NC]
// remove terrible experimental layout support
remove_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
function understrap_experimental_layout( $metadata ) {
if ( !empty($metadata['supports']['__experimentalLayout'])) {
$metadata['supports']['__experimentalLayout'] = false;
}
return $metadata;
}
add_filter( 'block_type_metadata', 'understrap_experimental_layout', 10, 1 );
sudo chown -vR webuser /not/webuser/