Skip to content

Instantly share code, notes, and snippets.

View Acen's full-sized avatar
💸

Zac Acen

💸
  • Auckland, New Zealand
View GitHub Profile
@Acen
Acen / UnparsedURL.php
Last active December 7, 2020 02:17
Facebook PHP Manual Unshim
<?php
/**
* Sourced from https://gist.github.com/Ellrion/f51ba0d40ae1d62eeae44fd1adf7b704
*/
class UnparsedURL
{
private $parts;
public function __construct(array $parts){
$this->parts = $parts;
@Acen
Acen / SearchForNotSomething.json
Created August 13, 2021 03:18
Kibana - Searching for wildcard values with the query DSL
{
"query": {
"bool": {
"must_not": {
"wildcard": {
"error.string": {
"value": "Some sort of value*"
}
}
}
query ($uri: String!) {
wpPage(uri: { eq: $uri }) {
title
content
uri
slug
isFrontPage
wpFields {
homepage {
fieldGroupName
@Acen
Acen / HeroSections.jsx
Created April 6, 2022 01:53
i cri err tim
import React, {useEffect, useRef, useState} from "react"
import {GatsbyImage, getImage} from "gatsby-plugin-image"
import {classNames} from "../../../../utils"
import Clamp from "react-multiline-clamp"
import parse from 'html-react-parser'
import {MinusSmIcon, PlusSmIcon} from "@heroicons/react/solid";
export const Section = ({data, darken, side}) => {
const image = getImage(data.image?.localFile) ?? null
const bgClass = darken ? `bg-white` : `bg-white`
@Acen
Acen / sidebar.liquid
Created May 2, 2022 02:13
Shopify Blog list by date (requires Luxon JS)
{%- when 'by_year' -%}
<div class="sf-block-aside">
<h3 class="sf-aside-title">{{ b_s.title }}</h3>
<div class="sf-aside-content">
<ul class="sf-list-row" id="year-tags"></ul>
</div>
</div>
<script type="text/javascript">
const articles = {};
{% for article in blog.articles limit: 9999 %}
@Acen
Acen / spr-reviews.liquid
Created May 4, 2022 23:46
Shopify Review - on click go to tab & scroll into view
{% if block.type == 'reviews' %}
<script>
document.querySelector('.spr-starrating').classList.add('cursor-pointer')
document.querySelector(`div.spr-summary-starrating`).onclick = function (e) {
Array.from(document.querySelectorAll('.sf-tab-header')).find(el => el.textContent.includes("Product reviews")).click();
setTimeout(function(){
document.querySelector('div[data-id="{{ product.id }}"]').scrollIntoView();
}, 200)
}
</script>
@Acen
Acen / URLRequestRewrite.ts
Created May 31, 2022 23:04
Rewrite the requested URL
addEventListener('fetch', function (event) {
event.respondWith(handleRequest(event.request));
});
const pageType = (path: string): string|false => {
switch(path)
{
case 'method':
return 'pages';
case 'book-a-consultation':
@Acen
Acen / updateImages.js
Created June 27, 2022 02:40
Write to a json file, all images you have on your cloudflare images account
import fetch, {Headers} from 'node-fetch';
import fs from 'fs';
const headers = new Headers({
"Authorization": "{your bearer token}{"
});
const requestOptions = {
method: `GET`,
headers: headers,
redirect: `follow`,
@Acen
Acen / response.json
Created July 25, 2022 22:36
Graphql response
{
"errors": [
{
"debugMessage": "Expected a value of type \"MenuLocationEnum\" but received: footer_1",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
import fs from 'fs';
import axios from 'axios';
import axiosThrottle from 'axios-request-throttle';
axiosThrottle.use(axios, {requestsPerSecond: 2});
const domain = 'https://blah:blah@store.myshopify.com';
const version = '2022-07'