Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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>
@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 / 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 / mediaquery.less
Created April 27, 2015 15:39
Mixin for media queries with .no-mq fallback (for <IE9)
@sml-bp: 480px;
@med-bp: 720px;
@lrg-bp: 970px;
.phablet(@rules) {
@media screen and (min-width: @sml-bp) {
@rules();
}
};
@matthewbeta
matthewbeta / gulpfile.js
Created September 8, 2014 11:18
example gulpfile for jekyll and sass
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 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)
}
# 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 ->
<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>