This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Expose variable when launched from Launchpad | |
if (sap.n) { | |
var attr; // optional (fill with the name of the window attribute you want, eg. 'APPxxx') | |
var exposed = (attr) ? window[attr] = {} | |
: window; | |
var regex = /var (\w*) \= new /gm; // regexp to determine all variable names (and a few wrong ones) | |
var funcCode = arguments.callee + ''; | |
var match; | |
while ((match = regex.exec(funcCode)) !== null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://stackoverflow.com/questions/40603913/search-recursively-for-value-in-object-by-property-name | |
function findVal(obj, key) { | |
var seen = new Set; | |
var active = [obj]; | |
while (active.length) { | |
var new_active = []; | |
var found = []; | |
for (var i=0 ; i<active.length ; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: https://stackoverflow.com/questions/24586110/resolve-promises-one-after-another-i-e-in-sequence/31070150#31070150 | |
// https://decembersoft.com/posts/promises-in-serial-with-array-reduce/ | |
/* | |
* Serialize promises (or rather tasks because once created, a Promise starts executing immedialtely | |
*/ | |
const promiseSerializer = (tasks: Array<()=>Promise<any>>) => { | |
return tasks.reduce((promiseChain: Promise<any>, currentTask: ()=>Promise<any>) => { | |
return promiseChain.then(chainResults => | |
currentTask().then(currentResult => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// (c) Copyright 2016 Caroline Schnapp. All Rights Reserved. Contact: [email protected] | |
// See https://docs.shopify.com/themes/customization/navigation/link-product-options-in-menus | |
var Shopify = Shopify || {}; | |
Shopify.optionsMap = {}; | |
Shopify.updateOptionsInSelector = function(selectorIndex) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: https://coderwall.com/p/euwpig/a-better-git-log | |
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
Remove sold-out variants. | |
Only works for products that have one option. | |
It won't work with products that have two or three options, like Size and Color. | |
See: https://docs.myshopify.io/themes/customization/products/hide-variants-that-are-sold-out | |
{% endcomment %} | |
{% if product.options.size == 1 %} | |
<script> | |
var $addToCartForm = $('form[action="/cart/add"]'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
Disable sold-out variants. | |
Only works for products that have one option. | |
It won't work with products that have two or three options, like Size and Color. | |
See: https://docs.myshopify.io/themes/customization/products/hide-variants-that-are-sold-out | |
{% endcomment %} | |
{% if product.options.size == 1 %} | |
<script> | |
var $addToCartForm = $('form[action="/cart/add"]'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Adapted from: https://weblogs.asp.net/dixin/use-fiddler-with-node-js | |
/* Usage: | |
import { Fiddler } from './../src/helpers/fiddler'; | |
... | |
Fiddler.proxyRequests(); | |
*/ | |
import * as url from 'url'; | |
import * as http from 'http'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- VIEW | |
Trick to download document silently (without opening a new tab) --> | |
<iframe *ngIf="hiddenUrl" class="hidden" [src]="hiddenUrl"> | |
</iframe> | |
<!-- CONTROLLER --> | |
public hiddenUrl: SafeUrl; | |
... |