Skip to content

Instantly share code, notes, and snippets.

@tmlangley
tmlangley / .htaccess
Created June 2, 2017 15:24
Redirect "/index.php" to "/"
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^index.php(.*)$ /$1 [R=301,L]
@tmlangley
tmlangley / themekit.php
Last active October 5, 2016 23:20
Get inline style for entity field
<?php
function themekit_preprocess_paragraph(&$variables) {
$paragraph = $variables['paragraph'];
$bundle = $variables['paragraph']->bundle();
switch ($bundle) {
case 'simple_small_cta':
$variables['image_inline_style'] = themekit_get_entity_image_inline_style($paragraph, 'field_image', 'small_cta');
break;
case 'simple_large_cta':
@tmlangley
tmlangley / _nav-boilerplate.scss
Created September 21, 2016 19:58
Dropdown navigation boilerplate
nav {
// wrapper styles...
// All tier menus (ul selector)
.menu {}
// All list items
li {}
// All links
@tmlangley
tmlangley / _buttons.scss
Created September 2, 2016 17:07
Advanced config based SASS buttons
$buttons: () !default;
// Extract the common styles into a placeholder
%btn-base {
display: inline-block;
line-height: 1;
font-weight: 700;
overflow: hidden;
position: relative;
vertical-align: middle;
transition: 50ms transform;
@tmlangley
tmlangley / _buttons.scss
Created August 18, 2016 15:54
Config based button SASS styles
$buttons: (
default: ()
) !defualt;
// Button mixin
@mixin btn($button-key, $size: small) {
$button: extend-in-map($buttons, $button-key);
display: inline-block;
line-height: 1;
@tmlangley
tmlangley / tabs.scss
Created March 22, 2016 17:52
Drupal Admin Tabs Styling
//
// _config.scss
//
$tabs-config: (
wrap: (
background: #fafafa,
border: #efefef
),
link: (
color: #251923,
@tmlangley
tmlangley / z-index.scss
Created March 18, 2016 17:48
Contextual z-index
// z-index organization
//
// References:
// - https://css-tricks.com/handling-z-index/
// - http://www.sitepoint.com/using-sass-maps/
// _config.scss
$z-layers: (
bottomless-pit: -9999,
@tmlangley
tmlangley / resize.js
Created February 11, 2016 15:51
Do something on resize and load.
$(function() {
$(window).resize(function() {
// Do stuff...
}).trigger('resize');
});
@tmlangley
tmlangley / sql-slurp.sh
Created November 6, 2015 16:20
sql-slurp
_sql-slurp () {
printf "This will overwrite the $2 database with the $1 database.\n"
printf "\n\t\t*** $1 -> $2 ***\n\n"
sleep 3s
read -p "Are you sure [Y/n]? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
drush $2 sql-drop -y
printf "\n"
drush $1 sql-dump | pv -br | drush $2 sql-cli -A
fi
@tmlangley
tmlangley / variables.scss
Created August 28, 2015 21:04
SASS variable selectors
$hover: '&:hover, &:active, &:focus';
$headings: 'h1, h2, h3, h4, h5, h6';
$headers: $headings;
//
// Usage
//
#{$headings} {
color: #222;