Skip to content

Instantly share code, notes, and snippets.

@panoply
panoply / readme.md
Last active June 21, 2024 21:20
Shopify Markets Domain Parse

What is this?

Shopify offers a rather fustrating solution for localization on the front-end and developers are likely at the behest of their slop served up as the "Geo" app... We are not animals. Anyway, this is a tiny little url parser to extract subfolder prefixes and provides determination for cases where you are employing your own solution and have a webshop operating multiple domains and/or targeting different markets using subfolders.

The typings will explain in rich detail each value in the closure. If you don't use TypeScript then maybe try acting like an adult.

Usage

Usage is simple, and only configuration required is setting you main domain, by default the function assumed your main domain is using a .com extension, change this if it differs.

.m-0 {
margin: 0 !important;
}
.m-1 {
margin: 0.25rem !important;
}
.m-2 {
margin: 0.5rem !important;
@panoply
panoply / zip.ts
Created April 26, 2023 13:47
Country Code to Accurate ZIP code (postcode) maps.
export default {
AD: 'AD501',
AE: '32222',
AF: '1001',
AG: '00000',
AI: '2640',
AL: '1001',
AM: '0001',
AO: '1001',
AR: '1010',
@milancermak
milancermak / app-session.ts
Last active December 8, 2022 03:00
Custom session storage for a Shopify app in SQL using Prisma
import { PrismaClient } from '@prisma/client'
import Shopify from '@shopify/shopify-api'
import { Session } from '@shopify/shopify-api/dist/auth/session';
const prisma = new PrismaClient({ log: ['info', 'warn', 'error'] })
async function storeCallback(session: Session): Promise<boolean> {
const payload: { [key: string]: any } = { ...session }
return prisma.appSession.upsert({
create: { id: session.id, payload: payload },
@nntrn
nntrn / espn-api-list.md
Last active July 20, 2024 03:44
List of nfl api endpoints from espn

List of NFL API Endpoints

This page has been updated a lot in the past 3 years. Older revisions you might like more than this one:

  • June 2021 - list of endpoints for other sports/leagues (i.e. basketball, baseball, lacrosse, rugby)
  • August 2021 - get historical fantasy league data
  • September 2021 - list of endpoints in plain text
  • May 2023 - collapsed endpoint response examples

Additional Resources

@panoply
panoply / auth.js
Last active April 12, 2023 15:04
Lambda Shopify OAUTH
import { config } from 'dotenv'
import Shopify from 'shopify-api-node'
import cryptographer from '@brixtol/cryptographer'
config()
export const crypto = cryptographer(process.env.SHOPIFY_AUTH_SECRET)
/**
* Request Headers
const { src, dest, watch, series, parallel, lastRun } = require('gulp')
const pipeline = require('stream').pipeline
const fs = require('fs')
const sass = require('gulp-sass')
const changed = require('gulp-changed')
const imagemin = require('gulp-imagemin')
const flatten = require('gulp-flatten')
const gulpif = require('gulp-if')
const cssnano = require('gulp-cssnano')
const rename = require('gulp-rename')
@stvnrynlds
stvnrynlds / menus-api.liquid
Last active January 19, 2022 14:46
Shopify LinkList API Workaround
{%- layout none -%}
{%- assign listParams = request.path | replace: page.url, "" | remove: "/" | split: '+' -%}
{% if listParams != empty %}
{
{% for param in listParams -%}
{%- assign getList = linklists[param] -%}
{%- if getList != empty %}
"{{ param }}": [{% for level1 in getList.links %}{
"id": "{{ level1.title | handle }}-{{ forloop.index0 }}",
@jeffochoa
jeffochoa / event.js
Last active April 13, 2023 19:55
VueJs global event dispatcher
class Event {
constructor() {
this.vue = new Vue();
}
fire(event, data = null) {
this.vue.$emit(event, data);
}
listen(event, callback) {