Skip to content

Instantly share code, notes, and snippets.

View JoeyBurzynski's full-sized avatar
💭
Hacking away on @EdgeSEO tools.

Joey Burzynski JoeyBurzynski

💭
Hacking away on @EdgeSEO tools.
View GitHub Profile
@JoeyBurzynski
JoeyBurzynski / globalErrorHandler.js
Created September 15, 2023 05:05
JavaScript SEO: Debugging Googlebot Crawling & Rendering Issues | Global JavaScript Error Handler [onerror]
// Here's an example that shows how to log JavaScript errors that are logged in the global onerror handler.
// Note that some types of JavaScript errors, such as a parse error, cannot be logged with this method.
window.addEventListener('error', function(e) {
var errorText = [
e.message,
'URL: ' + e.filename,
'Line: ' + e.lineno + ', Column: ' + e.colno,
'Stack: ' + (e.error && e.error.stack || '(no stack trace)')
].join('\n');
@JoeyBurzynski
JoeyBurzynski / cloudflare-ASN-bots.md
Created August 25, 2023 16:50
Cloudflare Rules: Allow Good Bots by ASN

Rule Name: Allow Good Bots (AS15169/Google LLC, AS8075/Microsoft Corporation, AS714/Apple Inc., AS32934/Facebook, Inc., AS17012/PayPal, Inc., AS5091/Stripe, Inc.) Cloudflare WAF Rule: Allow Good Bots: (cf.client.bot and ip.geoip.asnum in {15169 8075 714 32934 17012 5091})

Ex: https://ipinfo.io/AS15169 - Google

WAF Rules

  • Cloudflare offers 5 WAF rules for free accounts.
  • Create Firewall Rule and then paste them in the Edit Expression box.
// "cf-connecting-ip" should contain true client IP when Cloudflare managed
// transform rule ("Add visitor location headers") is enabled.
// See: https://share.marketkarma.com/cloudflare-managed-transform-add-geoip-http-headers.png
const HTTP_OK = 200;
const HTTP_INTERNAL_SERVER_ERROR = 500;
/**
* Filters out headers that are not allowed, sorts headers alphabetically,
* and converts headers to JSON.
@JoeyBurzynski
JoeyBurzynski / cloudflare-worker-ip-to-real-client-ip-address.js
Last active May 11, 2024 13:58
Resolving Cloudflare Worker IP Issues [Replace Cloudflare Worker IP with Real Client IP in X-Forwarded-For HTTP Header]
// Cloudflare Worker Sandbox Examples
// Learning here, not intended for production use.
// https://cloudflareworkers.com/#6bc84bcddcf251074b41adba568a9284:https://tutorial.cloudflareworkers.com
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
})
/**
@JoeyBurzynski
JoeyBurzynski / i-design-with-code.markdown
Created March 27, 2023 11:41
I DESIGN WITH CODE ❤
@JoeyBurzynski
JoeyBurzynski / renovate.json
Created February 15, 2023 09:58
Renovate Configuration
{
"extends": [
"config:base",
":pinAllExceptPeerDependencies",
"group:nodeJs",
"group:allApollographql",
"group:codemirror",
"group:fortawesome",
"group:fusionjs",
"group:glimmer",
@JoeyBurzynski
JoeyBurzynski / sample-hreflang-annotations-in-html-markup.html
Created February 6, 2023 08:07
Sample Hreflang Annotations via HTML Markup
<!-- x-default: default when no language matches -->
<link rel="alternate" hreflang="x-default" href="https://www.mordorintelligence.com"/>
<!-- English (en) -->
<link rel="alternate" hreflang="en" href="https://www.mordorintelligence.com"/>
<!-- Arabic: macrolanguage (ar) -->
<link rel="alternate" hreflang="ar" href="https://www.mordorintelligence.sa"/>
<!-- Chinese (zh) -->
@JoeyBurzynski
JoeyBurzynski / sample-hreflang-annotations-in-xml-sitemap.xml
Last active February 6, 2023 07:59
Sample hreflang annotations via XML sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://www.mordorintelligence.sa</loc>
<!-- Arabic: macrolanguage (ar) -->
<xhtml:link
rel="alternate"
hreflang="ar"
href="https://www.mordorintelligence.sa"/>
@JoeyBurzynski
JoeyBurzynski / globalErrorHandler.js
Created February 1, 2023 20:38
JavaScript: Global onerror handler
window.addEventListener('error', function(e) {
var errorText = [
e.message,
'URL: ' + e.filename,
'Line: ' + e.lineno + ', Column: ' + e.colno,
'Stack: ' + (e.error && e.error.stack || '(no stack trace)')
].join('\n');
// Example: log errors as visual output into the host page.
// Note: you probably don't want to show such errors to users, or