Skip to content

Instantly share code, notes, and snippets.

@mintindeed
mintindeed / example.conf
Created May 29, 2013 20:03
Example nginx 0.9.x config for accessing memcached caches directly
index index.php index.html index.htm;
upstream phpfcgi {
server 127.0.0.1:9000;
}
upstream memcached {
server example.compute-1.amazonaws.com:11211 max_fails=1 fail_timeout=2s;
server example.compute-1.amazonaws.com:11211 max_fails=1 fail_timeout=2s;
}
@mintindeed
mintindeed / gist:5646226
Created May 24, 2013 20:17
WordPress - query the top 100 tags, determined by number of times the tag has been used. Can be modified easily to report on custom taxonomies.
select tt.`count`, t.name from `wp_term_taxonomy` tt join wp_terms t on (tt.term_id=t.term_id) where tt.taxonomy='post_tag' order by tt.`count` desc limit 100;
@mintindeed
mintindeed / is_valid_url.php
Created March 19, 2013 20:55
Determine whether a string is trying to be a URL
<?php
/**
* Determine whether a string is trying to be a URL
*
* @see http://daringfireball.net/2010/07/improved_regex_for_matching_urls
*
* @param string $url
* @return bool preg_match() returns 1 if the pattern matches given subject, 0 if it does not, or FALSE if an error occurred.
*/
function is_valid_url( $url ) {
<?php
abstract class PMC_Base {
private static $_instance = array();
private function __construct() {}
public static function get_instance() {
$class = get_called_class();
if ( ! isset( self::$_instance[$class] ) ) {
self::$_instance[$class] = new $class();
@mintindeed
mintindeed / gist:4600385
Created January 23, 2013 00:25
Bash script for git pull using username and password
#!/bin/bash
path="/var/www/sites/htdocs/wp-content/themes/vip/";
git_path="https://username:password@bitbucket.org/penskemediacorp/";
git_array=( plugins pmc-variety pmc-plugins );
git_path_array=("${git_array[@]}")
#!/bin/bash
PLUGIN_DIR="/cygdrive/r/bgr/plugins"
SITE_ROOT="/cygdrive/r/bgr/bgr2010"
DRY_RUN=01
if [[ "$DRY_RUN" -eq "0" ]] ; then
DRY_RUN=""
else
DRY_RUN="--dry-run"
#!/bin/bash
WP_UPGRADE_ROOT="/cygdrive/r/bgr/wordpress-3.3.1"
SITE_ROOT="/cygdrive/r/bgr/bgr2010"
PATCH_ROOT="/cygdrive/r/bgr"
DRY_RUN=01
if [[ "$DRY_RUN" -eq "0" ]] ; then
DRY_RUN=""
else
@mintindeed
mintindeed / Add to Common Functions
Created December 5, 2012 01:20 — forked from vickybiswas/Add to Common Functions
Fix for broken menu_order
/**
* WP 3.5 doesn't update menu_order for ordering attachments, so this function updates the menu_order so that you can orderby menu_order
* @param int $id
*/
function pmc_gallery_menu_order_fix($id) {
$regex_pattern = get_shortcode_regex();
preg_match ('/'.$regex_pattern.'/s', stripslashes($_POST['content']), $regex_matches);
if ( ! $regex_matches ) {
return false;
}
@mintindeed
mintindeed / gist:3820638
Created October 2, 2012 16:22
AL get_hero_image() usage
<?php
$args = array(
'post_id' => get_the_ID(),
'size' => 'article-hero'
);
$hero_image = PMC_Awardsline::get_hero_image( $args, 'featured', 'array' );
if ( $hero_image ) {
?>
<figure class="a-center">
<img src="<?php echo esc_url( $hero_image['src'] ); ?>" width="602" height="360" alt="<?php echo esc_attr( $hero_image['alt'] ); ?>" />
success: function() {
// load stories here
// Build the current image
var real_path = document.location.href.replace("#!/", "");
// Track PV in Omniture
try {
s_mmc.pageName = real_path;
s_mmc.t();