Skip to content

Instantly share code, notes, and snippets.

View rotassator's full-sized avatar

Steve Dixon rotassator

  • Sydney, Australia
View GitHub Profile
@rotassator
rotassator / php-get-properties-from-array-of-objects.php
Last active May 29, 2016 23:32
PHP: get properties from an array of objects
<?php
array_map(function($o) { return $o->Name; }, $arrayOfObjects);
@rotassator
rotassator / css-prevent-autofill-styles.css
Last active March 7, 2018 00:13
CSS: prevent Webkit autofill styles
// prevent webkit autofill style
&:-webkit-autofill,
&:-webkit-autofill:focus {
-webkit-box-shadow: 0 0 0 100px #fff inset;
-webkit-text-fill-color: #333;
}
@rotassator
rotassator / ss-page-example.php
Last active February 13, 2017 22:43
SilverStripe: Page model example
<?php
/** PageExample */
/**
* PageExample
*
* Example description.
*/
class PageExample extends Page
{
/** @var array Database fields */
@rotassator
rotassator / ss-dataobject-example.php
Last active August 23, 2018 23:40
SilverStripe: DataObject model example
<?php
/**
* DataObjectExample
*
* Example description.
*/
class DataObjectExample extends DataObject
{
/** @var array Database fields */
@rotassator
rotassator / css-centre-crop-image.css
Last active May 13, 2019 04:25
CSS: centre and crop an image with a fixed height
/* Centre and crop an image with a fixed height */
.crop {
position: relative; /* provide a positioning context */
overflow: hidden;
height: 200px; /* make space */
}
.crop img {
position: absolute;
left: -100%; /* anchor the image corners outside the viewable area (increase for large images) */
right: -100%;
@rotassator
rotassator / centre-vertically.css
Last active February 11, 2016 00:27
CSS: centre a child block vertically
/*
* Centre a child block vertically within its parent.
* Works in IE9+ and other browsers. http://caniuse.com/#feat=transforms2d
*/
parent {
position: relative; /* create a positioning context */
}
child {
position: absolute;
top: 50%; /* position the top of the element to the middle of the parent */
@rotassator
rotassator / ss-read-only-fields.php
Last active February 11, 2016 00:27
SilverStripe: make fields read-only on admin content tab
<?php
// make main tab fields read-only
$main_fields = $fields->fieldByName('Root.Main')->Fields();
foreach ($main_fields as $field) {
$main_fields->push($field->performReadonlyTransformation());
}
@rotassator
rotassator / Default (Windows).sublime-keymap
Created February 10, 2016 22:54
Sublime Text 3: Key Binding - restore Quick Switch Project keystroke
[
{ "keys": ["ctrl+alt+p"], "command": "prompt_select_workspace" }
]
@rotassator
rotassator / ss-generate-slug.php
Last active December 3, 2022 21:26
SilverStripe: generate url segment from title string
<?php
// generate a url segment
$this->Slug = SiteTree::create()->generateURLSegment($this->Title);