Skip to content

Instantly share code, notes, and snippets.

View bjmiller121's full-sized avatar

BJ Miller bjmiller121

View GitHub Profile
@bjmiller121
bjmiller121 / pantheon-fix.js
Last active September 29, 2016 23:30
Bookmarklet to fix pantheon bug where links are missing on multidev dashboards.
javascript:$('.js-workspace-region-header').removeClass('hide');
@bjmiller121
bjmiller121 / drupal-login.js
Created February 29, 2016 22:33
Drupal login bookmarklet which takes you to the login page and sets the current page as the destination so you get placed back on the page you logged in from.
javascript:window.location.href = window.location.protocol + "//" + window.location.host + "/user?destination=" + window.location.pathname;
@bjmiller121
bjmiller121 / uncheck-autodetect.js
Created February 25, 2016 00:10
Bookmarklet to uncheck all auto-detected Features dependencies
javascript:(function($){$('.component-detected').prop('checked', false)})(jQuery);
@bjmiller121
bjmiller121 / breakpoint-classes.js
Last active January 16, 2016 00:53
Breakpoint body classes
/**
* Add breakpoint classes to the body as a utility.
*
* Requires jQuery and underscore
*/
Breakpoints = {
'mobileMax': 639,
'tabletMin': 640,
'tabletMax': 960,
@bjmiller121
bjmiller121 / _README.md
Last active December 7, 2015 17:35
Hover dropdown with dropdown content outside of target element

This is a method of displaying dropdowns via javascript when the content to be revealed is not contained within the element triggering the reveal as in your typical dropdown situation. This method uses the jQuery doTimeout() plugin to handle the hiding and showing on hover of the trigger element in order to help cancel the close event when the mouse is over the revealed content. It also handles throttling and hoverintent.

Codepen Example: https://codepen.io/anon/pen/LGPgxN

"installed_packages":
[
"BracketHighlighter",
"Color Highlighter",
"ColorPicker",
"Comments Aware Enter",
"D3.js Snippets",
"DashDoc",
"Diffy",
"DobDark Color Scheme",
@bjmiller121
bjmiller121 / placecage.sublime-snippet
Created October 28, 2015 01:33
Placeholder image snippet for Sublime Text
<snippet>
<content><![CDATA[
<img src="http://www.placecage.com/${1:300}/${2:300}" alt="Place Cage!">
]]></content>
<tabTrigger>placecage</tabTrigger>
</snippet>
@bjmiller121
bjmiller121 / multiple_files_update_hook.php
Last active September 29, 2015 02:16
Creating multiple fields and field instances in an update hook
// Define new fields
$new_fields = array(
'field_NAME_OF_FIELD' => array(
'entity_type' => 'node',
'bundle' => 'page',
'field_definition' => array(
'type' => 'text',
// Other field details here. Exact keys depend on the type of field being added.
// Best thing to do is create one on your local exactly how you want it (through
// the UI), and then running field_read_field() and copying data below.
@bjmiller121
bjmiller121 / multiple-push-urls.md
Last active March 4, 2024 05:47
Add multiple push URLs to a single git remote

Sometimes you need to keep two upstreams in sync with eachother. For example, you might need to both push to your testing environment and your GitHub repo at the same time. In order to do this simultaneously in one git command, here's a little trick to add multiple push URLs to a single remote.

Once you have a remote set up for one of your upstreams, run these commands with:

git remote set-url --add --push [remote] [original repo URL]
git remote set-url --add --push [remote] [second repo URL]

Once set up, git remote -v should show two (push) URLs and one (fetch) URL. Something like this:

@bjmiller121
bjmiller121 / jquery.slideHeight.js
Created July 14, 2015 20:03
Re-implementation of jQuery slideUp() and slideDown() to avoid display: none;
/*
A re-implementation of jQuery's slideDown() and slideUp() that animates the
height of an element without requiring the use of display: none;
Helpful when needing to hide a video player while maintaining control via an
API.
The element must have "overflow: hidden;" set in CSS for this to work properly.
In order to have the element hidden by default, you mist also set "height: 0;"
in CSS as well.