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 / 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 / idletimeout.js
Created March 28, 2012 19:34
JavaScript User Idle Timeout script.
// Define some global vars for our idle timer
var idleTime = 0;
var countdown = 10;
var idlemin = 10;
var idlemax = 20;
//
//
// you need to define your own HTML and css styles for the warning message and fade layer.
// the warning message goes in a div with the ID #idlewarn
@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 / prettyjson.css
Last active July 29, 2021 21:24
Pretty print and syntax highlight JSON See it in action at http://jsfiddle.net/faffyman/KRb8W/
pre {
outline: 1px solid #ccc;
padding: 5px; margin:
5px;
}
.string {
color: #008000;
}
@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]