Skip to content

Instantly share code, notes, and snippets.

View wilr's full-sized avatar

Will Rossiter wilr

View GitHub Profile
@wilr
wilr / UniqueEmailField.php
Last active September 24, 2015 20:17
A SilverStripe Email Field which enforces unique email addresses.
<?php
/**
* UniqueEmailField extends the built in {@link EmailField} but add's an additional check
* to the validation to ensure a member doesn't already exist which the email given.
*
* @author Will Rossiter <http://twitter.com/wilr>
*/
class UniqueEmailField extends EmailField {
@wilr
wilr / export.sql
Created February 8, 2011 02:12
Generates a list of all the suburbs and regions (with lat/lngs in NZ). Uses a timeout interval to prevent issues with the google geocoder. If you're too lazy to wait for that script to run, the SQL is attached below. I accept no responsibility for the acc
# ************************************************************
# Sequel Pro SQL dump
# Version 3348
#
# http://www.sequelpro.com/
# http://code.google.com/p/sequel-pro/
#
# Host: localhost (MySQL 5.1.54)
# Generation Time: 2011-07-10 19:08:36 +1200
# ************************************************************
@wilr
wilr / SilverStripe CMS CSS Coding Conventions.css
Created February 17, 2011 21:41
A sample SCSS file which describes the formatting guidelines of the CMS module.
/**
* Description of the file and what it covers.
*
* If there are any items you need to finish or which
* people need to be aware of use @todo like below, remember
* to remove the @todo's once you have completed them
*
* @todo Finish.
*/
@wilr
wilr / Menu.css
Created March 9, 2011 08:38
Dropdown Menu Example
#menu {}
#menu ul {
position:relative; z-index:500;
margin: 0 auto;
}
#menu li {
float: left;
list-style: none;
}
@wilr
wilr / google-reader-hide-count.js
Created July 26, 2011 11:14
Userscript - Google Reader - Hide unread counts and styles
// ==UserScript==
// @name Google Reader - Hide unread counts and styles
// @version 1.0.1
// @namespace http://willrossi.com
// @author willrossi
// @description Hide unread counts and indicators (including bold font faces) on Google Reader.
// @include http*://www.google.*/reader/*
// ==/UserScript==
(function() {
@wilr
wilr / event.tracking.js
Created August 26, 2011 03:54
Simple jQuery Helper for wrapping GA event tracking
(function($) {
/*
A simple helper plugin for wrapping Google Analytic event tracking
into sites through jQuery and HTML5 data attributes.
This assumes that you have used the standard configuration provided
by google for setting up Google Analytics and used the _gaq var for
storing the tracker.
Can track focus, activate, hover and click input methods but not key
@wilr
wilr / share.ss
Created September 30, 2011 01:58
Basic Facebook and Twitter Share Links
<div class="share-buttons">
<!-- data-via can be the twitter username, data-related is another twitterusername -->
<div class="twitter">
<a href="http://twitter.com/share" class="twitter-share-button" data-text="$Title" data-url="$AbsoluteLink" data-count="horizontal" data-via="" data-related="">Tweet</a>
</div>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<iframe src="http://www.facebook.com/plugins/like.php?href={$AbsoluteLink}&amp;layout=button_count&amp;show_faces=false&amp;width=150&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>
</div>
@wilr
wilr / gist:1471003
Created December 13, 2011 07:09
Check theme folder exists (sapphire). Allows site dev to delete themes/
diff --git a/sapphire/core/i18n.php b/sapphire/core/i18n.php
index 25190b1..cbd7903 100755
--- a/sapphire/core/i18n.php
+++ b/sapphire/core/i18n.php
@@ -1872,13 +1872,15 @@ class i18n extends Object {
// Load translations from themes
$themesBase = $base . '/themes';
- foreach(scandir($themesBase) as $theme) {
- if(
@wilr
wilr / ResampleUpload.php
Created April 4, 2012 05:33
An extension for resampling SilverStripe images on upload.
<?php
/**
* An extension to SilverStripes inbuilt {@link Image} class to handle resizing
* large images on upload either through the backend interface or through upload
* forms.
*
* File is resized to a copy, then the original is deleted and the smaller image
* moved back.
*
@wilr
wilr / CancelFormAction.php
Created April 5, 2012 10:57
Cancel form action for SilverStripe
<?php
/**
* Action that takes the user back to a given link rather than submitting
* the form.
*
* @package cancelformaction
*/
class CancelFormAction extends FormAction {