Skip to content

Instantly share code, notes, and snippets.

View paulferrett's full-sized avatar

Paul Ferrett paulferrett

  • Melbourne, Australia
View GitHub Profile
### Keybase proof
I hereby claim:
* I am paulferrett on github.
* I am paulferrett (https://keybase.io/paulferrett) on keybase.
* I have a public key ASA9bcvJeVB79sOnbOOYnPuU0DzhQEyDCCtNkbEvON27Dgo
To claim this, I am signing this object:
@paulferrett
paulferrett / timezones_and_geo_coordinates.csv
Created May 16, 2016 10:32
List of Timezones and their Geo Coordinates
Africa/Abidjan 5.359952 -4.008256 +0:00
Africa/Accra 5.603717 -0.186964 +0:00
Africa/Addis_Ababa 8.980603 38.757761 +03:00
Africa/Algiers 36.75377 3.058793 +01:00
Africa/Asmera 15.322877 38.925052 +03:00
Africa/Bamako 12.639232 -8.002889 +0:00
Africa/Bangui 4.394674 18.55819 +01:00
Africa/Banjul 13.454876 -16.579032 +0:00
Africa/Bissau 11.881655 -15.617794 +0:00
Africa/Blantyre -15.766671 35.016787 +02:00
{
"directory": "src/Acme/Bundle/DemoBundle/Resources/public/vendor"
}
<?php
namespace Acme\YourBundle\Serializer;
use JMS\Serializer\Context;
use JMS\Serializer\JsonSerializationVisitor;
use JMS\Serializer\Metadata\ClassMetadata;
/*
* Copyright 2014 Paul Ferrett <[email protected]>
@paulferrett
paulferrett / abn_validator.php
Created December 27, 2013 01:45
Here is a PHP validation class to validate Australian Business Numbers (ABN) and Australian Company Numbers (ACN)
<?php
/**
* ABN and ACN Validator Class
* @author Paul Ferrett, 2009 (http://www.paulferrett.com)
*/
class AbnValidator {
/**
* Return true if $number is a valid ABN
@paulferrett
paulferrett / prototype_template_with_default.js
Created December 27, 2013 01:42
This allows you to create a prototype javascript template, but gives you one extra parameter where you can define default values for anything not passed by the user to .evaluate();
/**
* Create a new wrapper to the Prototype Template class to
* allow default values for the template
*
* @param template
* @param defaults
*/
var TemplateWithDefaults = Class.create(Template, {
initialize: function($super, template, defaults, pattern) {
this.defaults = defaults || {};
@paulferrett
paulferrett / INNODB_TRUNCATE.sql
Created December 27, 2013 01:37
Stored procedure to allow a efficient truncating of InnoDB tables
delimiter //
DROP PROCEDURE IF EXISTS INNODB_TRUNCATE//
CREATE PROCEDURE INNODB_TRUNCATE(IN tbl CHAR(128))
BEGIN
SET @tbl_tmp = CONCAT(tbl, '_idbtrunc_tmp');
SET @tbl = tbl;
SET @v = CONCAT("DROP TABLE IF EXISTS ", @tbl_tmp);
PREPARE drop_tmp FROM @v;
@paulferrett
paulferrett / joomla_user_import.php
Created December 23, 2013 20:24
Joomla 1.5 User Import Script
<?php
/*
Script to bulk import users into a Joomla installation (v 1.5.7).
This script is free to use, modify and distribute,
however is comes with absolutely no guarantees!
Be careful and check everything in here before running
it on your installation - has little to no error checking and is
@paulferrett
paulferrett / ordinal_suffix.php
Last active July 2, 2018 21:23
Here's a function to get the ordinal suffix of an integer in PHP.
<?php
/**
* Get the ordinal suffix of an int (e.g. th, rd, st, etc.)
*
* @param int $n
* @param bool $return_n Include $n in the string returned
* @return string $n including its ordinal suffix
*/
function ordinal_suffix($n, $return_n = true) {
@paulferrett
paulferrett / simple_xml_encode.php
Created December 23, 2013 20:01
Super simple class to encode an object into XML.
<?php
class XML {
/**
* Encode an object as XML string
*
* @param Object $obj
* @param string $root_node
* @return string $xml
*/