Skip to content

Instantly share code, notes, and snippets.

@lstanard
lstanard / bash git branch
Created August 7, 2016 23:24
Add git branch name to bash prompt
function parse_git_branch {
ref=$(git status 2> /dev/null | grep -E "(On branch|detached) .*$" | grep -oE "\S*$") || return
echo "["${ref#refs/heads/}"] "
}
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
PS1='\[\033[0;33m\]$(parse_git_branch)\[\e[32m\]\W\[\e[33m\]: \[\e[0m\]'
{
"Right Option Key Sends" : 0,
"Tags" : [
],
"Ansi 12 Color" : {
"Green Component" : 0.3333333432674408,
"Blue Component" : 1,
"Red Component" : 0.3333333432674408
},
{
"auto_complete_delay": 5,
"auto_match_enabled": true,
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
@lstanard
lstanard / Sticky header demo markup
Last active March 26, 2016 19:36
Sticky header demo markup
<header class="header">
<div class="header__top">
<p>Top header bar</p>
</div>
<div class="header__primary">
<a href="#">Logo</a>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
@lstanard
lstanard / WordPress: Hide Dashboard comment activity
Last active March 16, 2016 16:27
WP action and callback function to inject CSS into admin head and hide comment activity
function remove_dashboard_comment_activity() {
echo '<style type="text/css">li.comment-count, li.comment-mod-count, #latest-comments, #wp-admin-bar-comments { display:none; }</style>';
}
add_action('admin_head', 'remove_dashboard_comment_activity');
@lstanard
lstanard / WordPress: Remove comment post type
Last active March 15, 2016 19:26
WP action and callback function to remove support for comments from the 'post' post type
function remove_comment_capability() {
remove_post_type_support('post', 'comments');
remove_post_type_support('page', 'comments');
}
add_action('init', 'remove_comment_capability');
@lstanard
lstanard / WordPress: Remove comments meta boxes
Last active March 16, 2016 16:28
WP action and callback function to remove comments meta boxes from pages and posts
function remove_comment_meta_boxes() {
remove_meta_box('commentsdiv', 'page', 'normal');
remove_meta_box('commentsdiv', 'post', 'normal');
remove_meta_box('commentstatusdiv', 'post', 'normal');
}
add_action('do_meta_boxes', 'remove_comment_meta_boxes');
@lstanard
lstanard / WordPress: Remove comments menu item
Last active March 15, 2016 19:19
WP action and callback function to remove comments from admin menu
function remove_comment_menu_page() {
remove_menu_page( 'edit-comments.php' );
}
add_action('admin_menu', 'remove_comment_menu_page');
@lstanard
lstanard / WordPress: Add custom query vars
Created March 1, 2016 22:32
Callback function and filter for adding custom query vars in WordPress
// Register custom query vars
function cs_add_query_vars($vars) {
$vars[] = 'post_date';
return $vars;
}
add_filter('query_vars', 'cs_add_query_vars');
@lstanard
lstanard / JS: WordPress select menu filtering
Last active March 1, 2016 21:47
JavaScript select menu on change for WordPress post filtering
$('select[name="post_date"]').on('change', function() {
var postDate = this.options[this.selectedIndex].value,
dateRE = /\d{4}[-]\d{1,2}|\d{4}/g,
prevDate = dateRE.exec(url);
// Drop pagination when changing the post_date filter value
if (url.indexOf('page/') > 0)
url = url.split('page/')[0];