Skip to content

Instantly share code, notes, and snippets.

View davidchase's full-sized avatar
📺
Working from home

David Chase davidchase

📺
Working from home
View GitHub Profile
@davidchase
davidchase / README.md
Last active April 26, 2024 04:53
cookie obj from the folks at MDN, awesome!

Mozilla Developer Network

Cookies object

Forked from here

A complete cookies reader/writer framework with full unicode support.

This framework is released under the GNU Public License, version 3 or later.

@davidchase
davidchase / bodyMenuClass.php
Created March 27, 2013 19:33
Adds the user input class from appearance>menu to the body class group, using add_filter and body_class
add_filter('body_class','get_custom_menu_classes');
function get_custom_menu_classes($classes)
{
$items = wp_get_nav_menu_items( 7 );
foreach ($items as $item):
$menuClasses = $item->classes;
$objectId = $item->object_id.' ';
if ( is_page($item->object_id) ):
@davidchase
davidchase / commitModified.bash
Created March 22, 2013 15:56
Committing only modified files in svn.. I use this to avoid committing .DS_Store files and it comes in handy a few times. Using sed and xargs.
Filename without spaces:
svn st | sed -n 's/^M//p' | xargs svn commit -m "modified"
Filename with spaces:
svn st | sed -n 's/$/"/; s/^M */"/p' | xargs svn commit -m "modified"
@davidchase
davidchase / paginationFunc.php
Created March 20, 2013 13:42
pagination inside of a function or shortcode
<?php
function paginationFunc() {
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; // setup pagination
$the_query = new WP_Query( array(
'post_type' => 'name_of_post_type', // post type custom or native
'orderby' => 'date', // how to order
'order' => 'DESC', // order ASC or DESC
'paged' => $paged,
'posts_per_page' => 2) //pages to show
);
// use for patterns:
// *gmail.com*
// *mail.google.com*
// *google.com*mail*
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 15000);
function updateDockBadge() {
@davidchase
davidchase / getPageBySlug.php
Created March 4, 2013 19:50
Wordpress get page id by its slug
<?php
//get page id's by their slug
function id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page):
return $page->ID;
else:
return null;
endif;
}
@davidchase
davidchase / wordpressResetCSS.css
Created March 4, 2013 19:49
Wordpress rest and required styles for making your own boilerplate
/* CSS Reset, Wordpress Required & Float Clear */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
@davidchase
davidchase / showHiddenFiles.sh
Created March 4, 2013 19:47
Shell Fu show hidden files and hide hidden files
#Show:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
#Hide:
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
@davidchase
davidchase / newExternalWindows.js
Created March 4, 2013 19:46
jQuery open all external links in a new window
$("a").filter(function () {
return this.hostname && this.hostname.replace(/^www\./, '') !== location.hostname.replace(/^www\./, '');
}).each(function () {
$(this).attr({
target: "_blank",
title: "Visit " + this.href + " (click to open in a new window)"
});
});
@davidchase
davidchase / bestClearfix.css
Last active December 14, 2015 12:18
CSS a nice way of using OOCSS and clearing floats
/*Cleafix
Use group for semantic purposes
*/
.group:before,
.group:after {
content:"";
display:table;
}