Skip to content

Instantly share code, notes, and snippets.

@davist11
davist11 / jquery.listSelect.js
Created December 18, 2012 22:06
jQuery List to Select
/**
* @name jQuery List to Select Plugin
* @author Trevor Davis
* @copyright (cc) Trevor Davis (http://www.viget.com)
*
* Licensed under the CC-GNU GPL (http://creativecommons.org/licenses/GPL/2.0/)
*/
;(function($, window, document, undefined) {
var ListSelect = function(elem, options) {
@brandonkelly
brandonkelly / gist:8672116
Created January 28, 2014 17:26
A function for converting an entry in Craft to JSON
<?php
public function getEntryJson(EntryModel $entry)
{
$entryData = array();
foreach ($entry->getType()->getFieldLayout()->getFields() as $field)
{
$field = $field->getField();
$handle = $field->handle;
@mshmsh5000
mshmsh5000 / redirect.vcl
Created February 10, 2016 15:38
Fastly VCL for redirects stored in dicts
sub vcl_recv {
if (table.lookup(redirects, req.url)) {
error 777 "Moved";
}
#FASTLY recv
if (req.request != "HEAD" && req.request != "GET" && req.request != "FASTLYPURGE") {
return(pass);
@mildlygeeky
mildlygeeky / Installing Imagick with PHP 7.md
Last active March 6, 2016 17:53 — forked from mmikkel/Installing Imagick with PHP 7.md
Installing Image Magick for PHP 7 on a Server Pilot managed server
apt-get install pkg-config libmagickwand-dev -y
cd ~/downloads
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
/opt/sp/php7.0/bin/phpize
./configure --with-php-config=/opt/sp/php7.0/bin/php-config
make install
rm -rf /tmp/imagick-3.4.0*
@bossanova808
bossanova808 / commerce.php
Created October 18, 2016 23:13
Example working Craft Commerce config file for payment details
<?php
// This controls and contains what keys/passwords are used for dev/live environments.
return [
// THIS * ENTRY MUST BE PRESENT - EVEN IF EMPTY!
'*' => array(
),
// DEV Details - i.e. your Paypal sandbox details for example
import qs from 'qs';
import Axios from 'axios';
Axios.defaults.baseURL = Craft.baseUrl;
Axios.defaults.headers.common['Accept'] = 'application/json';
Axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Axios.interceptors.request.use(config => {
if (config.data instanceof FormData) {
@Chrisedmo
Chrisedmo / craftblockwrap.twig
Created November 16, 2017 21:24 — forked from croxton/craftblockwrap.twig
Craft CMS matrix blocks intelligent wrapping
{# _partials/blocks/blocks.html #}
{#
Blocks component
Outputs a matrix field blocks, intelligently wrapping blocks that need to be inset from the edges
@param {object} contentBlocks (MatrixBlockModel)
#}
{# Parameters #}
@croxton
croxton / expresso_store_uk_postcodes.txt
Created November 27, 2017 10:30
Expresso Store match specific UK postcodes
Allow shipping rules to accept regex
***************************************************************
First, change the `postcode` column in `exp_store_shipping_rules` to type varchar(255).
./Store/src/Service/ShippingService.php
Change this:
/**
@croxton
croxton / critical-css-with-js.twig
Last active November 3, 2020 08:30
Inline critical CSS with JS (Craft CMS)
{% set _inline_css_block = block('_inline_css') %}
{% if _inline_css_block is not empty %}
<script>
(function() {
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(e){"use strict";var n=function(n,t,o){function i(e){return a.body?e():void setTimeout(function(){i(e)})}function r(){l.addEventListener&&l.removeEventListener("load",r),l.media=o||"all"}var d,a=e.document,l=a.createElement("link");if(t)d=t;else{var s=(a.body||a.getElementsByTagName("head")[0]).childNodes;d=s[s.length-1]}var f=a.styleSheets;l.rel="stylesheet",l.href=n,l.media="only x",i(function(){d.parentNode.insertBefore(l,t?d:d.nextSibling)});var u=function(e){for(var n=l.href,t=f.length;t--;)if(f[t].href===n)return e();setTimeout(function(){u(e)})};return l.addEventListener&&l.addEventListener("load",r),l.onloadcssdefined=u,u(r),l};"undefined"!=typeof exports?exports.loadCSS=n:e.loadCSS=n}("undefined"!=typeof global?global:this);
!function(t){"use strict";t.loadCSS||(t.loadCSS=function(){});var e=loadCSS.relpreload={
@mrmartineau
mrmartineau / stimulus.md
Last active April 9, 2025 15:37
Stimulus cheatsheet