Skip to content

Instantly share code, notes, and snippets.

View RAAbbott's full-sized avatar

Alex Abbott RAAbbott

View GitHub Profile
@RAAbbott
RAAbbott / run.graphql
Created May 30, 2024 05:16
Quantity Limits Cart Validation - Shopify Functions
query RunInput {
cart {
lines {
quantity
merchandise {
__typename
... on ProductVariant {
product {
metafield(namespace: "quantity_limits", key: "limit") {
value
@RAAbbott
RAAbbott / index.jsx
Created April 17, 2023 03:36
Code for `index.jsx` file for your Checkout UI Extension used in my video here: https://youtu.be/FDLoz__VKVk
import React from "react";
import {
render,
BlockStack,
InlineStack,
Text,
View,
Image,
Heading,
useAppMetafields,
@RAAbbott
RAAbbott / index.js
Created December 1, 2022 04:19
Code for Build A Shopify App series Part 2 - Working with the API
const IMAGES = [
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552461/BYOA/709618-0320_e20ckp.jpg",
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552412/BYOA/22-02-2021_MO_112247-NAVY_1_1_cseojc.webp",
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552374/BYOA/ipad-mini-select-202109_FMT_WHH_cb84pl.jpg",
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552374/BYOA/MPLD3_VW_34FR_watch-45-alum-starlight-nc-8s_VW_34FR_WF_CO_dgkcic.jpg",
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552374/BYOA/MQDY3ref_VW_34FR_watch-49-titanium-ultra_VW_34FR_WF_CO_watch-face-49-alpine-ultra_VW_34FR_WF_CO_il7bdy.jpg",
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552374/BYOA/buoy_wear_floating_hat-10_rqeipt.jpg",
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552374/BYOA/drinkcupsocks_product2_1_1_grande_autj8d.webp",
"https://res.cloudinary.com/dci7ukl75/image/upload/v1668552374/BYOA/20211202-141138_FGS169_Gloves_Hawk_Black_front_iri8qc.webp",
];
@RAAbbott
RAAbbott / .deps...npm...@openzeppelin...contracts...access...Ownable.sol
Created October 20, 2021 00:55
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.9+commit.e5eed63a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
@RAAbbott
RAAbbott / .deps...npm...@openzeppelin...contracts...access...Ownable.sol
Created October 20, 2021 00:55
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.9+commit.e5eed63a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
@RAAbbott
RAAbbott / index.js
Created August 27, 2021 21:08
Code for "Build A Shopify App - Part 1 (Polaris)"
import {
Page,
Layout,
Card,
Tag,
Stack,
TextField,
Button,
} from "@shopify/polaris";
@RAAbbott
RAAbbott / rotate.js
Last active April 26, 2021 19:14
Rotate a 2d n x n matrix IN PLACE
/**
* @param {number[][]} matrix
* @return {void} Do not return anything, modify matrix in-place instead.
*/
// Faster than 80.52% of submissions, less than 40.77% memory usage than other submissions
const rotate = function(matrix) {
const len = matrix.length
@RAAbbott
RAAbbott / sortBySubstring.js
Last active December 16, 2020 19:06
Sort array against a substring. Used for sorting collection by a search term to show most relevant searches first
function sortBySubstring (array, term) {
const func = (a,b) => {
const subStringA = a.substr(0,term.length)
const subStringB = b.substr(0,term.length)
return subStringA.localeCompare(term) - subStringB.localeCompare(term) === 0 ? 1 : -1
}
return array.sort(func)
}