Skip to content

Instantly share code, notes, and snippets.

View martinsoender's full-sized avatar

Martin Søndergaard martinsoender

View GitHub Profile
@martinsoender
martinsoender / responsive-image.liquid
Last active April 14, 2021 20:22
Responsive image snippet
{% comment %} Default images {% endcomment %}
{% assign PHONE_IMAGE = image %}
{% assign TABLET_IMAGE = image %}
{% assign DESKTOP_IMAGE = image %}
{% comment %} Default widths {% endcomment %}
{% assign PHONE_IMAGE_WIDTH = '640x' %}
{% assign TABLET_IMAGE_WIDTH = '768x' %}
{% assign DESKTOP_IMAGE_WIDTH = '1440x' %}
@martinsoender
martinsoender / intersection-observer.js
Created January 21, 2019 11:04
Intersection observer (react example)
// IE 11, Safari and Safari iOS safeguard
if (typeof IntersectionObserver === 'undefined') {
setActive(true)
return
}
const signupButton = document.querySelector('.banner .button')
const observer = new IntersectionObserver(entry => {
entry = entry[0]
@martinsoender
martinsoender / splitit-checkout.js
Created June 25, 2019 10:43
Show Splitit instalments on Shopify checkout
// Splitit sidebar
if(location.href.indexOf('/checkouts/') >= 0) {
// JQuery injection
var ccJqueryScript = document.createElement('script');
ccJqueryScript.setAttribute('type', 'text/javascript');
ccJqueryScript.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js');
document.getElementsByTagName('head')[0].appendChild(ccJqueryScript);
// Checkout js injection
var ccScript = document.createElement('script');
@martinsoender
martinsoender / splitit-checkout.js
Created July 12, 2019 11:15
Split it checkout
// Splitit
if(location.href.indexOf('/checkouts/') >= 0) {
// Splitit styles injection
const splititStyles = document.createElement('link');
splititStyles.setAttribute('rel', 'stylesheet');
splititStyles.setAttribute('src', '//cdn.shopify.com/s/files/1/0027/5536/2879/files/splitit-styles.css?56959');
document.getElementsByTagName('head')[0].appendChild(splititStyles);
// JQuery injection
var ccJqueryScript = document.createElement('script');
@martinsoender
martinsoender / vbtrax-thank-you-pixel.js
Created August 7, 2019 08:12
Thank You pixel for vbtrax tracking
<script type="text/javascript" src="//cdn.vbtrax.com/javascripts/va.js"></script>
<script>
VA.remoteLoad({
whiteLabel: { id: 8, siteId: 1559, domain: 'vbtrax.com' },
conversion: true,
conversionData: {
step: 'sale', // conversion name
revenue: '', // Revenue share
orderTotal: '{{ checkout.total_price | money_without_currency }}',
order: '{{ checkout.order_number }}' // order number
@martinsoender
martinsoender / gist:d6158778afcb24f3d052f7c415bdd838
Created December 16, 2019 14:59
Webgains landing page script
<!-- webgains tracking -->
<script>
(function(w,e,b,g,a,i,n,s){w['ITCLKOBJ']=a;w[a]=w[a]||function(){(w[a].q=w[a].q||[]).push(arguments)},w[a].l=1*new Date();i=e.createElement(b),n=e.getElementsByTagName(b)[0];i.async=1;i.src=g;n.parentNode.insertBefore(i,n)})(window,document,'script','https://analytics.webgains.io/clk.min.js','ITCLKQ');
ITCLKQ('set', 'internal.api', true);
ITCLKQ('set', 'internal.cookie', true);
ITCLKQ('click');
</script>
@martinsoender
martinsoender / setup.sh
Last active May 1, 2024 02:04
Vault, Nomad and Consul setup
dnf update -y
dnf install -y curl jq unzip
export CLUSTER_DC=fra1
export CLUSTER_PRIMARY_DC=fra1
export CLUSTER_PRIVATE_IPS=1.1.2.2,2.2.3.3,3.3.4.4
export CLUSTER_PUBLIC_IPS=1.1.1.1,2.2.2.2,3.3.3.3
export CLUSTER_SIZE=$(echo $CLUSTER_PUBLIC_IPS | jq -Rc 'split(",") | length')
export DOCKER_USERNAME=""
$container_width: 90% !default;
$width: 96% !default;
$gutter: 4% !default;
$breakpoint-small: 33.75em !default; // 540px
$breakpoint-med: 45em !default; // 720px
$breakpoint-large: 60em !default; // 960px
.hidden-sm {
display: none;
}
@martinsoender
martinsoender / README.md
Created June 6, 2021 19:18 — forked from ridem/README.md
Download a Shopify store's assets used in your theme

It's hard to migrate section themes that rely heavily on images. This bit of code helps you download all the CDN assets of your theme.

  1. Create a cdn_assets folder
  2. Create the download_assets.js file at the root of your project
  3. Edit the download_assets.js file to match the path to your settings_data.json (line 3)
  4. Edit the download_assets.js file to set the "CDN code" of your store. Each file that you upload from /admin/settings/files gets uploaded with the following format: https://cdn.shopify.com/s/files/1/YOUR_CDN_CODE/files/YOURFILE. The format of the code is /\d{4}\/\d{4}/ (four digits, a forward slash, and four digits)
@martinsoender
martinsoender / shopifyCartQueue.js
Created July 5, 2021 18:40 — forked from davidemaser/shopifyCartQueue.js
Using the Shopify queue to add items to the cart
Shopify.queue = [];
Shopify.moveAlong = function() {
if (Shopify.queue.length) {
var request = Shopify.queue.shift();
Shopify.addItem(request.variantId, request.quantity, request.properties, Shopify.moveAlong);
}
else {
document.location.href = '/cart';
}
};