Skip to content

Instantly share code, notes, and snippets.


Benjamin Sehl benjaminsehl

View GitHub Profile
benjaminsehl / shop-pay-unsub-check.sql
Last active Feb 9, 2021
Checking for Unsubs via Shop Pay
View shop-pay-unsub-check.sql
-- A SQL query to find customers that may have unintentionally unsubscribed from their e-mail.
-- This is related to a Shop Pay bug where if customers come from a Headless shop, they're unsubscribed.
SELECT T1.metadata__email "Email", C.accepts_marketing "Subscribed", C.accepts_marketing_updated_at "Unsubscribe Date", T2.created_at "Transaction Date", O.created_at "Order Date"
FROM ca_ecomm.transactions__receipt__charges__data T1
LEFT JOIN ca_ecomm.transactions T2
T1.metadata__order_transaction_id::VARCHAR =
LEFT JOIN ca_ecomm.customers C
benjaminsehl / resubsribe-shop-pay.js
Created Feb 9, 2021
Function to resubscribe people who were incorrectly unsubscribed via Shop Pay & Headless.
View resubsribe-shop-pay.js
A Webook to check if customers were unintentionally unsubscribed, and then re-subscribed them.
Shopify Customers can be unsubscribed if they checkout through Shop Pay. While not 100% sure, believe it's only limited to orders that happen from a Headless channel.
You will need to signup for Autocode for this below code to work.
To find all the customers that were affected, you can use this gist:
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
benjaminsehl / cloudSettings
Last active Aug 28, 2020
VS Code Settings
View cloudSettings
benjaminsehl / formatters.js
Created Aug 19, 2020
Typography Formatting Function
View formatters.js
const formatters = [
{ pattern: /'/g, replacement: '’' }, // Replace straight quotes with smart quotes
// { pattern: /\s([^\s<]+)\s*$/g, replacement: '\u00A0$1' }, // Add non breaking spaces before the last word
const formatted = (a) =>
(a, f) => a?.toString().replace(f.pattern, f.replacement),
benjaminsehl / scripts
Last active Aug 6, 2020
Zsh alias to print the scripts from a package.json file
View scripts
alias scripts="pcregrep -M '(?<=scripts\":\s)(.|\n)*?(?=\n\s*},)' package.json"
benjaminsehl / shopify-cleanslate.css
Last active Jun 22, 2020
Shopify Dynamic Checkout Buttons
View shopify-cleanslate.css
Shopify Dynamic Checkout Buttons on Cart Page
Examples of where broken:
On Safari it breaks and wraps (see screenshot), in Chrome, since there are just two active, the buttons don’t take up the full space.
benjaminsehl / handleize.js
Created Apr 22, 2020
Turn a string into a slug
View handleize.js
export function handleize (str) {
return str
.replace(/[^\w\u00C0-\u024f]+/g, '-')
.replace(/^-+|-+$/g, '')
benjaminsehl / adopt.js
Last active Mar 20, 2020
An ES6 function for fixing Orphans
View adopt.js
export function adopt(str) {
return str.replace(/\s([^\s<]+)\s*$/g, '\u00A0$1');
View original-orders.js
const shopifyStores = [
{name: 'Canada Web', tablePrefix: 'ca_ecomm'},
{name: 'Canada Retail', tablePrefix: 'ca_retail'},
{name: 'Intl. Web', tablePrefix: 'us_ecomm'},
{name: 'Intl. Retail', tablePrefix: 'us_retail'}
let KotnEmailsArray = [
benjaminsehl / .eslintrc
Created Aug 14, 2019 — forked from cletusw/.eslintrc
My default ESLint configs
View .eslintrc
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names