Skip to content

Instantly share code, notes, and snippets.

@bheyde
bheyde / coupon_batch_report.html
Created December 5, 2016 20:01
Coupon Batch Report
<mvt:foreach iterator="order" array="admin_order:orders">
<mvt:foreach iterator="coupon" array="order:coupons">
<mvt:comment>
:code
:coupon_id
:order_id
:total (discount applied to order)
@tessguefen
tessguefen / example.xml
Created December 6, 2016 21:38
Order report with dynamic headers (product codes).
<mvt:assign name="l.comma" value="asciichar('44')" />
<mvt:assign name="l.linebreak" value="asciichar('10')" />
<mvt:foreach iterator="order" array="admin_order:orders">
<mvt:foreach iterator="group" array="order:groups">
<mvt:comment> <!-- Build Dynamic Array --> </mvt:comment>
<mvt:if expr="miva_array_search( l.settings:products, 0, l.item, 'l.item:code EQ l.settings:group:code' )">
<mvt:assign name="l.item:quantity" value="l.item:quantity + l.settings:group:quantity" />
<mvt:assign name="l.item:subtotal" value="l.item:subtotal + l.settings:group:subtotal" />
<mvt:else>
@tessguefen
tessguefen / critical_css.xml
Created October 17, 2017 22:14
Add critical css files to /critical_css/
<mvt:if expr="g.request_cookies:critical_css NE 1 AND g.Screen CIN '|SFNT|CTGY|PLST|PROD|'">
<script>!function(a){"use strict";var b=function(b,c,d){function j(a){return e.body?a():void setTimeout(function(){j(a)})}function l(){f.addEventListener&&f.removeEventListener("load",l),f.media=d||"all"}var g,e=a.document,f=e.createElement("link");if(c)g=c;else{var h=(e.body||e.getElementsByTagName("head")[0]).childNodes;g=h[h.length-1]}var i=e.styleSheets;f.rel="stylesheet",f.href=b,f.media="only x",j(function(){g.parentNode.insertBefore(f,c?g:g.nextSibling)});var k=function(a){for(var b=f.href,c=i.length;c--;)if(i[c].href===b)return a();setTimeout(function(){k(a)})};return f.addEventListener&&f.addEventListener("load",l),f.onloadcssdefined=k,k(l),f};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
</script>
<noscript><link href="&mvt:global:theme_path;/css/all.min.css" rel="stylesheet" type="text/css" defer="defer"></noscript>
<mvt:if expr="g.Screen EQ 'SFNT'">
@ncochard
ncochard / babel-webpack.md
Last active April 2, 2025 18:22
The correct way to compile ES6 using babel...

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
@Gazzell
Gazzell / pre-commit
Created January 31, 2018 09:09
pre-commit. Only commit if pass tests and there are not leftovers (.only and .skip)
branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
echo "Direct commits to the branch master are not allowed"
exit 1
fi
testLeftOvers=`git diff --staged test/**/* | grep '^+' | grep '.only\|.skip'`
if [ -n "$testLeftOvers" ]; then
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, 'src/index.js'),
plugins: [
new webpack.HashedModuleIdsPlugin(), // so that file hashes don't change unexpectedly
],
output: {
path: path.resolve(__dirname, 'dist'),
@franktopel
franktopel / HTMLBaseElement.md
Last active September 27, 2024 18:22
HTMLBaseElement class solving the problem of connectedCallback being called before children are parsed

There is a huge practical problem with web components spec v1:

In certain cases connectedCallback is being called when the element's child nodes are not yet available.

This makes web components dysfunctional in those cases where they rely on their children for setup.

See WICG/webcomponents#551 for reference.

To solve this, we have created a HTMLBaseElement class in our team which serves as the new class to extend autonomous custom elements from.

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active August 28, 2025 15:49
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@tessguefen
tessguefen / Code to call template.xml
Created May 8, 2019 03:11
Components & Layouts - v1.012
<mvt:assign name="l.settings:layout_code" value="'sfnt_layout'" />
<mvt:item name="readytheme" param="contentsection( 'components_and_layouts' )" />
<mvt:eval expr="l.settings:final_output" />
@andrew-serrano
andrew-serrano / miva_order_template_email.xml
Last active April 28, 2020 17:44
Manually trigger a preexisting email
<mvt:comment>
Overrides if needed
</mvt:comment>
<mvt:assign name="l.run:override_from" value="''" />
<mvt:assign name="l.run:override_reply_to" value="''" />
<mvt:assign name="l.run:override_to" value="''" />
<mvt:assign name="l.run:override_cc" value="''" />
<mvt:assign name="l.run:override_bcc" value="''" />
<mvt:assign name="l.run:override_subject" value="''" />