Skip to content

Instantly share code, notes, and snippets.

View ebinnion's full-sized avatar

Eric Binnion ebinnion

View GitHub Profile
@ebinnion
ebinnion / gist:4481629
Created January 8, 2013 06:07
Import large database SQL into MAMP
/applications/MAMP/library/bin/mysql -u root -p wordpress_db < /Applications/MAMP/htdocs/backupDB.sql
@ebinnion
ebinnion / category-toolbox.php
Created January 20, 2013 21:31
WordPress Loop Group of Three
<?php if (have_posts()) :
$i=0; // counter
while(have_posts()) : the_post();
if($i%3==0) { // if counter is multiple of 3, put an opening div ?>
<!-- <?php echo ($i+1).'-'; echo ($i+3); ?> -->
<div class="cf">
<?php } ?>
<div class="col3 toolbox">
<div class="head">
<h5 style="text-align:center;"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h5>
@ebinnion
ebinnion / header.php
Created January 20, 2013 21:31
WordPress Title Tag
<title><?php
if( is_home() ){
echo 'Art of Blog - The Art of How to Start and Run a Blog';
}
else if ( is_category() ) {
$category = get_the_category();
echo $category[0]->cat_name . ' | Optiniche';
}
else {
single_post_title() .' | Art of Blog';
@ebinnion
ebinnion / style.css
Created January 20, 2013 23:51
Form CSS Chronicl
input,textarea {
font-size: 1em;
margin-bottom: 1em;
border-radius: 4px;
}
input[type="text"] {
margin-right: .5em;
}
@ebinnion
ebinnion / gist:4582703
Created January 21, 2013 00:02
Create WordPress Sidebar Shortcode
function sidebar_shortcode() {
$output = '<div class="viral-sidebar">';
ob_start();
dynamic_sidebar( 'sidebar_shortcode' );
$output .= ob_get_contents();
ob_end_clean();
$output .= '</div>';
return $output;
}
add_shortcode('viral_sidebar', 'sidebar_shortcode');
@ebinnion
ebinnion / gist:4590551
Created January 21, 2013 23:30
Enqueue Script and Js in Plugin
add_action('template_redirect', 'audience_intel_add_js');
function audience_intel_add_js() {
// enqueue script
wp_enqueue_script( 'audience_intel_js',
plugins_url( 'js/script.js' , __FILE__ ),
array('jquery'), audience_intel_version, true
);
// Get current page protocol
$protocol = isset( $_SERVER["HTTPS"] ) ? 'https://' : 'http://';
@ebinnion
ebinnion / gist:4601825
Created January 23, 2013 04:05
WordPress Top Commenters Code
function top_comment_authors($amount = 5){
global $wpdb;
$results = $wpdb->get_results('
SELECT
COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url
FROM
'.$wpdb->comments.'
WHERE
@ebinnion
ebinnion / terminal.txt
Last active December 12, 2015 07:58
Ubuntu Rsync Command. This command was used to backup computers in the MSU CS server room. Command will login to remote server, create a tar of the directory, then put the tar in the specified backup director (/backup in this case).
sudo rsync -arv -e "ssh" --rsync-path="sudo rsync" user@host:/home /backup
@ebinnion
ebinnion / Git Cheat Sheet
Last active December 13, 2015 23:19
A short list I'll manage of my most used git commands
git init - "Self explanatory"
git remote add origin [git_url] - "Adds a remote repository named origin"
git add . - "Add files you want to commit"
git add -u - "Will remove deleted files from git"
git commit -m 'your message' - "Commit with a message"
git push origin master - "Push repository to Github"
git update-index --assume-unchanged [[path]] - Will ignore file from git unless explicitly added
git reset --soft HEAD^ - Deletes last commit and keeps any code changes
git commit --amend --reuse-message HEAD
@ebinnion
ebinnion / gist:5027845
Created February 25, 2013 04:58
Download and Redirect in jQuery
$(".downloadLink").click(
function(e) {
e.preventDefault();
//open download link in new page
window.open( $(this).attr("href") );
//redirect current page to success page
window.location="www.example.com/success.html";
window.focus();