Skip to content

Instantly share code, notes, and snippets.

Avatar
💸

Zac Acen

💸
  • Auckland, New Zealand
View GitHub Profile
View requests-FullScan.ts
import type {Validator} from "remix-validated-form";
import {withZod} from "@remix-validated-form/with-zod";
import {z} from "zod";
import {address, UserAgent} from "~/requests/client/config";
interface IRuntimeForm {
[key: string]: any;
}
View somethingsomething_shopify_api.js
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'
@Acen
Acen / response.json
Created Jul 25, 2022
Graphql response
View response.json
{
"errors": [
{
"debugMessage": "Expected a value of type \"MenuLocationEnum\" but received: footer_1",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
@Acen
Acen / updateImages.js
Created Jun 27, 2022
Write to a json file, all images you have on your cloudflare images account
View updateImages.js
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 / URLRequestRewrite.ts
Created May 31, 2022
Rewrite the requested URL
View URLRequestRewrite.ts
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 / spr-reviews.liquid
Created May 4, 2022
Shopify Review - on click go to tab & scroll into view
View spr-reviews.liquid
{% 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 / sidebar.liquid
Created May 2, 2022
Shopify Blog list by date (requires Luxon JS)
View sidebar.liquid
{%- 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 %}
View HeroSections.jsx
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`
View pageQuery.graphql
query ($uri: String!) {
wpPage(uri: { eq: $uri }) {
title
content
uri
slug
isFrontPage
wpFields {
homepage {
fieldGroupName
@Acen
Acen / SearchForNotSomething.json
Created Aug 13, 2021
Kibana - Searching for wildcard values with the query DSL
View SearchForNotSomething.json
{
"query": {
"bool": {
"must_not": {
"wildcard": {
"error.string": {
"value": "Some sort of value*"
}
}
}