Skip to content

Instantly share code, notes, and snippets.

<input type="text" data-parsley-multiple="3" data-parsley-error-message="Please try again" />
/*...*/
<script type="text/javascript">
window.ParsleyValidator
.addValidator('multipleof', function (value, requirement) {
return 0 === value % requirement;
}, 32)
.addMessage('en', 'multipleof', 'This value should be a multiple of %s');
</script>
@matthewbeta
matthewbeta / isnumber.js
Last active February 23, 2017 17:52
Test if its a number in JS
function isNumber(val) {
// only returns true if its a number
return Number(val) === val;
}
// OR
function isAlsoNumber(val) {
return typeof val === 'number' && !Number.isNaN(val)
}
@matthewbeta
matthewbeta / scrim-gradient.scss
Last active January 22, 2024 15:52
A simple little SCSS mixin for creating scrim gradients
/*
A simple little SCSS mixin for creating scrim gradients
Inspired by Andreas Larson - https://github.com/larsenwork
https://css-tricks.com/easing-linear-gradients/
*/
@mixin scrimGradient($startColor: $color-black, $direction: 'to bottom') {
$scrimCoordinates: (
@matthewbeta
matthewbeta / gatsby-node.js
Created November 19, 2019 09:28
Paginated Blog in Gatsby
const createPaginatedPages = require('gatsby-paginate');
exports.createPages = ({ graphql, actions: { createPage } }) => {
return new Promise((resolve, reject) => {
graphql(`
{
blog: craft {
entriesConnection(section: [yoursectionhandle]) {
edges {
node {
@matthewbeta
matthewbeta / free-shipping-with-product.rb
Last active April 4, 2023 15:29
Shopify Script - Free Shipping with purchase of a specific product
# This is the product you need to buy to get free shipping
PRODUCT_ID = 000000000000
# This is the name of the shipping rate you want to discount (you can probably ad more options here and loop over them or soemthing
SHIPPING_NAME = "Standard Shipping"
# This is updated shipping name
UPDATED_SHIPPING_NAME = "FREE Standard Shipping"
# This is the message that will appear next to the doiscounted shipping rate option
MSG = "Buy X get Free Delivery offer"
is_in_cart = false
@matthewbeta
matthewbeta / gatsby-node.js
Created June 18, 2020 21:53
Rough Gatsby Plugin for downloading images from Craft CMS
const { createRemoteFileNode } = require(`gatsby-source-filesystem`);
const axios = require('axios');
require('console-success');
const ENTRY_API_URI = `${process.env.GATSBY_API_URL}/entries.json`;
const CATEGORY_API_URI = `${process.env.GATSBY_API_URL}/categories.json`;
exports.sourceNodes = async ({ actions, createNodeId, cache, store, createContentDigest }) => {
const { createNode, createNodeField } = actions;
@matthewbeta
matthewbeta / readme.md
Created June 2, 2021 10:41 — forked from davidohlin/readme.md
Homestead allow CORS (with Sprig for Craft CMS)

Working allow CORS Homestead (with Sprig for Craft CMS)

Place the following in the server block of your sites nginx config, ie /etc/nginx/sites-enabled/example.com

# Allow CORS
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,hx-current-url,hx-request,hx-target,hx-t&gt;