Skip to content

Instantly share code, notes, and snippets.

@matthewbeta
matthewbeta / free-shipping-with-product.rb
Last active May 9, 2022
Shopify Script - Free Shipping with purchase of a specific product
View free-shipping-with-product.rb
# 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 / scrim-gradient.scss
Last active Apr 20, 2022
A simple little SCSS mixin for creating scrim gradients
View scrim-gradient.scss
/*
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 / readme.md
Created Jun 2, 2021 — forked from davidohlin/readme.md
Homestead allow CORS (with Sprig for Craft CMS)
View readme.md

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>
@matthewbeta
matthewbeta / gatsby-node.js
Created Jun 18, 2020
Rough Gatsby Plugin for downloading images from Craft CMS
View gatsby-node.js
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 / gatsby-node.js
Created Nov 19, 2019
Paginated Blog in Gatsby
View gatsby-node.js
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 / mediaquery.less
Created Apr 27, 2015
Mixin for media queries with .no-mq fallback (for <IE9)
View mediaquery.less
@sml-bp: 480px;
@med-bp: 720px;
@lrg-bp: 970px;
.phablet(@rules) {
@media screen and (min-width: @sml-bp) {
@rules();
}
};
@matthewbeta
matthewbeta / gulpfile.js
Created Sep 8, 2014
example gulpfile for jekyll and sass
View gulpfile.js
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-ruby-sass') ;
var prefix = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var filter = require('gulp-filter');
var sourcemaps = require('gulp-sourcemaps');
var minifycss = require('gulp-minify-css');
var browserSync = require('browser-sync');
@matthewbeta
matthewbeta / isnumber.js
Last active Feb 23, 2017
Test if its a number in JS
View isnumber.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)
}
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View parsley.multipleof.js
<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>