Skip to content

Instantly share code, notes, and snippets.

{% layout none%}
{% assign applied_discounts = cart.discount_applications | where: "type", "discount_code" %}
{% capture discounts %}
{% for discount_application in applied_discounts %}
{
"title" : "{{ discount_application.title }}",
"value" : "{{ discount_application.value }}",
"value_type": "{{ discount_application.value_type }}",
"type": "{{ discount_application.type }}",
"amount" : "{{ discount_application.total_allocated_amount | money }}",
@tomfa
tomfa / urls.test.ts
Last active December 15, 2024 18:51
NextJS route vs pathname matcher
describe('matchesPath', () => {
const matches = [
['/cake', '/cake'],
['/cake', '/cake/'],
['/cake', '/cake?frige=warm'],
['/cake', '/cake?frige=warm&freezer=cold'],
['/[id]', '/cake'],
['/[anything-goes]', '/cake'],
['/c/[id]/practitioner/[pid]/[anything-goes]', '/c/1/practitioner/2/3'],
['/[...rest]', '/cake'],
{%comment%}
#############################################
# Mohamed El-Ghorfi Discount Code on Cart #
# [UPDATED] #
#############################################
# Paypal Me: https://paypal.me/elghorfimed #
# Buy Me A Coffee: #
# https://www.buymeacoffee.com/elghorfi #
#############################################
# elghorfi.med@gmail.com #
@salomao-santos
salomao-santos / aem-component-dialog.md
Last active September 26, 2025 03:04
AEM Component: Dialog field example: structure of a dialog, checkbox, datepicker, fileupload, multifield, numberfield, pathbrowser, pathfield, radiogroup, richtext, select, textarea, textfield
@jgthms
jgthms / schema.graphql.js
Created July 2, 2020 18:34
Strapi GraphQL find single item by slug
const { sanitizeEntity } = require('strapi-utils');
module.exports = {
query: `
categoryBySlug(slug: String!): Category
`,
resolver: {
Query: {
categoryBySlug: {
resolverOf: 'Category.findOne',
@AshlinRejo
AshlinRejo / Discount rules v2: For getting discounted price of a product
Last active October 27, 2023 05:45
Discount rules v2: For getting discounted price of a product
/**
* Get the discount details of given product with custom price
* @param $price float/integer
* @param $product object (Product object Example: wc_get_product($product_id))
* @param $quantity int
* @param $custom_price float/integer (0 for calculate discount from product price)
* @param $return_details string (Default value 'discounted_price' accepted values = 'discounted_price','all')
* @param $manual_request boolean (Default value false: pass this as true for get discount even if there is no item in cart)
* @param $is_cart boolean (Default value true)
* @return array|float|int - is product has no discounts, returns $price;else return array of discount details based on $return_details
@keikoro
keikoro / FF_HTMLbookmarks_toCSV.js
Last active September 11, 2025 17:31
JavaScript bookmarklet for converting HTML-formatted Firefox bookmarks into a downloadable CSV file
javascript:(function(){
/* escape quotes and commas in contents to be comma-separated */
function wrapCsvContents(content) {
if (typeof(content) === 'string') {
if (content.replace(/ /g, '').match(/[\s,"]/)) {
return '"' + content.replace(/"/g, '""') + '"';
}
}
return content;
}
@ollietreend
ollietreend / acf-php-to-json.php
Last active August 28, 2025 05:42
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'
@ateucher
ateucher / setup-gh-cli-auth-2fa.md
Last active May 3, 2024 11:06
Setup git on the CLI to use 2FA with GitHub

These are instructions for setting up git to authenticate with GitHub when you have 2-factor authentication set up. This authentication should be inherited by any GUI client you are using. These are intentionally brief instructions, with links to more detail in the appropriate places.

  1. Download and install the git command-line client (if required).

  2. Open the git bash window and introduce yourself to git (if required):

    git config --global user.name 'Firstname Lastname'
    git config --global user.email 'firstname.lastname@gov.bc.ca'
    

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8