Skip to content

Instantly share code, notes, and snippets.

View davehewy's full-sized avatar

David Heward davehewy

View GitHub Profile
@davehewy
davehewy / wp_custom_profile
Created June 13, 2012 13:59
WP Custom Profile Fields
<?php
/*
Plugin Name: Custom Profile Fields
Plugin URI: http://bytewire.co.uk/wordpress/plugins/custom-profile-fields/
Description: Create custom fields in the WP admin back panel for users.
Version: 1.0
Author: David Heward
Author URI: http://davidheward.com
Text Domain: custom-profile-fields
@davehewy
davehewy / lsmodel
Created September 25, 2012 10:35
Lemonstand model
<?php
class BwDiscountCodes_Log extends Db_ActiveRecord {
public $strings = array(
'model_title' => 'BW Discount Codes',
'model_name' => 'discount_code_logs',
'model_code' => 'bw_discount_codes_log',
'table_name' => 'bw_discount_codes_log',
'module_name' => 'bwdiscountcodes'
@davehewy
davehewy / mandrill-send
Created September 28, 2012 14:39
Mandrill send
require_once('Mandrill.php');
echo 'loaded mandrill...';
# Set mandrill's API Key.
Mandrill::setKey('89037b32-04f2-494a-8475-f85889c3fab4');
$ret = Mandrill::call(array('type'=> 'messages', 'call'=> 'send',
"message" => array(
"html" => "hey dave",
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://localhost/table.php");
curl_setopt($ch, CURLOPT_POST, 1);
<?php
/*
Include wordpress core
*/
require_once('wp_load.php');
/* Validate a url */
function validate_url($url)
{
<?php
return array(
"siteurl" => "singapore.kidevelopment.pw",
"s3bucket" => "s3bucket",
"s3accesskey" => "s3accesskey"
);
// Example usage
$deploy_conf = include('deploy.conf.php');
@davehewy
davehewy / easyXDM.debug.js
Last active December 20, 2015 13:29
This snippet has a dependency on easyXDM (http://easyxdm.net/wp/category/examples/). Decided to wrap it in a library which has a little bit nicer handling of cross domain scripting and less home baked code to try and speed things up.
/**
* easyXDM
* http://easyxdm.net/
* Copyright(c) 2009-2011, Øyvind Sean Kinsey, oyvind@kinsey.no.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
{{ render_partial('shop:product_selection_tool') }}
<hr />
{{ render_partial('search:product_list',
{
'products': products,
'paginate': false
})
}}
{{ render_partial(
{% if states[0] is defined %}
{% for state in states %}
{% if state.id == current_state %}
<option value="{{ state.id }}" selected="selected">{{ state.name }}</option>
{% else %}
<option value="{{ state.id }}">{{ state.name }}</option>
{% endif %}
{% endfor %}
{% else %}
{% if states %}
@davehewy
davehewy / gist:7912730
Created December 11, 2013 15:46
Userdata Drupal example
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"yum update -y aws-cfn-bootstrap\n",
"# Helper function\n",
"function error_exit\n",
"{\n",
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
" exit 1\n",
"}\n",