Skip to content

Instantly share code, notes, and snippets.

View jolantis's full-sized avatar

Jonathan van Wunnik jolantis

View GitHub Profile
<?php
/**
* Syntaxic sugar for getting values from Kirby page fields
*
* Example usage with the custom field method on a first line,
* and the corresponding logic (aka what you could write without
* the syntactic sugar methods) on the second line.
*
* // Use a fallback field if the first one is empty
* $title = $page->shorttitle()->or($page->title());
<?php
// Start off with an empty $title
$title = '';
// Get all the parents (except the homepage) and reverse the array
$parents = $site->breadcrumb()->not('home')->flip();
// Iterate over the array
foreach ($parents AS $parent) :
@jolantis
jolantis / gist:e9225086330c40e3849b
Created July 13, 2015 09:34
Disable Sketch 3 auto-save
defaults write com.bohemiancoding.sketch3 ApplePersistence -bool no
@jolantis
jolantis / prefetchbuilder.js
Created October 5, 2015 10:14 — forked from PaulKinlan/prefetchbuilder.js
Code to return link rel=dnsprefetch
(function() {
var requests = window.performance.getEntries();
var hosts = {};
var output = "";
for(var requestIdx = 0; requestIdx < requests.length; requestIdx++) {
var request = requests[requestIdx];
var origin = new URL(request.name).origin;
hosts[origin] = 1;
@jolantis
jolantis / gist:0a1991db917de3b3a423746da0a22e5a
Created December 2, 2016 17:44 — forked from mgmilcher/gist:5eaed7714d031a12ed97
Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X

This is my take on how to get up and running with NGINX, PHP-FPM, MySQL and phpMyAdmin on OSX Yosemite.

This article is adapted from the original by Jonas Friedmann. Who I just discovered is from Würzburg in Germany. A stonesthrow from where I was born ;)

Xcode

Make sure you have the latest version of XCode installed. Available from the Mac App Store.

Install the Xcode Command Line Tools:

xcode-select --install

@mixin valid-quantity($quantity) {
@if type-of($quantity) != 'number' {
@error 'The "quantity" parameter must be a number!';
}
@if not(unitless($quantity)) {
@error 'The "quantity" parameter must not have a unit!';
}
@if $quantity < 0 {
@error 'The "quantity" parameter must be at least 0!';
}