Skip to content

Instantly share code, notes, and snippets.

@tobiasdalhof
tobiasdalhof / .devcontainer.json
Created January 5, 2021 07:35
vscode go devcontainer example
{
"name": "Go",
"build": {
"dockerfile": "./Dockerfile",
"context": "./",
"target": "dev"
},
"forwardPorts": [3000],
@tobiasdalhof
tobiasdalhof / App.vue
Created September 4, 2020 12:27
Global v-snackbar with composition API
<template>
<v-app id="app">
<app-snackbar></app-snackbar>
</v-app>
</template>
<script lang="ts">
import { defineComponent, computed } from '@vue/composition-api'
import AppSnackbar from '@/components/AppSnackbar'
@tobiasdalhof
tobiasdalhof / useWindowSize.ts
Last active March 22, 2020 15:48
Vue Composition API function - window size
import { Ref, onMounted, onUnmounted, reactive, toRefs } from '@vue/composition-api'
interface WindowSize {
x: Ref<number>
y: Ref<number>
}
export function useWindowSize(): WindowSize {
const windowSize = reactive({ x: 0, y: 0 })
const resizeListener = () => {
@tobiasdalhof
tobiasdalhof / total_spent.liquid
Last active June 8, 2022 21:49
Shopify customer total spent value for all orders with status "paid", "partially_paid" and "partially_refunded" without refundend amount | ✨ Estimated delivery date & order deadline for product pages https://www.delm.io
{% assign total_spent = 0 %}
{% for order in customer.orders %}
{% if order.financial_status == 'paid' or order.financial_status == 'partially_paid' or order.financial_status == 'partially_refunded' %}
{% assign total_spent = total_spent | plus: order.total_price | minus: order.total_refunded_amount %}
{% endif %}
{% endfor %}
{{ total_spent | money }}
@tobiasdalhof
tobiasdalhof / index.js
Last active October 24, 2022 03:00
Shopify variant listener
/**
* This class contains general helper methods.
*/
class Helper {
/**
* @param {String} name
* @returns {String|null}
*/
static getQueryParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
#!/usr/bin/env bash
# Get environment from first attribute
ENV=$1
ENV_DEV="dev"
ENV_STAGING="staging"
ENV_PROD="prod"
MAGENTO_PATH="../magento"
HTACCESS_PATH="$MAGENTO_PATH/.htaccess"
LOCALXML_PATH="$MAGENTO_PATH/app/etc/local.xml"
@tobiasdalhof
tobiasdalhof / readme.md
Last active July 30, 2018 07:37
Laradock cron on Windows 10 Pro

If the cron is not running then it will probably fail silently because of EOL issues.

Check EOL

# @see ttps://unix.stackexchange.com/a/389616
cat -A file

Add EOL option to VSCode

@tobiasdalhof
tobiasdalhof / add-if-to-your-tracking-codes.js
Last active May 23, 2018 11:47
GDPR web tracking cookie toggle, using Cookie.js
if (typeof window.Cookies.get('disable-webtracking') === 'undefined') {
// Your tracking code here
// Google Analytics, Facebook, Matomo, you name it...
}
@tobiasdalhof
tobiasdalhof / optout.html
Last active May 9, 2022 17:01
Magento Fooman Google Analytics GDPR
<div>
<input type="checkbox" name="toggleGoogleAnalytics" id="toggleGoogleAnalytics">
<label for="toggleGoogleAnalytics">Allow Google Analytics to track my visit.</label>
</div>
<script>
var gaProperty = 'YOUR-ANALYTICS-PROPERTY';
var gaDisableCookieName = 'ga-disable-' + gaProperty;
var gaIsAllowed = document.cookie.indexOf(gaDisableCookieName + '=true') === -1
var gaCheckbox = document.getElementById('toggleGoogleAnalytics');
@tobiasdalhof
tobiasdalhof / Helper.js
Created May 7, 2018 08:22
Helper class
export default class DeliveryMessageHelper {
/**
* Get current URL without trailing slash.
* @returns {string}
*/
static getCurrentURL () {
return window.location.origin + window.location.pathname
}
/**