Skip to content

Instantly share code, notes, and snippets.

View mildlygeeky's full-sized avatar

Patrick Harrington mildlygeeky

View GitHub Profile
@mildlygeeky
mildlygeeky / gist:4547577
Created January 16, 2013 14:43
Print Stylesheet code
/* ==========================================================================
Print styles.
Inlined to avoid required HTTP connection: h5bp.com/r
========================================================================== */
@media print {
* {
background: transparent !important;
color: #000 !important; /* Black prints faster: h5bp.com/s */
box-shadow: none !important;
@mildlygeeky
mildlygeeky / gist:14b814ec8c815a1f5c6f
Last active January 3, 2019 11:43
Dynamic Navigation using native Craft CMS and Twig templates
{# For this, I wanted the nav to show the top-level node and second-level nodes #}
{# when on level 1, and then show the second-level and its children when on #}
{# level 2 or level 3 (so we get good parent, child, and sibling navigation. #}
{# Requires string 'sectionName' to be passed with Structure section name #}
{% if entry.showLeftNavigation %}
<nav class="interior-page__nav">
@mildlygeeky
mildlygeeky / gist:6f8eeb28a10240cde5a0
Last active August 29, 2015 14:03
Generating a menu for Matrix blocks in Craft CMS
{% for block in entry.bodyBlocks %}
{%- if loop.first %}<ul>{% endif %}
<li><a href="#bodyblock-{{ block.ownerId }}-{{ block.id }}">{{ block.blockName }}</a></li>
{%- if loop.first %}</ul>{% endif %}
{%- endfor %}
{% if entry.homepageHeroDesktop|length > 0 and entry.homepageHeroMobile|length > 0 %}
<div class="homepage-hero homepage-hero--image">
<figure>
<picture>
{% set homepageHeroDesktop = entry.homepageHeroDesktop.first().getUrl() %}
{% set homepageHeroMobile = entry.homepageHeroMobile.first().getUrl() %}
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="{{ homepageHeroDesktop }}" media="(min-width: 540px)">
@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*
@mildlygeeky
mildlygeeky / _layout.html
Created March 8, 2017 21:08 — forked from engram-design/_layout.html
SEOMatic Setup
<!doctype html>
<html lang="en">
<head>
<!-- Responsive-ness -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- SE-Oh -->
{% include '_includes/seo_meta' %}
</head>
### Keybase proof
I hereby claim:
* I am mildlygeeky on github.
* I am mildlygeeky (https://keybase.io/mildlygeeky) on keybase.
* I have a public key ASDegx54rfKDh0lbjQR4XWM2gLQaeLKl9g1hgtKNVbzVPgo
To claim this, I am signing this object:
@mildlygeeky
mildlygeeky / CacheBustingCraftValetDriver.php
Created August 26, 2017 12:08
Valet Driver for Craft CMS (2.x) that tries to resolve filenames using static asset versioning, per https://nystudio107.com/blog/simple-static-asset-versioning
<?php
class CacheBustingCraftValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
<?php
namespace craft\contentmigrations;
use Craft;
use craft\db\Migration;
/**
* m200829_184642_fix_colour_swatches migration.
*/