Skip to content

Instantly share code, notes, and snippets.

@stenvdb
stenvdb / img-macros.twig
Last active July 4, 2022 10:49
Macro collection for Imager in Craft CMS
{#
# USAGE:
# (transform can either be an object, or an array of objects, aka srcset)
#
# {{ macro.regular(entry.image.one(), { width: 50, height: 50 }, 'class="block"') }}
# ➡️ <img src="..." width="50" height="50" alt="..." class="block" />
#
# {{ macro.url(entry.image.one(), { width: 50, height: 50 }) }}
# ➡️ /uploads_c/../{...}.jpg
#
@shaneturner
shaneturner / craft-cms-entries-by-category-group.twig
Created December 4, 2017 00:26
Craft CMS: Getting entries grouped by category in order of the category type drag & drop order.
{# Get the categories related to my "entrySection" entries in structure order #}
{% set entries = craft.entries.section('entrySection') %}
{% set relatedCats = craft.categories.relatedTo(entries) %}
{# Loop the categories #}
{% for category in relatedCats %}
{{ category.title }}
{# Get and loop through entries related to this cat #}
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@wihodges
wihodges / Auto Param Push
Created April 26, 2012 19:17
Append all urls with current page URL parameters - JS
$(document).ready(function(){
elements = $('.openURL');
passMe = window.location.href.slice(window.location.href.indexOf('?'));
elements.each(function() {
url = $(this).attr("href");
newURL = url + passMe;
$(this).attr("href", newURL);
});
});
@Synchro
Synchro / Premailer.php
Created September 8, 2011 21:48
PHP interface class for the Premailer API
<?php
/**
* Premailer API PHP class
* Premailer is a library/service for making HTML more palatable for various inept email clients, in particular GMail
* Primary function is to convert style tags into equivalent inline styles so styling can survive <head> tag removal
* Premailer is owned by Dialect Communications group
* @link http://premailer.dialect.ca/api
* @author Marcus Bointon <marcus@synchromedia.co.uk>
*/
@robflaherty
robflaherty / csv-to-json.php
Created September 1, 2011 02:26
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
@jed
jed / LICENSE.txt
Created May 10, 2011 16:39 — forked from 140bytes/LICENSE.txt
use anchor tags to parse URLs into components
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);