Skip to content

Instantly share code, notes, and snippets.

@joemcgill
joemcgill / .bash_prompt
Created December 13, 2013 19:21
Custom bash prompt, inspired by Paul Irish's dotfiles repo.
#!/bin/bash
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
default_username='joemcgill'
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
@joemcgill
joemcgill / form_validation_browser_plug
Created November 27, 2013 18:04
When using HTML5 forms elements and validation, interrupt a browser's default invalidation message and plug in your own validation code (e.g., append an invalid class to the input and style accordingly).
document.addEventListener('invalid', (function(){
return function(e){
//prevent the browser from showing default error bubble/ hint
e.preventDefault();
// optionally fire off some custom validation handler
myvalidationfunction(e);
};
})(), true);
@joemcgill
joemcgill / README.md
Created November 22, 2013 07:16 — forked from oodavid/README.md
Steps for deploying a site with Git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@joemcgill
joemcgill / wp_kill_parent_post
Created November 17, 2013 05:51
Remove a custom post type from a parent theme in WordPress.
add_action('after_setup_theme', 'wp_kill_parent_post');
function wp_kill_parent_post() {
remove_action('init', '<% parent post name %>');
}
// Register your own version in place of the parent post type if you want
@joemcgill
joemcgill / Customize TinyMCE in WP
Last active October 14, 2016 08:11
Set of functions for easily customizing the tinyMCE editor in WordPress. More references: Wes Bos – http://wesbos.com/custom-wordpress-tinymce-wysiwyg-classes/ TinyMCE Reference – http://www.tinymce.com/wiki.php/TinyMCE3x:Buttons/controls
// add style selector drop down
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
// customize the MCE editor
function my_customize_mce( $init ) {
@joemcgill
joemcgill / location.attr reference
Created October 14, 2013 22:21
Nice reference of browswer location attributes cribbed from this Stack Overflow thread: http://stackoverflow.com/questions/406192/how-to-get-the-current-url-in-javascript
http://www.refulz.com:8082/index.php#tab2?foo=123
Property Result
-------------------------------------------
host www.refulz.com:8082
hostname www.refulz.com
port 8082
protocol http
pathname index.php
@joemcgill
joemcgill / Bootstrapped Contact Forms 7
Last active May 16, 2016 14:02
Boilerplate form code for the WP Contact Forms 7 plugin that makes use of Bootstrap styles
<div class="form-group">
<label for="your-name">My Name</label>[text your-name class:form-control]
</div>
<div class="form-group">
<label for="your-email">Email Address</label>[email your-email class:form-control]
</div>
<div class="form-group">
<label for="your-message">Your Message</label>[textarea your-message class:form-control]
@joemcgill
joemcgill / parse_youtube_url
Created September 16, 2013 20:30
A handy javascript function for parsing YouTube urls and returning just the video URI (adapted from: http://stackoverflow.com/posts/9102270/revisions).
function parse_youtube_url(url) {
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=v=|\&v=)([^#\&\?]*).*/;
var match = url.match(regExp);
if (match&&match[2].length==11){
return match[2];
}else{
//error
}
}

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@joemcgill
joemcgill / WP custom post time
Created May 25, 2013 16:52
A custom post time function for WordPress that allows you to change the output for posts that are published today.
/**
* custom post time function
*
* @uses global $post, get_the_time() and get_the_date()
* @vars $d (for custom date formatting), $t (for custom time formatting)
* @returns $my_post_time
*/
function my_post_time($d, $t) {
global $post;