Skip to content

Instantly share code, notes, and snippets.

View wilr's full-sized avatar

Will Rossiter wilr

View GitHub Profile
@wilr
wilr / LastLoggedInReport.php
Last active December 16, 2015 07:38
An example SS_Report for LastLoggedIn.
<?php
class LastLoggedInReport extends SS_Report {
public function title() {
if(isset($_GET['ago'])) {
$ago = (int) $_GET['ago'];
return "Last logged in $ago months ago";
}
@wilr
wilr / gist:5201154
Last active December 15, 2015 04:20
Wellington weather pattern (Summer '12-13) Want the tshirt? See http://www.wellhotsummer.org.nz/product/clear-skies.
C F C F F
R F F F F
F F F F F
F R F F C
F F F F C
C C F F F
F F F F F
F F F F F
F C C R F
F C F F C
@wilr
wilr / bench.sh
Created March 14, 2013 04:23 — forked from chillu/bench.sh
#/bin/bash
# Compares response times on a specific URL on different SilverStripe versions.
#
# USAGE: bench.sh <base-path> <base-url>
basepath=$1
baseurl=$2
urls="/?flush=all /"
abparams="-n 10"
@wilr
wilr / GridField_print.ss
Created March 4, 2013 22:23
An example GridField print template that contains a column with the number of submissions. See https://github.com/silverstripe/silverstripe-userforms/issues/44 for background.
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<% if $Title %><title>$Title</title><% end_if %>
</head>
<body onload="window.print();">
<% if $Title %><h3>$Title</h3><% end_if %>
<table>
<thead>
<tr>
@wilr
wilr / composer.rb
Created February 21, 2013 02:09
Composer helpers for using with Capistrano.
set :composer_bin, false
set :composer_options, "--no-scripts --verbose"
namespace :composer do
desc "Gets composer and installs it"
task :get, :roles => :app, :except => { :no_release => true } do
if remote_file_exists?("#{previous_release}/composer.phar")
pretty_print "--> Copying Composer from previous release"
run "#{try_sudo} sh -c 'cp #{previous_release}/composer.phar #{latest_release}/'"
puts_ok
@wilr
wilr / HTTPisBorkedTest.php
Created January 17, 2013 04:09
Example test to show urlRewriter is broken
<?php
class HTTPisBorkedTest extends SapphireTest {
public function testAbsoluteUrls() {
// should leave external urls along
$this->assertEquals('<a href="http://external.com">', HTTP::absoluteURLs('<a href="http://external.com">'));
}
}
@wilr
wilr / grunt.js
Created November 8, 2012 00:08
wcc/grunt.js
module.exports = function(grunt) {
grunt.initConfig({
lint: {
all: ['wcc/js/*.src.js']
},
meta: {
banner: '/*! DNA Designed Communications Limited | Copyright 2012 */'
},
less: {
development: {
@wilr
wilr / app._config.routes.yml
Created September 15, 2012 00:29
Basic SilverStripe 3.0 Framework Bootstrap
---
Name: app
After: framework/routes#coreroutes
---
Director:
rules:
'dev': 'DevelopmentAdmin'
'sitemap.xml': 'GoogleSitemap'
'$Action' : 'BaseController'
@wilr
wilr / .htaccess
Created August 6, 2012 06:26
XHProf
php_value auto_prepend_file header.php
php_value auto_append_file footer.php
@wilr
wilr / Tweet.php
Created July 6, 2012 03:38
A simple SilverStripe PHP class for loading a stream of tweets from a XML file.
<?php
/**
* Loads tweets onto a SilverStripe object through a XML file rather than the
* web API.
*
* Usage:
*
* // PHP
* function Tweets() {