Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
mrlannigan / .gitignore
Created October 11, 2012 13:26 — forked from tehnrd/gist:3870100
Node.js http timeout
node_modules
@mrlannigan
mrlannigan / gist:3795558
Created September 27, 2012 18:27
Error Object Utility
/**
* Error Object Utility
*
* The ErrorTypes object defines the arbitrary custom error objects.
*
* Definitions:
* - Each object's key defines the property name in the export
* - Each object can have a 'constructor' property that is executed
* within the constructor of the Error object
* - All other properties of the object are extended onto the prototype
{
"cmd": ["bin/run_dev_debug.sh", "/usr/local/bin/node", "bootstrap.js"],
"selector": "source.js",
"working_dir": "/Users/Julian/Work/boomerang",
"path": "/usr/local/bin/"
}
var fs = require("fs");
var logPath = "C:\\wamp\\www\\sandbox\\node\\gigya\\log";
var dates = {};
fs.readdir(logPath, function(err, files) {
files.forEach(function(i) {
var m = i.match(/([0-9]+)/gi);
if (typeof dates[m[0]] == "undefined") dates[m[0]] = [];
@mrlannigan
mrlannigan / gist:1409150
Created November 30, 2011 13:59
Custom Query Plugin Help for oomskaap
<?php
function register_price() {
$direction = "DESC"; //Default direction
if (isset($_GET["order_dir"]) && $_GET["order_dir"] == "ASC") {
$direction = "ASC";
}
register_custom_queryable_field("price", array("dataType" => "numeric", "order" => $direction));
}
?>
@mrlannigan
mrlannigan / wpq_plain_text.js
Created June 13, 2011 08:04
WPquestions Plain Text jQuery Plugin
The plain text icon used can be downloaded from:
http://www.iconfinder.com/icondetails/9091/128/plain_text_icon
I used the 16x16 version of the above.
@mrlannigan
mrlannigan / gist:1012138
Created June 7, 2011 12:29
WPquestions.com #2394 rev1
<?php
/**** ADD FB IMAGES***/
//Adding the Open Graph in the Language Attributes
function add_opengraph_doctype( $output ) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
//Lets add Open Graph Meta Info
@mrlannigan
mrlannigan / gist:972950
Created May 15, 2011 07:38
WPquestions.com #2235 rev1
<?php // answer to wpquestions.com #2235 by Julian Lannigan (julianlannigan.com)
function coauthor_add_to_wardrobe_link() {
$currentUrl = "http".(($_SERVER["HTTPS"] == "on") ? "s" : "")."://".$_SERVER["SERVER_NAME"].(($_SERVER["SERVER_PORT"] != "80") ? ":".$_SERVER["SERVER_PORT"] : "").$_SERVER["REQUEST_URI"]; //Gets current page url
if (defined('COAUTHORS_PLUS_VERSION')) {
global $current_user;
if (is_user_logged_in()) {
//Check if they have requested to be an author
if (isset($_REQUEST['addToWardrobe']) && is_numeric($_REQUEST['addToWardrobe']) && $_REQUEST['addToWardrobe'] > 0) {
if (!is_coauthor_for_post($current_user->user_login, $_REQUEST['addToWardrobe'])) {
$cAuthors = array();
@mrlannigan
mrlannigan / gist:972433
Created May 14, 2011 17:46
WPquestions.com #2245 rev1
<?php // answer to wpquestions.com #2245 by Julian Lannigan (julianlannigan.com)
// GET THE DATA
$customFieldName = 'event_date';
$outputData = array();
$currentDate = time();
$queryArgs = array(
'posts_per_page' => -1,
'meta_query' => array(
@mrlannigan
mrlannigan / gist:947141
Created April 28, 2011 19:37
WPquestions.com #2143 rev1
<?php // answer to wpquestions.com #2143 by Julian Lannigan (julianlannigan.com)
function override_logout_form() {
wp_logout();
$logoutDestination = '/';
$redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : $logoutDestination;
wp_safe_redirect($redirect_to);
exit();
}
add_action('login_form_logout', 'override_logout_form');