Skip to content

Instantly share code, notes, and snippets.

View wilr's full-sized avatar

Will Rossiter wilr

View GitHub Profile
@wilr
wilr / banners.html
Last active August 29, 2015 13:56
CSS3 animated colors
<div class="demo_container">
<div class="gradient gradient_1" aria-role="presentation"><!-- --></div>
<div class="gradient gradient_2" aria-role="presentation"><!-- --></div>
<div class="gradient gradient_3" aria-role="presentation"><!-- --></div>
<div class="gradient gradient_4" aria-role="presentation"><!-- --></div>
<div class="gradient gradient_5" aria-role="presentation"><!-- --></div>
<div class="gradient gradient_6" aria-role="presentation"><!-- --></div>
<div class="gradient gradient_7" aria-role="presentation"><!-- --></div>
</div>
diff --git a/dev/FixtureBlueprint.php b/dev/FixtureBlueprint.php
index e74bdee..3e95004 100644
--- a/dev/FixtureBlueprint.php
+++ b/dev/FixtureBlueprint.php
@@ -128,27 +128,53 @@ class FixtureBlueprint {
// Populate all relations
if($data) foreach($data as $fieldName => $fieldVal) {
if($obj->many_many($fieldName) || $obj->has_many($fieldName)) {
+ $obj->write();
+
@wilr
wilr / whic.sh
Created March 9, 2014 22:24
What Have I Changed? with several git repos in a project, this lists changes in all of them
#!/usr/bin/env bash
path=`pwd`
chil="/*/"
path=$path$chil
for i in $path; do
cd $i
if [ -d ".git" ]; then
echo -e "==> \033[1m$i\033[0m"
git status
@wilr
wilr / generate_animated_photos.sh
Last active August 29, 2015 14:03
Generate an animated sequence of photos. I used iPhoto export to generate a Images folder of images at a set size and resolution.
#!/bin/bash
# normalize filenames exported from iPhoto to XXXX.jpg so that the frames come
# out in order
cd Images
for f in *.jpg; do
num=`basename $f .jpg | cut -d '.' -f 1`
name=`printf "%0.4i.jpg\n" $num`
[ ! -f $name ] && mv $f $name
done
@wilr
wilr / gist:b688b612af3f6f08b1bd
Created June 29, 2014 10:54
Output contents of SilverStripe template mainfest in a readable
php -r "echo '<pre>'; print_r(unserialize(file_get_contents('silverstripe-cache/apache/templatemanifest/cache_manifest')));"
diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php
index 9f96dd7..58e91d6 100755
--- a/code/model/UserDefinedForm.php
+++ b/code/model/UserDefinedForm.php
@@ -1055,6 +1055,8 @@ JS
}
}
+ Session::set('LastSubmissionFor'. $this->ID, serialize($submittedForm));
+
@wilr
wilr / GoogleSitemapController_sitemap.ss
Created November 8, 2014 19:37
Implement localisation for Google Sitemaps
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='{$BaseHref}googlesitemaps/templates/xml-sitemap.xsl'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<% loop $Items %>
<url>
<loc>$AbsoluteLink</loc><% if Localisations %><% loop Localisations %>
<xhtml:link rel="alternate" hreflang="$PlaceHolderForLocale" href="$AbsoluteLink" /><% end_loop %><% end_if %>
<% if $LastEdited %><lastmod>$LastEdited.Format(c)</lastmod><% end_if %>
<% if $ChangeFrequency %><changefreq>$ChangeFrequency</changefreq><% end_if %>
<% if $GooglePriority %><priority>$GooglePriority</priority><% end_if %>
@wilr
wilr / Member.php
Last active August 29, 2015 14:17
Member optimisation.
diff --git a/security/Member.php b/security/Member.php
index 6fe8278..05f5d14 100644
--- a/security/Member.php
+++ b/security/Member.php
@@ -163,6 +163,9 @@ class Member extends DataObject implements TemplateGlobalProvider {
*/
private static $session_regenerate_id = true;
+ private static $_cached_current_member_id;
+ private static $_cached_current_member;
@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 / 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.
*/