Skip to content

Instantly share code, notes, and snippets.

@mfields
mfields / gist:1184759
Created August 31, 2011 21:27
Enqueue css for a custom post_type in edit.php
<?php
add_action( 'load-edit.php', 'myplugin_setup_edit_screen' );
function myplugin_setup_edit_screen() {
$screen = get_current_screen();
if ( 'my_post_type' != $screen->post_type ) {
return;
}
add_action( 'admin_print_styles', 'myplugin_edit_screen_css' );
@evansolomon
evansolomon / .bashrc
Created April 1, 2012 08:36
Bash prompt
PROMPT_COMMAND='DIR=`pwd|sed -e "s!$HOME!~!"`; if [ ${#DIR} -gt 30 ]; then CurDir=${DIR:0:12}...${DIR:${#DIR}-15}; else CurDir=$DIR; fi'
# show git branch name in prompt
PS1='\[\e[1;32m\]\u: $CurDir $(__git_ps1 " (%s)")\$\[\e[0m\] '
# make bash autocomplete with up arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
# make tab cycle through commands instead of listing
<ul>
<?php foreach($pages->visible() AS $p): ?>
<li>
<a<?php echo ($p->isOpen()) ? ' class="active"' : '' ?> href="<?php echo $p->url() ?>"><?php echo html($p->title()) ?></a>
<?php if($p->children()->visible()->count()): ?>
<ul>
<?php foreach($p->children()->visible() AS $item): ?>
<li><a<?php echo ($item->isOpen()) ? ' class="active"' : '' ?> href="<?php echo $item->url() ?>"><?php echo html($item->title()) ?></a></li>
@pce
pce / .bash_alias
Created May 30, 2012 23:44
cat ~/.bash_alias >> ~/.bashrc && source ~/.bashrc
# duh - disk usage humanreadable, source 'inataysia' reddit
alias duh='du -sk * | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done'
@phred
phred / pedantically_commented_playbook.yml
Last active June 27, 2024 13:39
Very complete Ansible playbook, showing off all the options
---
####
#### THIS IS OLD AND OUTDATED
#### LIKE, ANSIBLE 1.0 OLD.
####
#### PROBABLY HIT UP https://docs.ansible.com MY DUDES
####
#### IF IT BREAKS I'M JUST SOME GUY WITH
#### A DOG, OK, SORRY
####
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active June 5, 2024 22:16 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@evansolomon
evansolomon / gist:3186427
Created July 27, 2012 06:11
Generic function to add body classes on the fly in WordPress
<?php
/**
* Generic function to add body classes
* Can take either a string of space-separated classes or an array
*
* Requires PHP 5.3 for access to closures
*/
function es_add_body_class( $new_classes ) {
// Turn the input into an array we can loop through
@syamilmj
syamilmj / generate_options_css.php
Created November 3, 2012 22:53
generate_options_css()
function generate_options_css($newdata) {
/** Define some vars **/
$data = $newdata;
$uploads = wp_upload_dir();
$css_dir = get_template_directory() . '/css/'; // Shorten code, save 1 call
/** Save on different directory if on multisite **/
if(is_multisite()) {
$aq_uploads_dir = trailingslashit($uploads['basedir']);
@johnregan3
johnregan3 / cpt_in_wp_submenu.php
Last active December 3, 2022 07:32
Add Custom Post Type to WordPress Plugin Submenu (Hack)
<?php
/*
Plugin Name: Nerfherder Plugin
Plugin URI: https://gist.github.com/johnregan3/6133389
Description: Demonstration of how to add Custom Post Types to Submenu Items
Author: John Regan
Author URI: http://johnregan3.com
Version: 1.0
*/
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");