Skip to content

Instantly share code, notes, and snippets.

@itsmattsoria
itsmattsoria / gistfil1.textile
Last active July 3, 2024 05:36
Mac Terminal Cheat Sheet

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor
@brandonkelly
brandonkelly / templating.md
Last active February 7, 2024 15:20
Templating in EE vs. Craft
// Not shown here is the Grunt task that takes source SVGs, creates PNGs (later optimised by imageoptim) and minified SVGs
@mixin bg-image($image, $size: 16px, $repeat: no-repeat, $position: center) {
// SVG backgrounds with PNG fallback
// All browsers that support multiple backgrounds also support SVGs. Woohoo!
background-image: image-url("#{$image}.png");
// inline-image requires Compass
background-image: inline-image("#{$image}.min.svg"), none;
background-size: $size;
@kmgdevelopment
kmgdevelopment / gist:dfe6d793fb7210bfc565
Created December 2, 2015 23:11
Craft: Single-Image Asset Field
{% set bannerBg %}
{% for bgImg in entry.bannerBg %}
{{ bgImg.url }}
{% endfor %}
{% endset %}
@engram-design
engram-design / export.php
Last active September 12, 2023 12:01
ExpressionEngine PHP Export into JSON
<?php
$channel = $_GET['id'];
$content = array();
$fields_query = $this->EE->db->query("SELECT * FROM exp_channel_fields LEFT JOIN exp_channels ON exp_channel_fields.group_id = exp_channels.field_group WHERE exp_channels.channel_id = '$channel'");
$entries_query = $this->EE->db->query("SELECT * FROM exp_channel_data cd INNER JOIN exp_channel_titles ct ON cd.entry_id = ct.entry_id WHERE cd.channel_id = '$channel'");
$fields = $fields_query->result_array();
@WilliamIsted
WilliamIsted / Craft CMS Image Alt Text
Last active April 3, 2019 22:38
Craft CMS - Show image alt text if it has been set and isn't autogenerated
<img{% if image.title | kebab != image.slug %} alt="{{ image.title }}"{% endif %} src="{{ image.getUrl('thumb') }}">
Example Usage:
{% if entry.images | length %}
{% for image in entry.images %}
<img{% if image.title | kebab != image.slug %} alt="{{ image.title }}"{% endif %} src="{{ image.getUrl('thumb') }}">
{% endfor %}
{% endif %}
@johnfmorton
johnfmorton / gist:639451fea75d84a5b89b5bcacb6ae8bb
Created May 16, 2024 17:52
Example script to get a YouTube video to display on a page that has an embed
<script>
document.addEventListener('DOMContentLoaded', (event) => {
// Find all oembed elements
const oembedElements = document.querySelectorAll('oembed[url]');
oembedElements.forEach(element => {
const url = element.getAttribute('url');
const videoId = extractYouTubeId(url);
if (videoId) {