Skip to content

Instantly share code, notes, and snippets.

View MikeNGarrett's full-sized avatar
🤘
Rocking this project.

Mike Garrett MikeNGarrett

🤘
Rocking this project.
View GitHub Profile
/*
mobileNav.js by Matt Jordan.
*/
(function($) {
$.fn.mobileNav = function(mobileWidth) {
// Create the <select> element
var selectHTML = '<select name="mobileNav" class="mobileNav" style="display:none">',
currentHref = window.location.href,
checkSize = function() {
@MikeNGarrett
MikeNGarrett / wp_schedule_task
Created January 27, 2014 20:37
Simple WordPress Scheduled Task Structure
<?php
add_action( 'wp', 'schedule_task' );
/* Let's schedule some tasks! */
function schedule_task() {
if ( ! wp_next_scheduled( 'task_hook' ) ) {
// Add scheduled daily task
wp_schedule_event( time(), 'daily', 'task_hook');
}
}
add_action( 'task_hook', 'function_to_run' );
@MikeNGarrett
MikeNGarrett / gist:40059cae93fa8311ce5c39caaefb8594
Created May 3, 2016 14:46
Acquia DevDesktop Drush Location
$ # If you're using Drush with MAMP and DevDesktop, you'll have to either change your bash profile or (my preference) specify the path to the correct instance of Drush.
$ # This solves the "Command pm-update needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command" issue.
$ /Applications/DevDesktop/drush/drush
─────────▄──────────────▄────
────────▌▒█───────────▄▀▒▌───
────────▌▒▒▀▄───────▄▀▒▒▒▐───
───────▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐───
─────▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐───
───▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀██▀▒▌───
──▐▒▒▒▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▒▌──
──▌▒▒▐▄█▀▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐──
─▐▒▒▒▒▒▒▒▒▒▒▒▌██▀▒▒▒▒▒▒▒▒▀▄▌─
─▌▒▀▄██▄▒▒▒▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌─
@MikeNGarrett
MikeNGarrett / Contract Killer 3.md
Last active September 19, 2016 15:16 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@MikeNGarrett
MikeNGarrett / categories.txt
Created September 22, 2016 15:46
iOS 10 App Store iMessages Sticker Categories
Animals & Nature
Art
Celebrations
Celebrities
Comics & Cartoons
Eating & Drinking
Emoji & Expressions
Fashion
Gaming
Kids & Family
@MikeNGarrett
MikeNGarrett / change-cpt-to-page.php
Last active October 20, 2016 15:10
If you need to switch a WordPress custom post type from post capability to page capability, do this.
<?php
/* This doesn't work and here's why not.
*
* The missing piece here has to do with rewrite rules.
* The registration process creates new rewrite rules during the process.
* This ensures the custom post type is set up appropriately.
* Modifying the url structure (which we're doing here) to hierarchical requires a change to the rewrite rules as well.
*
* The following is the first change you need to make. The rewrite change is not included here.
*/
@MikeNGarrett
MikeNGarrett / chmod-correct-files
Last active November 21, 2016 08:49
Change file permissions to 664, directory permissions to 775
// Run this from the command line.
// h/t: http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively#answer-91966
// add read/execute to world, remove write
chmod -R u+rwX,g+rwX,o+rX-w path/
// remove read/write/execute from world
chmod -R u+rwX,g+rwX,o-rwX path/
@MikeNGarrett
MikeNGarrett / siege-ab.sh
Last active December 19, 2016 04:07
Load Testing Examples
# Siege attempts to recreate real traffic by using a CSV of urls to hit.
# This allows you to remove requests for assets, if you're running a CDN.
#
# c = concurrent users
# i = "like the internet would visit"
# b = benchmark (no delay needed)
# t = time
# f = file with urls 1 per line
siege -c100 -i -b -t120S -f urls.csv
<?php
add_filter('the_content','add_my_content');
function add_my_content($content) {
$my_custom_text = '<hr><div class="patreonpara"><p><em>PARAGRAPH TEXT</em></p><a href="LINKURL" data-patreon-widget-type="become-patron-button" class="patreonbutton"><img src="FILEURL"></a></div>';
$my_custom_text_other = 'something else';
if(is_single() && !is_home()) {
if(in_category('videos')) {
$content .= $my_custom_text_other;
} else {
$content .= $my_custom_text;