Skip to content

Instantly share code, notes, and snippets.

@kaseybon
kaseybon / abbreviation.html
Last active January 31, 2019 14:45
Examples of good and bad markup.
<p>The <abbr title="Described and Captioned Media Program">DCMP</abbr> provides services designed to support and improve the academic achievement of students who are blind, visually impaired, deaf, hard of hearing, or deaf-blind.</p>
@kaseybon
kaseybon / flyout-closed.html
Last active January 16, 2019 18:20
Example of an interactive component using ARIA attributes.
<button class="flyout-button"
id="browseTopics"
aria-expanded="false">Browse Topic</button>
<div class="flyout"
aria-labelledby="browseTopics"
aria-hidden="true" >...</div>
@kaseybon
kaseybon / svg-img-fallback.js
Created November 6, 2017 19:09
Uses modernizr to swap the file extension of an svg image if svg is not supported.
if(!Modernizr.svg) {
$('img[src*="svg"]').attr('src', function() {
return $(this).attr('src').replace('.svg', '.png');
});
}

Refactoring Stylesheets

To make the stylesheets easier to maintain we will transition away from the current media query breakpoint organization and content based class names. This will be done gradually as we create/modify a feature.

  • When working on an existing feature, refactor the CSS by pulling all current styles from mq breakpoint partials and creating new feature partials.
    • If needed, create "sub-partials"
      • _table.scss
      • _table-striped.scss
  • When creating/renaming classes:
  • Don't delete old class names until it is safe to do so. Leave them in place and include new class names.
@kaseybon
kaseybon / greed.rb
Last active August 29, 2015 14:14 — forked from cromwellryan/greed.rb
# My approach for the greed game was to take the values in a roll and sort them into seperate arrays. For example all the ones would be in an array, twos in an array, etc.. To keep these neat and tidy I will organize them into a hash.
# I could create a class called dice with two methods, roll and score:
#The roll method will randomly generate the numbers for the roll (I don't think this project included that but I'll add it anyways) and them store them into their arrays of similar numbers.
# The score method would be responsible for taking the sorted arrays and calculating the score then return the score.
class Dice
def initialize
@roll = {1 => [], 2 => [], 3 => [], 4 => [], 5 => [], 6 => []}
@points = 0
@kaseybon
kaseybon / structure-checker.css
Created August 28, 2014 13:59
CSS - Quickly apply background colors to check a grid layout for alignment issues.
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
@kaseybon
kaseybon / remove-menus.php
Created August 28, 2014 13:53
WordPress - Hides menu options in the WordPress backend.
// Hide unused sections in the backend
function remove_menus () {
global $menu;
$restricted = array( __('Posts'), __('Links'), __('Comments'), __('Plugins') );
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}
}
<?php if ( is_user_logged_in() ) { ?>
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','woothemes'); ?>"><?php _e('My Account','woothemes'); ?></a>
<?php }
else { ?>
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','woothemes'); ?>"><?php _e('Login / Register','woothemes'); ?></a>
<?php } ?>
@kaseybon
kaseybon / shared-taxonomies.php
Created August 3, 2014 13:16
WordPress - Share a custom taxonomy with multiple post types in place of a single $object_type.
add_action( 'init', 'create_my_taxonomies', 0 );
function create_my_taxonomies() {
register_taxonomy(
'type',
array('page, 'post', 'posttype1','posttype2'), //An array of post types that share this taxonomy
array(
'labels' => array(
'name' => 'Product Type',
'add_new_item' => 'Add New Product Type',
'new_item_name' => "New Product Type"
@kaseybon
kaseybon / redirect-index.php
Created June 13, 2014 22:00
Add to WordPress index.php to redirect the blog page to the first blog post.
<?php
require('./wp-blog-header.php');
if (have_posts()) : the_post();
header("location: ".get_permalink());
exit;
endif;
?>