Skip to content

Instantly share code, notes, and snippets.

View dirtystylus's full-sized avatar

Mark Llobrera dirtystylus

View GitHub Profile
@dirtystylus
dirtystylus / eleventy-figure-shortcode.md
Last active January 3, 2023 13:33
Eleventy Figure Shortcode
module.exports = (image, caption, className) => {
  const classMarkup = className ? ` class="${className}"` : '';
  const captionMarkup = caption ? `<figcaption>${caption}</figcaption>` : '';
  return `<figure${classMarkup}><img src="/img/${image}" />${captionMarkup}</figure>`;
  // the line below does all this in one line, but is more confusing:
  // return `<figure${className ? ` class="${className}"` : ''}><img src="/img/${image}" />${caption ? `<figcaption>${caption}</figcaption>` : ''}</figure>`;
};
const markdownIt = require("markdown-it");
const md = new markdownIt();
const dbg = require("debug")("responsiver-config");
const runAfterHook = (image, document) => {
let imageUrl =
image.getAttribute("data-pristine") || image.getAttribute("src");
let caption = image.getAttribute("title");
if (caption !== null) {
caption = md.renderInline(caption.trim());

Gods of Jade and Shadow

  • by Silvia Moreno-Garcia
  • Started 2019/01/02
  • Finished 2019/01/08
  • Is this YA? Does it matter? I enjoyed this, and I like that it didn’t end in an easy cliché.

what is yours is not yours

  • by Helen Oyeyemi
@dirtystylus
dirtystylus / reading-log-2019.md
Last active November 19, 2019 21:48
Reading Log 2019

China Rich Girlfriend

  • by Kevin Kwan
  • Started 2019/01/02
  • Finished 2019/01/08

Good and Mad

  • by Rebecca Traister
  • Started 2019/01/02
  • The Underground Railroad, Colson Whitehead
  • Moonglow, Michael Chabon
  • Gnomon, Nick Harkaway
  • Death of a King, Tavis Smiley
  • The Obelisk Gate, N. K. Jemisin
  • New York 2140, Kim Stanley Robinson
  • My Brilliant Friend, Elena Ferrante
  • The Woman Who Smashed Codes, Jason Fagone
  • So You Want to Talk About Race, Ijeoma Oluo
  • Her Body and Other Parties, Carmen Maria Machado
@dirtystylus
dirtystylus / hook-presave-delete.module
Created April 5, 2017 12:24
Hook Presave and Delete
<?php
/**
* @file
* Field DOS Feed Status Module file
*
* This module allows site administrators to send a stock warning
* email to a specified user or users through the admin interface.
* Administrators can configure the default email including token replacement.
*/
//define('EXHIBIT_ITEMS_MODIFICATION_DATE', 'none');
@dirtystylus
dirtystylus / vs-code-key-bindings.json
Last active February 20, 2017 20:39
VS Code Key Bindings
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "shift+alt+down", "command": "cursorColumnSelectDown", "when": "editorTextFocus" },
{ "key": "shift+alt+up", "command": "cursorColumnSelectUp", "when": "editorTextFocus" },
{ "key": "cmd+l", "command": "workbench.action.gotoLine" },
{ "key": "shift+ctrl+d", "command": "editor.action.copyLinesDownAction", "when": "editorTextFocus && !editorReadonly" },
{ "key": "ctrl+cmd+down", "command": "editor.action.moveLinesDownAction", "when": "editorTextFocus && !editorReadonly" },
{ "key": "ctrl+cmd+up", "command": "editor.action.moveLinesUpAction", "when": "editorTextFocus && !editorReadonly" },
{ "key": "shift+cmd+[", "command": "workbench.action.previousEditor" },
{ "key": "shift+cmd+]", "command": "workbench.action.nextEditor" },
/* Modular Scale */
$ms-base: 1.125em;
$ms-ratio: $golden;
$ms-range:
1.05 20em,
1.33 81.25em;
.entry-meta {
@include ms-respond(font-size, -1);
@dirtystylus
dirtystylus / Drupal 7: Child CSS Class for Parent LI
Last active December 25, 2015 14:39
Pulls the class elements from child <a> element and puts them on the parent <li> item. Useful if you want classes you added with the menu_attributes module to be used on the parent <li>, since those classes are placed on the <a> element itself.
function THEME_preprocess_menu_link(&$variables) {
$element = &$variables['element'];
if (!empty($element['#original_link']['options']['attributes']['class'])) {
foreach($element['#original_link']['options']['attributes']['class'] as $class) {
$element['#attributes']['class'][] = $class;
}
}
}
@dirtystylus
dirtystylus / Drupal 7: Add Menu Title to LI elements
Last active December 25, 2015 14:39
Add Menu Title to LI elements.
/**
* Add unique class (mlid) to all menu items.
* with Menu title as class
*/
function THEME_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
$name_id = strtolower(strip_tags($element['#title']));
// remove colons and anything past colons
if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':'));