Skip to content

Instantly share code, notes, and snippets.

@dougkeeling
dougkeeling / 0_reuse_code.js
Created January 14, 2014 20:23
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
@dougkeeling
dougkeeling / css_resources.md
Created January 14, 2014 20:23 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@dougkeeling
dougkeeling / play_vids.js
Created July 10, 2018 13:23
[Make background videos work in iOS/Android] Script to be placed in footer #video #php #mobile #html
// Place in footer
var mobilevideo = document.getElementsByTagName("video");
var i;
for (i = 0; i < mobilevideo.length; i++) {
mobilevideo[i].setAttribute("playsinline", "");
}
// Alternate, gets only the first video
var mobilevideo = document.getElementsByTagName("video")[0];
mobilevideo.setAttribute("playsinline", "");
@dougkeeling
dougkeeling / terminal.app
Last active November 20, 2018 17:50
[Set default WP file permissions] Run commands within the root Wordpress folder. #wordpress
sudo find . -type f -exec chmod 664 {} +
sudo find . -type d -exec chmod 775 {} +
sudo chmod 660 wp-config.php
@dougkeeling
dougkeeling / scrollmagic.js
Created June 18, 2020 14:59
[ScrollMagic loop over elements] Loop through elements with a given class and add animations to them. Be sure each item in the loop has a unique ID. #scrollmagic #javascript #jquery
$('.my-class').each(function(){
var id = $(this).attr('id');
scenes[scenes.length] = new ScrollMagic.Scene({triggerElement: '#'+id, duration: 0, triggerHook: 0.9, reverse: false})
.setClassToggle('#'+id, "animate");
});
@dougkeeling
dougkeeling / functions.php
Last active August 11, 2020 15:42
[Populate an ACF select field with Gravity Form ID] When all you need is the ID of a Gravity Form in an ACF select field, here's a basic solution that works very well, without having to use a full-blown Gravity Forms field plugin. Simply add a class of "gravity-form-select" to your field and it will be populated automatically. #gravityforms #wor…
function my_acf_load_gravity_forms_select( $field ) {
// This feels slightly hacky, but it works.
//
// If your select field has the wrapper class "gravity-form-select",
// it will be intercepted and any values will be replaced by a list of
// your form IDs and Titles.
//
// You could choose to intercept a select field with a specific name or
// field key, but I prefer this method because you can use it on multiple
@dougkeeling
dougkeeling / scripts.js
Created December 4, 2020 18:20
[Truncate overflowing text boxes] Combination of JS, CSS, and HTML to modify responsive textboxes that need to be limited to a specific height, based on font-size and line-height #javascript #jquery #css #html
jQuery(function($){
function truncateToEllipsis(textboxes) {
function doTruncate(containers) {
for (var i = 0; i < containers.length; i++) {
var cntnr = $(containers[i]);
// The original content for this textbox should be place in an attribute
// called "data-text". The script will modify the original content, so we
@dougkeeling
dougkeeling / acf.php
Created August 17, 2021 18:17
[Get ACF Field from Menu Location] For fields assigned to menu locations (not to menu items). #acf #wordpress #php
// Menus are saved as terms, so get the term object first
$menu = get_term_by('name', 'Slideout Menu', 'nav_menu');
// Get field as you would from a normal taxonomy term, in the format "term_XX"
$field = get_field( 'field_name', 'term_'.$menu->term_id);
@dougkeeling
dougkeeling / mixins.scss
Created August 31, 2021 17:25
[Convert Font Size to Em] #scss #css
$browser-context: 16;
@function em($pixels, $context: $browser-context) {
@if (unitless($pixels)) {
$pixels: $pixels * 1px;
}
@if (unitless($context)) {
$context: $context * 1px;
}
@dougkeeling
dougkeeling / mixins.scss
Created August 31, 2021 17:29
[Cover one <div> with another completely] Allows for a specific amount of padding/inset from the edge of the parent div. #scss #css
@mixin cover($pos:absolute,$inset:0px) {
position: $pos;
bottom: $inset;
left: $inset;
right: $inset;
top: $inset;
width: calc(100% - (#{$inset} * 2));
height: calc(100% - (#{$inset} * 2));
}