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 / ImageAsInvisibleButton.lua
Created April 25, 2023 02:19
some image as button handling - may not be valid due to missing end etc - pasted/cut from larger code blocks
for k, v in ipairs(self.tabs) do
if(v.image ~= nil) then
GUI:Image(v.image.path, v.image.width, v.image.height)
if(v.tooltip ~= nil) then
if(GUI:IsItemHovered()) then
GUI:SetTooltip(v.tooltip)
end
end
GUI:SetCursorPos(0, 0)
GUI:BeginChild('##<replace me>' .. v.name .. 'Image', v.image.width, v.image.height, false, GUI.WindowFlags_NoResize)
self.options = {
priorities = {
low = {
minimumTickLength = 1000,
},
medium = {
minimumTickLength = 500,
},
high = {
@Acen
Acen / shopify_products_articles.js
Last active December 28, 2022 22:38
Blog type of "testimonials" -> has articles with a metafield that links to a product ID. Builds a Map of products that have an articles array, with a list of articles that have that metafield relationship. Does 2 requests. One to get a list of the blog posts, then a batch request for products (using the "(id:<number>) OR (id:<number>)") request …
const authenticationHeaders = new Headers();
authenticationHeaders.append("Content-Type", "application/json");
authenticationHeaders.append("X-Shopify-Storefront-Access-Token", <access-token-here>);
const articleGraphql = JSON.stringify({
query: "query {\n blog(handle: \"testimonials\"){\n articles(first: 100){\n edges{\n node{\n id\n title\n url\n metafield(namespace: \"testimonial\", key: \"product\"){\n value }\n }\n }\n }\n }\n}",
variables: {}
});
const articleRequest = {
@Acen
Acen / requests-FullScan.ts
Created August 29, 2022 22:33
CF Request
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;
}
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 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": [
{
@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 / 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 / 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 / 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 %}