Skip to content

Instantly share code, notes, and snippets.

View megclaypool's full-sized avatar

Meg Claypool megclaypool

View GitHub Profile
@megclaypool
megclaypool / responsive_nav.css
Last active July 16, 2021 16:08
[Bootstrap Responsive Sidebar Menu]
body,html {
height: 100%;
}
/* remove outer padding */
.main .row {
padding: 0;
margin: 0;
}
@megclaypool
megclaypool / 0_reuse_code.js
Created May 21, 2017 05:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@megclaypool
megclaypool / gist:54d7b4e209a825985b3c6b7ab9898cd2
Last active July 16, 2021 16:09 — forked from CristinaSolana/gist:1885435
[Keeping a fork up to date]

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@megclaypool
megclaypool / gist:da2485541a765d12018f71fc29e07ecb
Created March 8, 2018 15:55 — forked from aczietlow/gist:1d2c8f7694e1471f2874
Behat tests for checkout css properties
<?php
/**
* @Given /^The element "(?P<selector>[^"]*)" should have a css property "(?P<property>[^"]*)" with a value of "(?P<value>[^"]*)"$/
*
* @TODO Need to find a way to test for css styles on elements.
* Or possibly we should just be checking the markup, and not the styling... Research this more.
*/
public function assertElementHasCssValue($selector, $property, $value)
{
$page = $this->getSession()->getPage();
@megclaypool
megclaypool / styles.scss
Last active May 18, 2018 15:31
SCSS button sprite background position and size adjustments This lets you set a desired button height as a variable. Then it stretches and repositions the button background image sprite based on the desired height so that the button looks as it shou
$sprite-color-position: 1;
$sprite-section-height: 33;
$sprite-total-image-height: 198;
$desired-button-height: 66px;
background-position: 0 calc (-3 * #{$desired-button-height});
background-size: 2px calc(#{$sprite-total-image-height}px * 2);
background-position: 0 calc(-1 * (#{$sprite-color-position} - 1) * #{$sprite-section-height}px / #{$desired-button-height});
// background size: width height;
height: $desired-button-height;
@megclaypool
megclaypool / button-background-resizer.js
Last active May 18, 2018 15:31
Dynamic button background resizer (Javascript) This script measures the rendered height of a button element (which, if someone puts long content in the button, might render taller than planned for!). Then it stretches and repositions the button back
// This script measures the rendered height of a button element (which, if someone puts long content in the button, might render taller than planned for!). Then it stretches and repositions the button background image sprite based on the rendered height so that the button looks as it should. The numbers come from the button sprite at https://essentialaccess.org/themes/essentialaccess/dist/images/button_sprite.jpg but could be rejiggered for any sprite as long as all the sprite sections were of a consistent height.
// Notes:
// From Algebra 2, you may remember function transformations (No? Huh...) When you're trying to graph a transformed function, first you apply the dilation (stretching/shrinking) and then the translation (scooting). Similarly, first we'll do the background-size and then the background-position.
// For the purposes of this script, the css background-size property takes two arguments: width and height. The width of te sprite I'm using is 2px. We divide the actual height of our element by t
@megclaypool
megclaypool / FailedStepScreenshotDefinition.php
Last active April 18, 2018 18:48
Add this definition to your FeatureContext.php to take a screenshot of failed steps for your Behat/Selenium2 tests. It creates a directory called "screenshots" in your project directory (if one doesn't already exist) and within it places screenshots whose filenames consist of the date and time as well as the name of the failed step.
/**
* @AfterStep
*/
public function takeScreenShotAfterFailedStep(afterStepScope $scope)
{
if (99 === $scope->getTestResult()->getResultCode()) {
$driver = $this->getSession()->getDriver();
$filePath = getcwd() . DIRECTORY_SEPARATOR . 'screenshots';
@megclaypool
megclaypool / browserResizeDefinition.php
Last active April 18, 2018 18:42
This Behat definition resizes the browser. I've discovered that Chrome defaults to a fairly wide browser whereas PhantomJS defaults to a very narrow browser... Either way, it's important to be able to resize the browser window so you can get specific versions of your sites/menus *on purpose* rather than by accident!
// Include the following step definition in your FeatureContext.php file:
/**
* @Given /^I set browser window size to "([^"]*)" x "([^"]*)"$/
*/
public function iSetBrowserWindowSizeToX($width, $height)
{
$this->getSession()->resizeWindow((int)$width, (int)$height, 'current');
}
@megclaypool
megclaypool / external.twig
Last active May 18, 2018 15:31
Calling an External Twig File for an ACF Repeater Field How to include an external twig file for the contents of a repeater field. (WordPress, Twig, Timber, Advanced Custom Fields, ACF, Radicati)
Template:
{% if <codename-1> %}
<ul class="social-links-menu">
{% for <codename-2> in <codename-1> %}
<li>
<a href="{{<codename-2>.<repeater-subfield>}}">
{{ <codename-2>.<some-other-repeater-subfield> }}
</a>
</li>
{% endfor %}
@megclaypool
megclaypool / Instructions
Last active July 16, 2021 14:54
How to update a Rootid Drupal 8 site (Pantheon one-click update merge conflicts)
We're installing our Pantheon D8 sites in /web to **provoke** merge conflicts and thus prevent us from appliying Pantheon's one click updates from the dashboard. We're using composer to manage our D8 sites, which is incompatible with the one-click updates. (So this isn't a bug, it's a feature!) Happily, we're pretty sure that Pantheon have moved all their magical secret sauce into modules and the settings file. In theory, none of it is in core anymore.
Instead:
1. Pull a copy of the site onto your local
2. Navigate to the /web directory of your site
3. Use `composer update drupal/core --with-dependencies` to update using composer
- Unfortunately, Composer sometimes installs nested .git directories, which make Pantheon very unhappy. So after you've updated, you need to find and remove any nested .git directories:
4. Run `find . -name .git -type d -prune` to get a list of any new .git directories hiding in the bowels of your install. You might see something like: `/web/vendor/afdafaf/adsfasdfdas/.