Skip to content

Instantly share code, notes, and snippets.

@joeyblake
joeyblake / gist:11402110
Created April 29, 2014 14:30
Redirect all subdomains to main domain: ExpressJS/Ghost
/*
* redirect all subdomains example
* example domain name testsite.com
*/
// split the incoming host to get the first element
var incoming = req.headers.host.split('.')[0];
// check if it matches your domain
if ( incoming !== 'testsite' ) {
@joeyblake
joeyblake / gist:9622208
Created March 18, 2014 15:22
Customizing SharePress og:meta tags with custom fields
//Add this to your theme's functions.php file
//Modify the function to add the custom field value you are looking for
add_filter('sharepress_og_tags', 'my_sharepress_og_tags');
function my_sharepress_og_tags( $og ) {
global $post;
$custom_value = get_post_meta($post->ID, 'your custom field name', true);
$og = array_merge($og, array(
'og:title' => $og['og:title'] . " " . $custom_value
@joeyblake
joeyblake / gist:9474346
Created March 10, 2014 21:08
responsive facebook comments
.fb-comments, .fb-comments iframe[style] {
width: 100% !important;
}
/**
* If you cannot clean up your open graph meta tags, adding this filter to the functions.php file in your theme will keep
* SharePress from verifying the open graph data.
* Caution: Bad use of open graph meta tags could possibly cause unexpected results in shared images and titles on facebook.
*/
add_filter('sp_auto_flush_fb', '__return_false');
/**
* add this to the functions.php file in your theme to disable fb comments open graph metadata
*/
add_filter('fbc_og_tags', '__return_false');
@joeyblake
joeyblake / Sample multiple 301 redirects in Ghost
Created January 30, 2014 04:31
Multiple 301 redirects in Ghost
server.get('/*', function(req, res, next) {
var fullURL = req.protocol + "://" + req.get('host') + req.url;
//your 301 redirects
var redirects_301 = {
'http://thinkingandmaking.com/working/92/72-questions-to-ask-on-your-first-day': '/view/72-questions-to-ask-on-your-first-day',
'http://thinkingandmaking.com/working/92/someother': '/view/someother'
}
//check and see if there is a redirect, if so, redirect to it!
if (redirects_301[fullURL]) {
res.redirect(301, redirects_301[fullURL]);
@joeyblake
joeyblake / gist:7993402
Created December 16, 2013 20:04
SharePress facebook cache bypass filter
add_filter('sp_auto_flush_fb', '__return_false');
@joeyblake
joeyblake / gist:2854349
Created June 1, 2012 18:50 — forked from coreyweb/gist:2718955
WordPress Popular Comments
<?php
/**
* Display a list of the 10 most commented posts (WordPress)
* @author Corey Brown https://github.com/coreyweb
* @author Aaron Collegeman: https://github.com/collegeman
* @author Joey Blake: https://github.com/joeyblake
*
* Rules:
* - show a list of 10 posts
* - published any time
<?php foreach ( $recipe_vars['instructions'] as $instruction ) { ?>
<p itemprop="recipeInstructions" >
<?php
if ($instruction['image_id'] != ""){
$inst_image = wp_get_attachment_image_src( $instruction['image_id'], "medium", false );
echo "<img src='{$inst_image[0]}' style='float:left;' /> ";
}
if (count($instruction['text']) > 1 ) {
echo '<ol>';
foreach ($instruction['text'] as $numbered_inst ){
@joeyblake
joeyblake / hostfix
Created February 27, 2012 16:13
Shell script for cleaning/resetting /etc/hosts files messed up by MAMP Pro
#!/bin/bash
# copy this file to /usr/sbin
# if you have other hosts entries that you would not like to lose, make sure they get added to the hosts.mamp.bak file
cat /etc/hosts.mamp.bak > /etc/hosts
echo 'clean!'