Skip to content

Instantly share code, notes, and snippets.

View jamesmehorter's full-sized avatar

James Mehorter jamesmehorter

  • Penske Media Corporation
  • Northport, Maine
View GitHub Profile
@joshlevinson
joshlevinson / .bash_profile
Last active April 21, 2023 12:04
WP CLI + Xdebug
# Add this to /config/bash_profile
function wpd {
export XDEBUG_CONFIG="idekey=VVVDEBUG remote_connect_back=1"
wp "$@"
unset XDEBUG_CONFIG
};
# Run these commands:
# vagrant ssh
# sudo cp /srv/config/bash_profile /home/vagrant/.bash_profile
# source ~/.bash_profile
@anchetaWern
anchetaWern / laravel-ums.markdown
Created December 6, 2012 11:14
Building a User Management System in Laravel

There's no shortage of good resources for learning laravel. So instead of the usual introductory tutorial were just gonna learn Laravel by building a project from scratch and that's gonna be a User Management System.

I don't know if my definition of a User Management System is correct but here's my idea of what's it's capable of doing:

  • Register Roles
  • Register Users
  • Update Users

What you're going to do is you're going to create a list that has the section name and the color space separated, with each pair comma separated. This will allow us to loop over each item and do something with it. See Lists and Control Directives for the technical explanation as to what's going on. The nth() function says I want a specific piece of this list, in our case the 1st part of the list is the section we want, and the second part is the color. We wrap the first nth() function in #{} to tell Sass that we want to use the value of nth($section, 1) instead of the string 'nth($section, 1'.

$sections: 'div' red, 'section' green, 'article' blue;

@each $section in $sections {
  .wrapper-#{nth($section, 1)} {
    background-color: nth($section, 2);
  }
}
@ninnypants
ninnypants / functions.php
Created April 6, 2012 16:33
Clean up empty tags in the_content
<?php
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
// clean up p tags around divs
$content = str_replace(array('<p><div', '</div></p>'), array('<div', '</div>'), $content);
$content = force_balance_tags($content);
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@freekrai
freekrai / multisite_functions.php
Created July 19, 2011 14:20
Some handy wordpress multisite functions
<?php
$posts = multisite_latest_post( array(
"how_many"=>10,
"how_long_days"=>30,
"how_many_words"=>50,
"more_text"=>"[...]",
"remove_html"=>true,
"sort_by"=>"post_date",
// if paginating:
"paginate"=>true,