This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function windowHistorySupported() { | |
// If pushState is supported, return true, else return false. | |
return !!(window.history && window.history.pushState); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
osascript -e "set Volume 3.5" | |
afplay ~/Dropbox/Sounds/itssofluffy.mp3 | |
osascript -e "set Volume 1.25" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine if a post exists based on post_name and post_type | |
* | |
* @param $post_name string unique post name | |
* @param $post_type string post type (defaults to 'post') | |
*/ | |
function post_exists( $post_name, $post_type='post' ) { | |
global $wpdb; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'menu_icon' => plugins_url('images/custom-post-type-icon.png', __FILE__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$query = new WP_Query( array( | |
'post_type' => 'event_type', | |
'post_status' => 'publish', | |
'nopaging' => true | |
) ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
// Do something with the post here... | |
endwhile; | |
wp_reset_postdata(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This resets the array's internal pointer to the first element: | |
reset( $array ); | |
This does not modify the original array, but does make a copy of it, only use it for small arrays: | |
array_shift(array_values($array)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
class PostPublisher < Generator | |
safe false | |
def replace(filepath, regexp, *args, &block) | |
content = File.read(filepath).gsub(regexp, *args, &block) | |
File.open(filepath, 'wb') { |file| file.write(content) } | |
end | |
def generate(site) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# collections_filter.rb | |
# | |
# Filter individual Jekyll collections items based on arbitrary yam front matter variables. | |
# | |
# input - the collection array | |
# property - key to filter by | |
# value - desired value | |
# | |
# Returns the filtered array of objects | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# collections_sort.rb | |
# | |
# Sort Jekyll collections items based on arbitrary yaml front matter variables. | |
# | |
# example usage: | |
# | |
# if you want to sort a collection based on a yaml variable of "order": | |
# | |
# {% assign filtered_events = site.my_collection | collection_sort: 'order' %} | |
# |
OlderNewer