Skip to content

Instantly share code, notes, and snippets.

View jasonglisson's full-sized avatar

Jason Glisson jasonglisson

View GitHub Profile
@jasonglisson
jasonglisson / 0_reuse_code.js
Created May 28, 2014 19:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jasonglisson
jasonglisson / click_function.js
Last active September 14, 2017 12:41
Click function in jquery
$( "#target" ).click(function() {
alert( "Handler for .click() called." );
});
@jasonglisson
jasonglisson / click_slidetoggle.js
Created May 29, 2014 00:54
Slide toggle on click
$( "#clickme" ).click(function() {
$( "#book" ).slideToggle( "slow", function() {
// Animation complete.
});
});
@jasonglisson
jasonglisson / query_post_type.php
Last active September 14, 2017 12:33
Wordpress: Query Post Types
$args = array( 'post_type' => 'product', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;
@jasonglisson
jasonglisson / save_node.php
Last active September 14, 2017 01:57
Drupal 7: Create and save node programmatically
<?php
/**
* Basic Node Creation Example for Drupal 7
*
* This example:
* - Assumes a standard Drupal 7 installation
* - Does not verify that the field values are correct
*/
$body_text = 'This is the body text I want entered with the node.';
@jasonglisson
jasonglisson / git_rsync
Created May 29, 2014 01:21
Rsync using Git
git diff --name-only v0.3 v0.4 | xargs -I{} rsync -Rv "{}" ~/Desktop/destination-dir/
@jasonglisson
jasonglisson / max_character_title.php
Last active September 14, 2017 12:33
Wordpress: Set Maximum Post Title Length
function maxWord($title){
global $post; $title = $post->post_title;
if (str_word_count($title) >= 10 ) //set this to the maximum number of words
wp_die( __('Error: your post title is over the maximum word count.') );
}
add_action('publish_post', 'maxWord');
// Get # parameter
var param = document.URL.split('#')[1];
@jasonglisson
jasonglisson / wordpress_htaccess
Last active September 14, 2017 01:57
Wordpress: Default htaccess file http://codex.wordpress.org/htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
@jasonglisson
jasonglisson / facebook_share_link
Last active September 14, 2017 01:58
Facebook: Link to open share dialog. Can be used in email, websites, etc. u=URL t=Title