Skip to content

Instantly share code, notes, and snippets.

View JonMcL's full-sized avatar

Jonathan McLaughlin JonMcL

View GitHub Profile
@JonMcL
JonMcL / sshd-obvious.conf
Last active March 1, 2016 19:44
sshd-obvious configuration for fail2ban Allows for a maxretry=1 for obvious hack attempts while leaving maxretry=3 available for possible mistakes.
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
#
# $Revision$
#
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
@JonMcL
JonMcL / gist:5213486
Last active December 15, 2015 05:59
Useful CSS for Drupal theme. Designed to make many action tabs flow to a second line. Gleamed from: http://redfinsolutions.com/blog/sanitizing-drupals-default-tabs
ul.primary {
border-bottom: 0;
white-space: normal;
line-height: 1.6em;
padding: 0;
margin: 0
}
ul.primary li {
display: list-item;
float: left;
server {
listen 80;
server_name mydomain.com;
rewrite ^/(.*) http://mydomain.com permanent;
}
server {
listen 80;
server_name www.mydomain.com;
@JonMcL
JonMcL / gist:6123443
Last active December 20, 2015 11:29
Simple Javascript to disable Drupal Overlay for admin_menu toolbar. Add to page with a hook_page_preproces.
(function ($) {
// Don't use Overlay module for the admin menu (toolbar) links
Drupal.admin.behaviors.overlay_exclude = function (context, settings, $adminMenu) {
$adminMenu.not('.overlay-exclude-processed')
.addClass('overlay-exclude-processed')
.find('a').addClass('overlay-exclude');
}
})(jQuery);
@JonMcL
JonMcL / gist:7108388
Created October 22, 2013 21:21
Useful responsive SCSS breakpoint mixins with IE8/IE7 fallback
@import 'breakpoint';
$mobile: max-width 959px;
$desktop: min-width 960px;
@mixin break-mobile {
@include breakpoint($mobile) {
@content
}
}
@mixin break-desktop {
@include breakpoint($desktop) {
/**
* Delete fields no longer used by this module.
*/
function hook_update_N() {
$fields_to_delete = array(
'field_cost',
'field_construction_budget',
'field_construction_cost',
'field_total_budget',
);
@JonMcL
JonMcL / gist:f802c4eb844452835c0f
Created December 15, 2014 18:55
CSS Vertical Centering Holy Grail?
/* From: http://css-tricks.com/centering-in-the-unknown/ */
/* This parent can be any width and height */
.block {
text-align: center;
}
/* The ghost, nudged to maintain perfect centering */
.block:before {
content: '';
@JonMcL
JonMcL / settings.php
Last active September 14, 2017 16:17
Redirect to www and https in Pantheon server environments. Add to Drupal 7 settings.php file.
/**
* Pantheon HTTPS and www redirects.
*/
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && php_sapi_name() !== 'cli') {
$domain = $_SERVER['HTTP_HOST'];
$www_redirect = false;
if (isset($_ENV['PANTHEON_ENVIRONMENT']) && $_ENV['PANTHEON_ENVIRONMENT'] === 'live') {
if (count(explode('.', $domain)) < 3 && stripos($domain, 'www.') === false) {
$domain = 'www.' . $domain;
$www_redirect = true;
@JonMcL
JonMcL / add_js_to_root_before_load.js
Last active December 26, 2017 20:13
Simple Javascript to force 'js' class into document root as soon as <head> is loaded and parsed. This happens before CSS and before JS assets are loaded. Also removes 'no-js' if it is there.
<script type="text/javascript">
var root = document.documentElement;
if (root.classList) {
root.classList.add('js');
root.classList.remove('no-js');
}
else {
root.className += ' js';
var regex = new RegExp('(\\s|^)' + 'no-js' + '(\\s|$)');
el.className = root.className.replace(regex, ' ');
@JonMcL
JonMcL / style-tests.js
Last active February 14, 2018 14:14
Adds one or more classes to document root for CSS tests. Classes persist through session.
/**
* Simple utility function to add special classes, prefixed with 'style-test' into
* the document.
*
* Example:
* ?style-test=test1+test2
* Adds classes: style-test-test1 style-test-test2
*
*/
(function(Document, window) {