Skip to content

Instantly share code, notes, and snippets.

View huntlyc's full-sized avatar

Huntly Cameron huntlyc

View GitHub Profile
@huntlyc
huntlyc / gist:2889818
Created June 7, 2012 16:16 — forked from JeffreyWay/gist:2889230
Simple PHP Quiz
// Fun little quiz
Assuming this string: "January 5th, 2012"
In the shortest amount of code possible, place:
- 'January' within a $month variable
- '5th' within a $day variable
- '2012' within a $year variable.
@huntlyc
huntlyc / .htaccess
Last active December 15, 2015 15:59
Wordpress setup Ubuntu 12.10
#This goes in your #server-config
<VirtualHost *:80>
ServerName bobswordpress.dev
ServerAdmin [email protected]
DocumentRoot /var/www/bobswordpress.dev/
ServerAlias www.bobswordpress.dev
DirectoryIndex index.html index.php
<Directory /var/www/bobswordpress.dev/>
Options FollowSymLinks
@huntlyc
huntlyc / .htaccess
Created April 1, 2013 16:56
Project: Creating A RESTful PHP Web Service With Tonic
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !dispatch\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/([^/\.]+)/([^/\.]+)/?$ dispatch.php [L,QSA]
</IfModule>
@huntlyc
huntlyc / httpd.conf
Last active December 16, 2015 03:48
wp-login.php protection
#How to get this to work...
#First create your password file:
# - Replace $FILE and $USER with your values
# $> htpasswd -c $FILE $USER
#This goes into your apache config
# - Replace /PATH/TO/$FILE with the full path (incl file) to your
# created password file
<Files "wp-login.php">
AuthUserFile /PATH/TO/$FILE
@huntlyc
huntlyc / .htaccess
Last active December 16, 2015 14:59
Custom redirects with WordPress
#Domain Redirect
<IfModule mod_rewrite.c>
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?huntlywordpress\.co\.uk$ [NC]
RewriteRule ^ http://www.huntlywordpress.com%{REQUEST_URI} [R=301,L]
</IfModule>
#EndDomain Redirect
#BEGIN custom redirects (single page)
<IfModule mod_rewrite.c>
@huntlyc
huntlyc / hs-img-upload.js
Created June 20, 2013 09:03
WP 3.5 Image upload example
/**
Uploading files
Taken from: http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/
INSTRUCTIONS:
In the page you wish to use this script you'll need to enque the media scripts and this script.
Then create a input box and a button with NOTHING in between.. with the class 'upload_image_button'
<?php
wp_enqueue_media();
@huntlyc
huntlyc / simple-events-custom-output.php
Created October 31, 2013 16:25
This example shows how to output an unordered list of all events using the Really Simple Events Plugin (http://wordpress.org/plugins/really-simple-events/)
<?php
/**
* Function documentation for 'hc_rse_get_events($listType, $showEvents = -1, $startdate = -1, $enddate = -1)'
* Depending on the list type, get the events
*
* @param str $listType - [all|all-reverse|upcoming|upcoming-reverse|past|past-reverse]
* @param int $showEvents (optional) - the number of events to show
* @param date $startdate (optional) - date range to start
* @param date $enddate (optional) - date range to finish
* @return $wpdb result set $events - Result set of the query
@huntlyc
huntlyc / functions.php
Created February 10, 2014 19:04
simple-events-custom-table
<?php
//Setup the shortcode:
// [rse_custom_events] - this works the same as the normal one
add_shortcode( 'rse_custom_events' , 'customised_event_table' );
/**
* Parses the shortcode and displays the events. The defalt is to only show
* events which are happening from the current time onwards. To change this
* the user can suppy the 'showevents' attribute with one of the following
@huntlyc
huntlyc / svnli
Created January 28, 2015 16:36
svnli
#!/bin/bash
#
# Author: Huntly Cameron <[email protected]>
# Date: 2015-01-25
# Licence: MIT
# Description: if working dir, lists the root forlders of the repo + branches
##
# Try an info and redriect err to std input so we can save it to the status var
status=$(svn info 2>&1)
@huntlyc
huntlyc / woocommerceImgWrap.php
Last active February 20, 2016 11:37 — forked from Bradley-D/WooCommerce: Add img-wrap div to archive and tag images
Wraps woocommerce product images - based on Bradley D's gist: https://gist.github.com/Bradley-D/9479200
<?php
/**
* wrapWoocommerceImages()
*
* Wraps woocommerce product images with spans making it easier to apply custom styles.
*
* This is a slightly more involved approach based on this gist:
* https://gist.github.com/Bradley-D/9479200
*