Skip to content

Instantly share code, notes, and snippets.

View philwolstenholme's full-sized avatar

Phil Wolstenholme philwolstenholme

View GitHub Profile
@philwolstenholme
philwolstenholme / first-time-using-min-aspect-ratio.scss
Created April 16, 2020 19:28
Using a combination of the orientation and min-aspect-ratio media queries to make sure a 16:9 video always fits inside a modal (at all screen sizes and orientations) without any content being cut off
@media (orientation: landscape) {
// 1.77 represents the 16/9 aspect ratio.
// 95vh / 1.77 gives us the max height our video can be to guarantee
// its width won't be too large to fit on some awkward viewport dimensions.
// 95vh / 1.77 = 53.672316384, and 53.672316384 * 1.77 = 95.
// This is <100, so this stops our video ever being too wide to fit on the screen.
width: calc((95vh / 1.77) * 1.77);
height: calc(95vh / 1.77);
}
@philwolstenholme
philwolstenholme / classListToCommaAndNewLineSeparatedString.js
Created July 15, 2019 10:49
Take the CSS classes of the currently selected DOM node in Chrome devtools and output it as a comma and newline separated string ready to paste into an array
$0.classList.toString().split(" ").map(utilityClass => `'${utilityClass.trim()}',`).join('\n')
javascript:window.location=(jQuery("link[rel='shortlink']").attr('href') + '/edit')
@philwolstenholme
philwolstenholme / example_response.json
Last active February 26, 2018 14:18
Corrupted Drupal AJAX response JSON (potentially) as a result of the Ghost Inspector Chrome plugin
[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"london_plan","theme_token":"EER5So6oi7xk_WA15TAY7yhCtIlfsjhC9tpZ_dx4v88"}},"merge":true},{"command":"insert","method":"append","selector":"div#ajax-status-messages-wrapper","data":"\u003Cdiv class=\u0022messages-container\u0022\u003E\n\u003Cdiv class=\u0022messages status\u0022 role=\u0022contentinfo\u0022 aria-label=\u0022Status message\u0022\u003E\n\u003Cdiv role=\u0022status\u0022\u003E\n\u003Ch2 class=\u0022element-invisible\u0022\u003EStatus message\u003C\/h2\u003E\nThank you, your comment has been submitted\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n","settings":null},{"command":"invoke","selector":null,"method":"updateAJAXCommentCount","arguments":["Thank you, your comment has been submitted"]},{"command":"modal_dismiss"},{"command":"insert","method":"append","selector":"div#ajax-status-messages-wrapper","data":"\u003Cdiv class=\u0022messages-container\u0022\u003E\n\u003Cdiv class=\u0022messages st
<?php
/**
* Implements hook_views_post_render().
*/
function MODULE_NAME_views_post_render($view) {
if ($view->id() !== 'VIEW_ID' && $view->getDisplay()->getPluginId() !== 'page') {
return;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>Countdown</title>
<meta name="author" content="">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="//code.jquery.com/jquery.js"></script>
/*
Credit to https://github.com/bsuresh, I'm just saving this as a gist for my own reference
*/
/* Content to extend beyond the boundaries of our container and span
to full width of viewport */
.u-breakout {
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
clear: both;
@philwolstenholme
philwolstenholme / SassMeister-input-HTML.html
Created January 21, 2016 16:39
Generated by SassMeister.com.
<div class="container">
<div class="box">Kinda works</div>
</div>
<div class="container">
<div class="box">Shame the gutter is applied with padding rather than a margin though</div>
</div>