Skip to content

Instantly share code, notes, and snippets.

View faffyman's full-sized avatar
💭
I may be slow to respond.

Tim Swann faffyman

💭
I may be slow to respond.
View GitHub Profile
@faffyman
faffyman / vbox-tips.md
Last active August 29, 2015 14:00
Virtual Box Hints & Tips

List VMS at the command line

VBoxManage list vms

This should show something like:-

  • "IE11 - Win8.1" {054501a7-7636-407a-b124-9b6c9724ffa4}
  • "IE6 - WinXP" {f3fab135-8b15-4b6a-a446-d747854d9688}
  • "<inaccessible>" {c7601a5b-eef7-4660-8fdc-a9fbc8dab9d3}
@faffyman
faffyman / SoapDaysUntilChristmas.php
Created January 31, 2012 09:45
A quickie just-for-fun script used to count the days until Christmas. Originally used as part of a SOAP service hence the XML output.
<?php
/*
* This class was originally written as part of a SOAP service - just for fun
*
* used as a countdown until Christmas
* Returns
* the number of Days
* the number of Shopping Days
* the number of Weekends
* */
@faffyman
faffyman / function.app_rand.php
Created March 28, 2012 15:34
Simple Smarty Plugin for generating a random integer
<?php
/**
* Smarty plugin wrapper for PHP's rand function
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {app_rand} function plugin
*
@faffyman
faffyman / gmapembed.js
Created March 28, 2012 20:00
Auto embed a google map from it's share link
// --------------------------------------------------------
// auto embed google map if google map link found in body
// Allows site content editors to simply place a standard
// link in their text, and this will turn it into an
// embedded map
// --------------------------------------------------------
// N.B. links with a class of dont-embed means... duh. dont embed.
var sMapSel = 'a[href^="http://maps.google.co.uk/maps"]:not(.dont-embed)' ;
@faffyman
faffyman / modifier.readable_filesize.php
Created April 24, 2012 11:11
Smarty Modifier: readable_filesize - displays a filesize in an easier to read format/ best units available.
<?php
/**
* Smarty plugin
*
* @package App
* @subpackage SmartyPluginsModifier
*/
/**
* Smarty number modifier
@faffyman
faffyman / fillme-clearme.js
Created October 3, 2012 20:59
just for fun - testing the embed gist feature
function clearMe(oObj,val) {
if(oObj.value==val) {
oObj.value='';
}
}
function fillMe(oObj,val) {
if (oObj.value=='') {
oObj.value=val
}
@faffyman
faffyman / colorReduce.php
Created October 5, 2012 07:51
Build a colorProfile from an image with Imagick
/**
* Generate a Color Palette
* Using Imagick to quantize the image
* (http://www.php.net/manual/en/class.imagick.php)
*
* ASSUMPTION - your image directory has suitable permission levels to allow
* your script to edit/copy/create files.
**/
@faffyman
faffyman / Urlize.php
Last active December 23, 2015 18:19
A view helper for ZF2 (Zend Framework 2) This view helper will "urlize" a word or phrase to make it "safer" as a url slug. e.g. It's Séan's Party becomes its-seans-party
<?php
namespace Application\View\Helper;
use Zend\View\Helper\AbstractHelper;
class Urlize extends AbstractHelper
{
public function __invoke($string)
{
@faffyman
faffyman / apache.sh
Created November 13, 2013 17:42
Reminder hint list of Unix commands for working with apache
# enable a site
sudo a2ensite
# disable a site
sudo a2dissite
# enable an apache2 module
sudo a2enmod
# a2enmod [modulename]
@faffyman
faffyman / functions.php
Created January 23, 2017 14:29
Wordpress - Sort Admin Table Column by Taxonomy
// functions.php
/**
* Snippet to create allow a custom admin column to be sortable when it uses Taxonomy terms
**/
if(!function_exists('sz_sort_POSTNAME_by_COLUMN-NAME')){
function sz_sort_POSTNAME_by_COLUMN-NAME($clauses, $wp_query){
global $wpdb;
if(isset($wp_query->query['orderby']) && $wp_query->query['orderby'] == 'YOUR ORDERBY FIELD'){