Skip to content

Instantly share code, notes, and snippets.

@tomdavies
tomdavies / CustomJsonDatatype.php
Last active August 2, 2023 11:06
Adding a custom DataType to Feed Me for CraftCMS
<?php
namespace modules\datatypes;
use craft\feedme\datatypes\Json;
use illuminate\Support\Collection;
class CustomJsonDatatype extends Json
{
/**
@tomdavies
tomdavies / Plugin.php
Created December 6, 2022 12:20
Register custom image transformers in CraftCMS
<?php
use Craft;
use craft\base\Plugin;
use craft\elements\Asset;
use craft\events\GenerateTransformEvent;
use craft\events\RegisterComponentTypesEvent;
use craft\services\ImageTransforms;
@tomdavies
tomdavies / .eslintrc.js
Last active January 17, 2021 21:03
Make eslint-loader (+ prettier) play nice with gridsome
module.exports = {
root: true,
env: {
node: true,
},
parserOptions: {
parser: "babel-eslint",
},
settings: {
'import/resolver': 'webpack',
@tomdavies
tomdavies / _disabled.twig
Created August 18, 2016 14:28
application form
<div class="island island--light">
<div class="wrapper">
<div class="cell-v30">
<div class="g">
<div class="g__col
g__col--12
g__col--7--medium g__col--center--medium">
<div class="island cell-40 rule rule--all rule--grey">
{% include '_includes/body' %}
</div>
@tomdavies
tomdavies / set-project-perms.sh
Created December 8, 2015 13:49 — forked from khalwat/set-project-perms.sh
Properly set permissions for a Craft CMS install, including ensuring that files are all g-x. Set CHOWN_USER, CHOWN_GROUP, and BASE_DIR to whatever is appropriate, add directories that need to be writeable by the web server to DIRS[], then execute: ./set-project-perms.sh PROJECT_NAME
#!/bin/bash
# Execute via: ./set-project-perms.sh PROJECT_NAME
# The paradigm is the entire project dir is owned by $CHOWN_USER with the group set to $CHOWN_GROUP
# $CHOWN_USER is an admin or user account that is used to edit files/templates, etc.
# $CHOWN_GROUP is the group of the webserver (e.g.: 'apache', 'nginx', 'httpd', etc.)
# The project dir permissions are set to 755 (-rwxr-xr-x) for directories and to 644 (-rw-r--r--) for files
# The permissions to $DIRS[] that need to be writeable are set to 775 (-rwxrwxr-x) for directories and
# 664 (-rw-rw-r--) for files. Add any assets directories, etc. as necessary.
# Change $BASE_DIR to the absolute path where your websites are stored (leaving it appended with '/$1')
@tomdavies
tomdavies / palette.scss
Last active August 29, 2015 13:56
Better colour names with palettes & SASS maps
// Declare colours
$_color-base-grey: rgb(229,231,234);
$palettes: (
purple: (
base: rgb(42,40,80),
light: rgb(51,46,140),
dark: rgb(40,38,65)
),
grey: (
base: $_color-base-grey,
@tomdavies
tomdavies / Directory Structure
Created October 3, 2013 15:45
Mobile first media queries with IE8 fallback, using Breakpoint
sass/
|- _config.scss
|- site.scss
|- site--ie8.scss
\- modules/
\- _widget.scss
@tomdavies
tomdavies / gist:5721867
Created June 6, 2013 14:20
Last Git commit SHA to Mac clipboard
git log -n1 | cut -c6-12 | pbcopy
@tomdavies
tomdavies / config.php
Created November 30, 2012 11:45 — forked from 1stevengrant/config.php
Fixes the daylight savings issue with EE
var $dateTime = new DateTime();
$dateTime->setTimezone(new DateTimeZone('America/New_york'));
$dateTime->setTimestamp(time());
$isDst = (bool)$dateTime->format('I') ? "y" : "n";
$conf['daylight_savings'] = $isDst;
@tomdavies
tomdavies / HowTo.md
Created November 29, 2012 00:35
ExpressionEngine Google Analytics Site Search

Google Analytics Site Search

New GA.js script allows to track EE searches

Google updated their Analytics code from their former Urchin script (urchin.js) to their own Google Analytics (gs.js) that now allows to track:

  • Site Search (e.g EE site search)
  • Events (e.g file downloads) (still in closed beta Jan.11.2008)

Preparation